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

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

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

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

    public class GetScannerResult {
      public Com.Raritan.Idl.tfw.ScannerCtrl _ret_;
    }

    public GetScannerResult getScanner(string name) {
      var _parameters = new LightJson.JsonObject();
      _parameters["name"] = name;

      var _result = RpcCall("getScanner", _parameters);
      var _ret = new GetScannerResult();
      _ret._ret_ = Com.Raritan.Idl.tfw.ScannerCtrl.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
      return _ret;
    }

    public AsyncRequest getScanner(string name, AsyncRpcResponse<GetScannerResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getScanner(name, rsp, fail, RpcCtrl.Default);
    }

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

      return RpcCall("getScanner", _parameters,
        _result => {
          try {
            var _ret = new GetScannerResult();
            _ret._ret_ = Com.Raritan.Idl.tfw.ScannerCtrl.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class StartAllScannersResult {
    }

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

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

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

    public class StopAllScannersResult {
    }

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

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

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

    public class StartAllBackWorkersResult {
    }

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

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

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

    public class StopAllBackWorkersResult {
    }

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

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

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

  }
}
