// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2020 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from LhxDevel.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.lhxmodel {
  public class LhxDevel_1_1_2 : Com.Raritan.Idl.lhxmodel.Lhx_3_2_4 {

    static public readonly new TypeInfo typeInfo = new TypeInfo("lhxmodel.LhxDevel:1.1.2", null);

    public LhxDevel_1_1_2(Agent agent, string rid, TypeInfo ti) : base(agent, rid, ti) {}
    public LhxDevel_1_1_2(Agent agent, string rid) : this(agent, rid, typeInfo) {}

    public static new LhxDevel_1_1_2 StaticCast(ObjectProxy proxy) {
      return proxy == null ? null : new LhxDevel_1_1_2(proxy.Agent, proxy.Rid, proxy.StaticTypeInfo);
    }

    public class ParameterData : ICloneable {
      public object Clone() {
        ParameterData copy = new ParameterData();
        copy.value = this.value;
        copy.rawValue = this.rawValue;
        copy.metadata = this.metadata;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["value"] = this.value;
        json["rawValue"] = this.rawValue;
        json["metadata"] = this.metadata.Encode();
        return json;
      }

      public static ParameterData Decode(LightJson.JsonObject json, Agent agent) {
        ParameterData inst = new ParameterData();
        inst.value = (double)json["value"];
        inst.rawValue = (int)json["rawValue"];
        inst.metadata = Com.Raritan.Idl.lhxmodel.Parameter_2_0_1.MetaData.Decode(json["metadata"], agent);
        return inst;
      }

      public double value = 0.0;
      public int rawValue = 0;
      public Com.Raritan.Idl.lhxmodel.Parameter_2_0_1.MetaData metadata = new Com.Raritan.Idl.lhxmodel.Parameter_2_0_1.MetaData();
    }

    public class DumpParameterResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.lhxmodel.LhxDevel_1_1_2.ParameterData> _ret_;
    }

    public DumpParameterResult dumpParameter() {
      JsonObject _parameters = null;
      var _result = RpcCall("dumpParameter", _parameters);
      var _ret = new DumpParameterResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.lhxmodel.LhxDevel_1_1_2.ParameterData>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.lhxmodel.LhxDevel_1_1_2.ParameterData.Decode(_value, agent)));
      return _ret;
    }

    public AsyncRequest dumpParameter(AsyncRpcResponse<DumpParameterResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return dumpParameter(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest dumpParameter(AsyncRpcResponse<DumpParameterResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("dumpParameter", _parameters,
        _result => {
          try {
            var _ret = new DumpParameterResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.lhxmodel.LhxDevel_1_1_2.ParameterData>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.lhxmodel.LhxDevel_1_1_2.ParameterData.Decode(_value, agent)));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
