public override string InitIO(string port) { _iniSettings = new IniSettings(HS); //_iniSettings.IniSettingsChangedForCheckInterval += IniSettingsChangedForCheckInterval; _iniSettings.IniSettingsChangedForUserNamePassword += IniSettingsChangedForUserNamePassword;; _log = new Log(HS, _iniSettings); _log.Info("Starting plugin"); _config = new ConfigHandler(HS, Callback, _iniSettings, _log); _config.Register(); _deviceHandler = new DeviceHandler(HS, _log); _settings = new Setting(HS); _settings.DoIniFileTemplateIfFileMissing(); _restHandler = new RestHandler(_log); StartLoginAndDataFetchingInNewThread(); Shutdown = false; _log.Debug("Done init io"); return(""); }
/// <summary> /// Gets the device handler of the given handler class name via reflection. /// </summary> /// <param name="handlerClassName">The class name of the device handler to get.</param> /// <param name="lowerLayer">The lower layer for talking to this device.</param> /// <param name="oidTable">The OID lookup table for the device.</param> /// <param name="osVersion">The SW version of the device.</param> /// <param name="model">The device's model name. Shall be the same name as used for the device name during OID database lookups.</param> /// <param name="options">The options to use.</param> /// <returns>The generated device handler.</returns> protected IDeviceHandler GetHandlerViaReflection(string handlerClassName, ISnmpLowerLayer lowerLayer, IDeviceSpecificOidLookup oidTable, SemanticVersion osVersion, string model, IQuerierOptions options) { var type = Type.GetType($"SnmpAbstraction.{handlerClassName}"); if (type == null) { var ex = new HamnetSnmpException($"{lowerLayer.Address} ({model} v {osVersion}): Cannot find a DeviceHandler implementation of name '{handlerClassName}'", lowerLayer.Address?.ToString()); this.CollectException("Missing handler class name", ex); throw ex; } object myObject = null; try { myObject = Activator.CreateInstance(type, lowerLayer, oidTable, osVersion, model, options); } catch (Exception ex) { this.CollectException($"Instantiate handler class '{type.FullName}'", ex); throw new HamnetSnmpException($"{lowerLayer.Address} ({model} v {osVersion}): Exception while instantiating DeviceHandler of name '{handlerClassName}': {ex.Message}", ex, lowerLayer.Address?.ToString()); } IDeviceHandler castedHandler = myObject as IDeviceHandler; if (castedHandler == null) { var ex = new HamnetSnmpException($"{lowerLayer.Address} ({model} v {osVersion}): Instantiating DeviceHandler of name '{handlerClassName}' is NOT an IDeviceHandler", lowerLayer.Address?.ToString()); this.CollectException($"Cast handler class '{type.FullName}' to IDeviceHandler", ex); throw ex; } return(castedHandler); }
/// <summary> /// Creates a new querier using the given lower layer and options. /// </summary> /// <param name="lowerLayer">The IP address of the device to query.</param> /// <param name="options">The options for the query.</param> /// <returns>An <see cref="IHamnetQuerier" /> that talks to the given address.</returns> internal IHamnetQuerier Create(ISnmpLowerLayer lowerLayer, IQuerierOptions options) { if (lowerLayer == null) { throw new ArgumentNullException(nameof(lowerLayer), "lowerLayer is null"); } IHamnetQuerier querier = null; if (options.EnableCaching) { querier = new CachingHamnetQuerier(lowerLayer, options); } else { var detector = new DeviceDetector(lowerLayer); IDeviceHandler handler = detector.Detect(options); if (handler == null) { var errorInfo = $"Cannot obtain a feasible device handler for device '{lowerLayer.Address}'"; log.Error(errorInfo); throw new HamnetSnmpException(errorInfo, lowerLayer.Address?.ToString()); } querier = new HamnetQuerier(handler, lowerLayer.Options); } return(querier); }
public ProtocolHandler(IDeviceHandler deviceHandler, ConfirmationFactory confirmationFactory, ReplyFactory replyFactory, OrderFactory orderFactory, CommandTranslator commandTranslator, ResponseAwaiterDispatch awaiterDispatch) { _deviceHandler = deviceHandler; _confirmationFactory = confirmationFactory; _replyFactory = replyFactory; _orderFactory = orderFactory; _commandTranslator = commandTranslator; _awaiterDispatch = awaiterDispatch; _deviceHandler.CommandReceived += OnCommandReceived; }
public InputController(EngagementType a_type, int id = -1) { if (a_type == EngagementType.Keyboard) { Device = new KeyboardHandler(InputManager.Instance.KeyboardDefaults()); } else if (a_type == EngagementType.Controller) { Device = new GamepadHandler(id, InputManager.Instance.GamePadDefaults()); } }
/// <summary> /// Creates a new instance using the specified device handler. /// </summary> /// <param name="handler">The device handler to use for obtaining SNMP data.</param> /// <param name="options">The options for the query.</param> public HamnetQuerier(IDeviceHandler handler, IQuerierOptions options) { if (handler == null) { throw new ArgumentNullException(nameof(handler), "The device handler is null"); } if (options == null) { throw new ArgumentNullException(nameof(options), "The query options are null"); } this.handler = handler; this.options = options; }
protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { if (this.handler != null) { this.handler.Dispose(); this.handler = null; } } this.disposedValue = true; } }
public DeviceController(IDeviceHandler deviceHandler) { _deviceHandler = deviceHandler; }
public void RegisterHandler(IDeviceHandler handler) { var handlerList = GetHandlerList(handler.ServiceIdentifier); handlerList.Add(handler); }
public InputController() { Device = new KeyboardHandler(); }
public LogBrowserController(ILogger <LogBrowserController> logger, IDeviceHandler devicehandler) : base(logger) => _devicehandler = devicehandler;
public ProtocolHandlerTestWrapper(IDeviceHandler deviceHandler, ConfirmationFactory confirmationFactory, ReplyFactory replyFactory, OrderFactory orderFactory, CommandTranslator commandTranslator, ResponseAwaiterDispatch awaiterDispatch) : base(deviceHandler, confirmationFactory, replyFactory, orderFactory, commandTranslator, awaiterDispatch) { }
public DeviceController(ILogger <DeviceController> logger, IDeviceHandler deviceHandler) : base(logger) => _deviceHandler = deviceHandler;
public PaneController(IPaneHandler paneHandler, IDeviceHandler deviceHandler) { _paneHandler = paneHandler; _deviceHandler = deviceHandler; }