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

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

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

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

    public enum State {
      OFF,
      ON_NOTIFICATION,
      ON_ACTIVATION,
    }

    public class MuteChangedEvent : Com.Raritan.Idl._event.UserEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("hmi.InternalBeeper.MuteChangedEvent:1.0.0", Com.Raritan.Idl._event.UserEvent.typeInfo);

      public bool muted = false;
    }

    public class StateChangedEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("hmi.InternalBeeper.StateChangedEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public Com.Raritan.Idl.hmi.InternalBeeper.State state = Com.Raritan.Idl.hmi.InternalBeeper.State.OFF;
      public string reason = "";
    }

    public class MuteResult {
    }

    public MuteResult mute(bool muted) {
      var _parameters = new LightJson.JsonObject();
      _parameters["muted"] = muted;

      var _result = RpcCall("mute", _parameters);
      var _ret = new MuteResult();
      return _ret;
    }

    public AsyncRequest mute(bool muted, AsyncRpcResponse<MuteResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return mute(muted, rsp, fail, RpcCtrl.Default);
    }

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

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

    public class IsMutedResult {
      public bool _ret_;
    }

    public IsMutedResult isMuted() {
      JsonObject _parameters = null;
      var _result = RpcCall("isMuted", _parameters);
      var _ret = new IsMutedResult();
      _ret._ret_ = (bool)_result["_ret_"];
      return _ret;
    }

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

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

    public class ActivateResult {
    }

    public ActivateResult activate(bool on, string reason, int timeout) {
      var _parameters = new LightJson.JsonObject();
      _parameters["on"] = on;
      _parameters["reason"] = reason;
      _parameters["timeout"] = timeout;

      var _result = RpcCall("activate", _parameters);
      var _ret = new ActivateResult();
      return _ret;
    }

    public AsyncRequest activate(bool on, string reason, int timeout, AsyncRpcResponse<ActivateResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return activate(on, reason, timeout, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest activate(bool on, string reason, int timeout, AsyncRpcResponse<ActivateResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["on"] = on;
        _parameters["reason"] = reason;
        _parameters["timeout"] = timeout;
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

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

    public class GetStateResult {
      public Com.Raritan.Idl.hmi.InternalBeeper.State _ret_;
      public string reason;
    }

    public GetStateResult getState() {
      JsonObject _parameters = null;
      var _result = RpcCall("getState", _parameters);
      var _ret = new GetStateResult();
      _ret._ret_ = (Com.Raritan.Idl.hmi.InternalBeeper.State)(int)_result["_ret_"];
      _ret.reason = (string)_result["reason"];
      return _ret;
    }

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

    public AsyncRequest getState(AsyncRpcResponse<GetStateResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getState", _parameters,
        _result => {
          try {
            var _ret = new GetStateResult();
            _ret._ret_ = (Com.Raritan.Idl.hmi.InternalBeeper.State)(int)_result["_ret_"];
            _ret.reason = (string)_result["reason"];
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
