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

    static public readonly new TypeInfo typeInfo = new TypeInfo("tfw.ScannerCtrl:1.0.0", null);

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

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

    public class GetScanIntervalResult {
      public int _ret_;
    }

    public GetScanIntervalResult getScanInterval() {
      JsonObject _parameters = null;
      var _result = RpcCall("getScanInterval", _parameters);
      var _ret = new GetScanIntervalResult();
      _ret._ret_ = (int)_result["_ret_"];
      return _ret;
    }

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

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

    public class SetScanIntervalResult {
    }

    public SetScanIntervalResult setScanInterval(int interval) {
      var _parameters = new LightJson.JsonObject();
      _parameters["interval"] = interval;

      var _result = RpcCall("setScanInterval", _parameters);
      var _ret = new SetScanIntervalResult();
      return _ret;
    }

    public AsyncRequest setScanInterval(int interval, AsyncRpcResponse<SetScanIntervalResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return setScanInterval(interval, rsp, fail, RpcCtrl.Default);
    }

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

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

  }
}
