public void AddDisplay(int baseAddress) { IDeviceInput input = _devicesFactory.GetDisplay(baseAddress); _devices.Add(input); input.OpenForm(); }
public void AddTimer2(int baseAddress, int irq) { IDeviceInput input = _devicesFactory.GetTimer2(baseAddress, irq); _devices.Add(input); input.OpenForm(); }
public void AddKeypadAndIndication(int baseAddress, int irq) { IDeviceInput input = _devicesFactory.GetKeypadAndIndication(baseAddress, irq); _devices.Add(input); input.OpenForm(); }
public void KeypadAndIndicationControllerCreateTest() { IDeviceOutput deviceOutput = new ExternalDevicesController(_externalDevice); DevicesFactory devicesFactory = new DevicesFactory(deviceOutput); IDeviceInput keypadAndIndicationController = devicesFactory.GetKeypadAndIndication(1, 1); Assert.IsInstanceOfType(keypadAndIndicationController, typeof(KeypadAndIndicationController)); }
public void OscillographControllerCreateTest() { IDeviceOutput deviceOutput = new ExternalDevicesController(_externalDevice); DevicesFactory devicesFactory = new DevicesFactory(deviceOutput); IDeviceInput oscillographController = devicesFactory.GetOscillograph(); Assert.IsInstanceOfType(oscillographController, typeof(OscillographController)); }
public void AddExternalDevice() { // todo select proper device IDeviceInput input = _devicesFactory.GetKeyboard1(); _devices.Add(input); input.OpenForm(); }
public Thermostat(IDeviceInput inp, IDeviceOutput outp) : base(inp, outp) { Enabled = false; SetPoint = new Temperature() { Temp = 0 }; Value = new Temperature() { Temp = 0 }; }
/** * Rests internal IO objects for this Device. With no arguments, the * device will no longer communicate with any remote authority, making this object * useful for storing old results/dumb usage. * \param[in] inp IDeviceInput instance, defaults to a NullDeviceInput. * \param[out] outp IDeviceOutput instance, defaults to a NullDeviceOutput. */ public void resetIO(IDeviceInput inp = default(IDeviceInput), IDeviceOutput outp = default(IDeviceOutput)) { //Force sane defaults, so we can assume these are always valid if (inp == null) { inp = new NullDeviceInput(); } if (outp == null) { outp = new NullDeviceOutput(); } _in = inp; _out = outp; }
public Device(IDeviceInput inp, IDeviceOutput outp, TimeFrame frame) { resetIO(inp, outp); if (frame == null) { frame = new TimeFrame(); } _frame = frame; _last_time = DateTime.MinValue; //Set to minimum possible time _id = new FullID(); _name = ""; _update_ok = false; }
public Thermostat(IDeviceInput inp, IDeviceOutput outp, TimeFrame frame) : base(inp, outp, frame) { Enabled = false; SetPoint = new Temperature() { Temp = 0 }; Value = new Temperature() { Temp = 0 }; Class = "Thermostat"; }
public InGameWrapper(UnityData unityData, IDeviceInput deviceInput) { instance = this; logger = new UnityLogger(); camera = GameObject.Find("Camera").GetComponent <Camera>(); clockWrapper = new ClockWrapper(); resetLogic = new ResetLogic(); playersWrapper = new PlayersWrapper(unityData.playerData, deviceInput); mapWrapper = new MapWrapper(unityData.mapData, playersWrapper.GetOnlyLocalPlayer()); spellsWrapper = new SpellWrapper(unityData.spellData); cursorWrapper = new CursorWrapper(unityData.cursorData); aimWrapper = new AimWrapper(unityData.aimData, deviceInput); currencyWrapper = new CurrencyWrapper(unityData.currencyWrapper); EverythingSetupEvent(); }
public PlayerController(GameObject playerGmj, Message_ServerCommand_CreateGameObject info, UnityPlayerData generalPlayerData, IDeviceInput deviceInput) { alive = true; playerScoreController = new PlayerScoreController(); spellCaster = new SpellCasterController(this); playerAnimator = new PlayerAnimatorController(playerGmj); healthController = new PlayerHealthController(this, generalPlayerData); this.playerGmj = playerGmj; this.generalPlayerData = generalPlayerData; PlayerControllerGUID = info.GmjGUID; OwnerID = info.OwnerGUID; playerGmj.transform.position = new Vector3(info.transform.xPos, StaticVariables.GetYPos(), info.transform.zPos); targetPos = playerGmj.transform.position; this.deviceInput = deviceInput; }
public void KeypadAndIndicationSetAndGetMemoryTest() { IDeviceOutput deviceOutput = new ExternalDevicesController(_externalDevice); DevicesFactory devicesFactory = new DevicesFactory(deviceOutput); int[] mas = { 0x10, 0x12, 0x13 }; ExtendedBitArray extendedBitArray = new ExtendedBitArray(1); IDeviceInput keypadAndIndicationController = devicesFactory.GetKeypadAndIndication(0x1, 1); foreach (var m in mas) { keypadAndIndicationController.SetMemory(extendedBitArray, m); Assert.AreEqual(extendedBitArray, keypadAndIndicationController.GetMemory(m)); } }
private void InitInputDevice() { _inputDevice = new MouseInput(); _moveSpeed = MouseMoveSpeed; _zoomSpeed = MouseZoomSpeed; _rotationSpeed = MouseRotationSpeed; if (Input.touchSupported) { _inputDevice = new TouchInput(); _moveSpeed = TouchMoveSpeed; _zoomSpeed = TouchZoomSpeed; _rotationSpeed = TouchRotationSpeed; } _isEnabled = true; }
/** * Given an instance of the device, attempts to update all public properties with info * from the new device instance. Note that devices currently must have the same ID, but * the actual classes do not need to be the same. * \param[in] old_dev Device which will be updated. * \param[in] new_dev Device which contains values to be updated with * \param[in] silence_io Temporarily disable the Device IO for simple value updating * \param[out] Flag indicating if a field was updated with a new value */ public static bool UpdateDevice(Device old_dev, Device new_dev, bool silence_io = false) { if (old_dev == null || new_dev == null) { return(false); } var props = old_dev.GetType().GetRuntimeProperties(); bool update_field = false; IDeviceInput inp = null; IDeviceOutput outp = null; if (silence_io) { inp = old_dev.Input; outp = old_dev.Output; old_dev.resetIO(); } foreach (var info in props) { //Can't update this method if (info.SetMethod == null || !info.SetMethod.IsPublic || info.GetMethod == null) { continue; } if (info.Name != "LastUpdate") { var updated = !(info.GetValue(old_dev).Equals(info.GetValue(new_dev))); update_field |= updated; } info.SetValue(old_dev, info.GetValue(new_dev)); } if (silence_io) { old_dev.resetIO(inp, outp); } return(update_field); }
public static bool DeviceInput(IDeviceInput input) { // Mouse move is handled here to reduce performance impact due to its high frequency if (input.Key == Key.MouseMove) { if (input.Injected) { return(false); } MoveEvent?.Invoke(); LastMouseAction = Time.Now; return(IsLocked || IsMouseLocked || IsMouseMoveLocked); } if (input.Key.IsUnknown()) { return(false); } var key = !StatelessNumpad || !input.Key.IsNumpad() ? input.Key : MapNumpad(input.Key); // Deal with injected input if (input.Injected && (!key.IsMedia() || (uint)input.ExtraInfo == pid)) { if (!key.IsStateless()) { if (input.State) { DownKeysVirtual.Add(key); } else { DownKeysVirtual.Remove(key); } } return(false); } // Record key state if it has changed (ignore auto-repeat presses) if (input.State != IsDown(key)) { if (!key.IsStateless()) { SetState(key, input.State); } History.Push(new KeyState(key, input.State)); GlobalIDs[key] = ++CurrentGlobalID; } // Invoke special key event subscriptions InputEvent?.Invoke(key, input.State); // Check lock state bool locked = IsLocked || IsAllKeysLocked || (key.IsMouse() ? IsMouseLocked : IsKeyboardLocked) || IsLockedKey(key); bool blocked; // Update idle info if (key.IsMouse()) { LastMouseAction = Time.Now; } else { LastKeyboardAction = Time.Now; } // If hotkey is running tell it that the key has been released if (!input.State && HotkeyManager.CurrentHotkeys.ContainsKey(key)) { blocked = HotkeyManager.KeyUp(key); } // Block key if locked else if (locked) { return(true); } // Hotkey for that key is already running else if (HotkeyManager.CurrentHotkeys.ContainsKey(key)) { blocked = HotkeyManager.IsBlocked(key); } // Pass key event to hotkey manager else if (input.State) { blocked = HotkeyManager.KeyDown(key); } else { blocked = HotkeyManager.KeyUp(key); } if (!blocked) { SetStateVirtual(key, input.State); } return(blocked); }
public CeilingFan(IDeviceInput inp, IDeviceOutput outp) : base(inp, outp) { Enabled = false; State = 0; }
public AlarmSystem(IDeviceInput inp, IDeviceOutput outp, TimeFrame frame) : base(inp, outp, frame) { Enabled = false; Class = "AlarmSystem"; }
public AlarmSystem(IDeviceInput inp, IDeviceOutput outp) : base(inp, outp) { Enabled = false; }
public LightSwitch(IDeviceInput inp, IDeviceOutput outp) : base(inp, outp) { _enabled = false; _light = new Light(); }
/// <summary> /// Unregisters an eventhandler on the device to stop beeing notified about input. /// </summary> /// <param name="cueDevice">The <see cref="ICueDevice"/> the eventhandler should be unregistered from.</param> /// <param name="eventHandler">The eventhandler to unregister.</param> public static void UnregisterOnInput(this ICueDevice cueDevice, EventHandler <OnInputEventArgs> eventHandler) { IDeviceInput deviceInput = GetOrCreateDeviceInput(cueDevice); deviceInput.UnregisterEventHandler(eventHandler); }
public GarageDoor(IDeviceInput inp, IDeviceOutput outp) : base(inp, outp) { Enabled = true; }
public Device(IDeviceInput inp, IDeviceOutput outp) { _in = inp; _out = outp; LastUpdate = DateTime.Now.ToUniversalTime(); }
public GarageDoor(IDeviceInput inp, IDeviceOutput outp, TimeFrame frame) : base(inp, outp, frame) { Enabled = true; Class = "GarageDoor"; }
public PlayerFactory(UnityPlayerData playerData, IDeviceInput deviceInput) { this.playerData = playerData; this.deviceInput = deviceInput; }
public void DeviceFormClosed(IDeviceInput device) { _devices.Remove(device); }
/** * Internal device updating function. * \param[in] dev Device to be updated * \param[in] json JSON blob of fields to update * \param[in] silence_io Temporarily disable the Device IO for simple value updating * \param[in] update_id Flag indicating if the DeviceID should be updated at all * \param[in] force Flag indicating if public/private flags should be respected for the update * \param[out] Flag indicating if at least one field was updated */ protected static bool update(Device dev, string json, bool silence_io = false, bool update_id = false, bool force = false) { if (dev == null) { return(false); } IDeviceInput inp = null; IDeviceOutput outp = null; if (silence_io) { inp = dev.Input; outp = dev.Output; dev.resetIO(); } bool updated_value = true; try { var props = dev.GetType().GetRuntimeProperties(); var json_obj = JObject.Parse(json); foreach (var info in props) { if (info.SetMethod == null || !(force || info.SetMethod.IsPublic) || info.Name == "Frame") { continue; } JToken field; if (!json_obj.TryGetValue(info.Name, StringComparison.OrdinalIgnoreCase, out field)) { continue; } if (update_id && info.Name == "ID") { if (field.Type == JTokenType.Integer) { dev.ID.DeviceID = field.ToObject <UInt64>(); } else { dev.ID = field.ToObject <FullID>(); } } else if (info.Name != "ID") { var value = field.ToObject(info.PropertyType); info.SetValue(dev, value); } updated_value = true; } } catch (JsonException ex) { //TODO: Report error somehow? Debug.WriteLine("Error updating the device" + ex.Message); Debug.WriteLine("Error updating the device" + ex.InnerException.Message); } if (silence_io) { dev.resetIO(inp, outp); } return(updated_value); }