// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2026 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from TestUnit.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.test {
  public class Unit_2_0_0 : ObjectProxy {

    static public readonly new TypeInfo typeInfo = new TypeInfo("test.Unit:2.0.0", null);

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

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

    public class GetDisplaysResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.test.Display_2_0_0> _ret_;
    }

    public GetDisplaysResult getDisplays() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDisplays", _parameters);
      var _ret = new GetDisplaysResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.test.Display_2_0_0>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.test.Display_2_0_0.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

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

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

    public class GetButtonStatesResult {
      public System.Collections.Generic.IEnumerable<bool> _ret_;
    }

    public GetButtonStatesResult getButtonStates() {
      JsonObject _parameters = null;
      var _result = RpcCall("getButtonStates", _parameters);
      var _ret = new GetButtonStatesResult();
      _ret._ret_ = new System.Collections.Generic.List<bool>(_result["_ret_"].AsJsonArray.Select(
        _value => (bool)_value));
      return _ret;
    }

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

    public AsyncRequest getButtonStates(AsyncRpcResponse<GetButtonStatesResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getButtonStates", _parameters,
        _result => {
          try {
            var _ret = new GetButtonStatesResult();
            _ret._ret_ = new System.Collections.Generic.List<bool>(_result["_ret_"].AsJsonArray.Select(
              _value => (bool)_value));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class SetBuzzerResult {
    }

    public SetBuzzerResult setBuzzer(bool isOn) {
      var _parameters = new LightJson.JsonObject();
      _parameters["isOn"] = isOn;

      var _result = RpcCall("setBuzzer", _parameters);
      var _ret = new SetBuzzerResult();
      return _ret;
    }

    public AsyncRequest setBuzzer(bool isOn, AsyncRpcResponse<SetBuzzerResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return setBuzzer(isOn, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest setBuzzer(bool isOn, AsyncRpcResponse<SetBuzzerResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["isOn"] = isOn;
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("setBuzzer", _parameters,
        _result => {
          try {
            var _ret = new SetBuzzerResult();
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class ResetAllSubControllersResult {
    }

    public ResetAllSubControllersResult resetAllSubControllers() {
      JsonObject _parameters = null;
      var _result = RpcCall("resetAllSubControllers", _parameters);
      var _ret = new ResetAllSubControllersResult();
      return _ret;
    }

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

    public AsyncRequest resetAllSubControllers(AsyncRpcResponse<ResetAllSubControllersResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("resetAllSubControllers", _parameters,
        _result => {
          try {
            var _ret = new ResetAllSubControllersResult();
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class TriggerSubControllerWatchdogResult {
    }

    public TriggerSubControllerWatchdogResult triggerSubControllerWatchdog(int rs485Addr) {
      var _parameters = new LightJson.JsonObject();
      _parameters["rs485Addr"] = rs485Addr;

      var _result = RpcCall("triggerSubControllerWatchdog", _parameters);
      var _ret = new TriggerSubControllerWatchdogResult();
      return _ret;
    }

    public AsyncRequest triggerSubControllerWatchdog(int rs485Addr, AsyncRpcResponse<TriggerSubControllerWatchdogResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return triggerSubControllerWatchdog(rs485Addr, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest triggerSubControllerWatchdog(int rs485Addr, AsyncRpcResponse<TriggerSubControllerWatchdogResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["rs485Addr"] = rs485Addr;
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("triggerSubControllerWatchdog", _parameters,
        _result => {
          try {
            var _ret = new TriggerSubControllerWatchdogResult();
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
