// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2020 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from PeripheralDevicePackage.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.peripheral {

  public class PackageInfo : ICloneable {
    public object Clone() {
      PackageInfo copy = new PackageInfo();
      copy.state = this.state;
      copy.position = this.position;
      copy.hwInfo = this.hwInfo;
      copy.fwInfo = this.fwInfo;
      return copy;
    }

    public LightJson.JsonObject Encode() {
      LightJson.JsonObject json = new LightJson.JsonObject();
      json["state"] = (int)this.state;
      json["position"] = new JsonArray(this.position.Select(
        _value => (JsonValue)(_value.Encode())));
      json["hwInfo"] = this.hwInfo.Encode();
      json["fwInfo"] = this.fwInfo.Encode();
      return json;
    }

    public static PackageInfo Decode(LightJson.JsonObject json, Agent agent) {
      PackageInfo inst = new PackageInfo();
      inst.state = (Com.Raritan.Idl.peripheral.PackageInfo.State)(int)json["state"];
      inst.position = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PosElement>(json["position"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.PosElement.Decode(_value, agent)));
      inst.hwInfo = Com.Raritan.Idl.peripheral.PackageInfo.HardwareInfo.Decode(json["hwInfo"], agent);
      inst.fwInfo = Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo.Decode(json["fwInfo"], agent);
      return inst;
    }


    public enum State {
      NORMAL,
      FW_UPDATE,
      INTERNAL_ERROR,
      CONFIG_ERROR,
    }

    public class HardwareInfo : ICloneable {
      public object Clone() {
        HardwareInfo copy = new HardwareInfo();
        copy.serial = this.serial;
        copy.packageClass = this.packageClass;
        copy.model = this.model;
        copy.minDowngradeVersion = this.minDowngradeVersion;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["serial"] = this.serial;
        json["packageClass"] = this.packageClass;
        json["model"] = this.model;
        json["minDowngradeVersion"] = this.minDowngradeVersion;
        return json;
      }

      public static HardwareInfo Decode(LightJson.JsonObject json, Agent agent) {
        HardwareInfo inst = new HardwareInfo();
        inst.serial = (string)json["serial"];
        inst.packageClass = (string)json["packageClass"];
        inst.model = (string)json["model"];
        inst.minDowngradeVersion = (int)json["minDowngradeVersion"];
        return inst;
      }

      public string serial = "";
      public string packageClass = "";
      public string model = "";
      public int minDowngradeVersion = 0;
    }

    public class FirmwareInfo : ICloneable {
      public object Clone() {
        FirmwareInfo copy = new FirmwareInfo();
        copy.compileDate = this.compileDate;
        copy.version = this.version;
        copy.updateDate = this.updateDate;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["compileDate"] = this.compileDate.Ticks;
        json["version"] = this.version.Encode();
        json["updateDate"] = this.updateDate.Ticks;
        return json;
      }

      public static FirmwareInfo Decode(LightJson.JsonObject json, Agent agent) {
        FirmwareInfo inst = new FirmwareInfo();
        inst.compileDate = new System.DateTime(json["compileDate"]);
        inst.version = Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo.Version.Decode(json["version"], agent);
        inst.updateDate = new System.DateTime(json["updateDate"]);
        return inst;
      }


      public class Version : ICloneable {
        public object Clone() {
          Version copy = new Version();
          copy.majorNumber = this.majorNumber;
          copy.minorNumber = this.minorNumber;
          return copy;
        }

        public LightJson.JsonObject Encode() {
          LightJson.JsonObject json = new LightJson.JsonObject();
          json["majorNumber"] = this.majorNumber;
          json["minorNumber"] = this.minorNumber;
          return json;
        }

        public static Version Decode(LightJson.JsonObject json, Agent agent) {
          Version inst = new Version();
          inst.majorNumber = (int)json["majorNumber"];
          inst.minorNumber = (int)json["minorNumber"];
          return inst;
        }

        public int majorNumber = 0;
        public int minorNumber = 0;
      }
      public System.DateTime compileDate = new System.DateTime(0);
      public Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo.Version version = new Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo.Version();
      public System.DateTime updateDate = new System.DateTime(0);
    }
    public Com.Raritan.Idl.peripheral.PackageInfo.State state = Com.Raritan.Idl.peripheral.PackageInfo.State.NORMAL;
    public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.PosElement> position = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PosElement>();
    public Com.Raritan.Idl.peripheral.PackageInfo.HardwareInfo hwInfo = new Com.Raritan.Idl.peripheral.PackageInfo.HardwareInfo();
    public Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo fwInfo = new Com.Raritan.Idl.peripheral.PackageInfo.FirmwareInfo();
  }
}
