private void refreshAvailablePoKeysList() { AvailablePoKeysList.Clear(); List <PoKeysDeviceInfo> devices = PoKeysDevice.EnumeratePoKeysDevices(true, true, true); foreach (PoKeysDeviceInfo device in devices) { if (PoKeysDevice.ConnectToDevice(device)) { int pokeysSerial = PoKeysDevice.GetDeviceSerialNumber(); string pokeysName = PoKeysDevice.GetDeviceName(); byte pokeysUserId = 0; bool pokeysUserIdOk = false; if (PoKeysDevice.GetUserID(ref pokeysUserId)) { pokeysUserIdOk = true; } AvailablePoKeys availablePoKeys = new AvailablePoKeys(pokeysSerial, pokeysName, pokeysUserIdOk ? pokeysUserId : (byte?)null, device); AvailablePoKeysList.Add(availablePoKeys); PoKeysDevice.DisconnectDevice(); } } }
private void RefreshAvailablePoKeysList() { AvailablePoKeysList.Clear(); int nbPokeys = PoKeysDevice.EnumerateDevices(); for (int pokeysIndex = 0; pokeysIndex < nbPokeys; pokeysIndex++) { if (PoKeysDevice.ConnectToDevice(pokeysIndex)) { int pokeysSerial = 0; int firmwareMajor = 0; int firmwareMinor = 0; PoKeysDevice.GetDeviceIDEx(ref pokeysSerial, ref firmwareMajor, ref firmwareMinor); string pokeysName = PoKeysDevice.GetDeviceName(); byte pokeysUserId = 0; bool pokeysUserIdOk = PoKeysDevice.GetUserID(ref pokeysUserId); AvailablePoKeys availablePoKeys = new AvailablePoKeys(pokeysSerial, pokeysName, pokeysUserIdOk ? pokeysUserId : (byte?)null, pokeysIndex); AvailablePoKeysList.Add(availablePoKeys); PoKeysDevice.DisconnectDevice(); } } }
private void refreshAvailablePoKeysList() { AvailablePoKeysList.Clear(); int nbPokeys = PoKeysDevice.EnumerateDevices(); for (int pokeysIndex = 0; pokeysIndex < nbPokeys; ++pokeysIndex) { if (PoKeysDevice.ConnectToDevice(pokeysIndex)) { int pokeysSerial = PoKeysDevice.GetDeviceSerialNumber(); string pokeysName = PoKeysDevice.GetDeviceName(); byte pokeysUserId = 0; bool pokeysUserIdOk = false; if (PoKeysDevice.GetUserID(ref pokeysUserId)) { pokeysUserIdOk = true; } AvailablePoKeys availablePoKeys = new AvailablePoKeys(pokeysSerial, pokeysName, pokeysUserIdOk ? pokeysUserId : (byte?)null, pokeysIndex); AvailablePoKeysList.Add(availablePoKeys); PoKeysDevice.DisconnectDevice(); } } }
public void UpdateStatus() { if (owner == null) { return; } if (!PinId.HasValue) { Error = null; } else if (!owner.PoKeysIndex.HasValue) { Error = null; } else { PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { byte pinFunction = 0; if (!poKeysDevice.GetPinData((byte)(PinId.Value - 1), ref pinFunction)) { Error = Translations.Main.DigitalOutputErrorGetIOType; } else { if ((pinFunction & 0x4) == 0) { Error = Translations.Main.DigitalOutputErrorBadIOType; } else { Error = null; } } poKeysDevice.DisconnectDevice(); } } WriteOutputState(); }
private void WriteOutputState() { if (string.IsNullOrEmpty(Error) && owner != null && owner.PoKeysIndex.HasValue && MatrixLedConfig != null) { PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { foreach (SevenSegmentDigit digit in SevenSegmentDigits) { for (int segmentPosition = 0; segmentPosition < 8; ++segmentPosition) { SevenSegmentDigitSegment segment = digit.Segments[segmentPosition]; if (segment.Dirty) { bool setPixelOk; if (matrixLedConfig.DigitOnRow) { setPixelOk = MatrixLed.SetPixel((byte)(digit.Index - 1), (byte)(MatrixLedConfig.SegmentIndexes[segmentPosition] - 1), segment.Value); } else { setPixelOk = MatrixLed.SetPixel((byte)(MatrixLedConfig.SegmentIndexes[segmentPosition] - 1), (byte)(digit.Index - 1), segment.Value); } if (!setPixelOk) { Error = Translations.Main.MatrixLedErrorWrite; } segment.Dirty = false; } } } poKeysDevice.DisconnectDevice(); } } }
internal void UpdateStatus() { if (owner == null) { return; } if (MatrixLedConfig == null) { Error = null; } else if (!owner.PoKeysIndex.HasValue) { Error = null; } else { PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { if (!MatrixLed.IsEnabled()) { Error = Translations.Main.MatrixLedErrorNotEnabled; } else { Error = null; } poKeysDevice.DisconnectDevice(); } } SetOutputStateDirty(); WriteOutputState(); }
protected override void WriteOutputState() { if (string.IsNullOrEmpty(Error) && owner != null && owner.PoKeysIndex.HasValue && MatrixLed != null && Row.HasValue && Column.HasValue) { PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { if (!MatrixLed.SetPixel((byte)(Row.Value - 1), (byte)(Column.Value - 1), OutputState)) { Error = Translations.Main.MatrixLedErrorWrite; } poKeysDevice.DisconnectDevice(); } } }
protected override void WriteOutputState() { if (string.IsNullOrEmpty(Error) && owner != null && owner.PoKeysIndex.HasValue && PinId.HasValue) { PoKeysDevice pokeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!pokeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { if (!pokeysDevice.SetOutput((byte)(PinId.Value - 1), OutputState)) { Error = Translations.Main.DigitalOutputErrorWrite; } pokeysDevice.DisconnectDevice(); } } }
internal void UpdateStatus() { if (owner == null) { return; } if (MatrixLed == null || !Row.HasValue || !Column.HasValue) { Error = null; } else if (!owner.PoKeysIndex.HasValue) { Error = null; } else { PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice; if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value)) { Error = Translations.Main.PoKeysConnectError; } else { if (!MatrixLed.IsPixelEnabled((byte)(Row.Value - 1), (byte)(Column.Value - 1))) { Error = string.Format(Translations.Main.MatrixLedPixelErrorNotEnabled, Row, Column); } else { Error = null; } poKeysDevice.DisconnectDevice(); } } WriteOutputState(); }
private void StepperPositioningThreadStub() { if ((poKeysDevice == null) || (PE == null)) { return; } while (StepperRunning) { // New Pulse engine state was commanded if (NewStateCommanded) { PE.PulseEngineStateSetup = NewState; poKeysDevice.PEv2_SetState(ref PE); NewStateCommanded = false; } poKeysDevice.PEv2_GetStatus(ref PE); if (PE.PulseEngineState > 100) // Error or limit { if (!ErrorFixed) { ErrorFixed = true; Error = Translations.Main.StepperPositioningError; } // Do nothing else... Thread.Sleep(10); continue; } ErrorFixed = true; // Position update was commanded if (SetPosition) { for (int i = 0; i < 8; i++) { PE.PositionSetup[i] = SetAxisPos[i]; } PE.param2 = 0xFF; // Set all 8 positions poKeysDevice.PEv2_SetPositions(ref PE); SetPosition = false; } // Homing was commanded if (StartHoming) { IsHoming = true; raiseHomingStatusChanged(IsHoming); if (HomeStepper()) { IsHomed = true; } IsHoming = false; raiseHomingStatusChanged(IsHoming); StartHoming = false; } if (PE.PulseEngineState != (byte)ePoKeysPEState.peRUNNING) { NewState = (byte)ePoKeysPEState.peRUNNING; NewStateCommanded = true; } for (int i = 0; i < 8; i++) { // Check axes states and change them to position mode... if ((PE.AxesConfig[i] & (byte)ePEv2_AxisConfig.aoPOSITION_MODE) == 0) { PE.AxesConfig[i] |= (byte)(ePEv2_AxisConfig.aoPOSITION_MODE); PE.param1 = (byte)i; poKeysDevice.PEv2_SetAxisConfiguration(ref PE); } } if (CheckNewState) { switch (State) { case PoKeysStepperPositioningState.STOPPED: // Stop the motion... for (int i = 0; i < 8; i++) { PE.ReferencePositionSpeed[i] = PE.CurrentPosition[i]; } break; case PoKeysStepperPositioningState.MOVE_TO_POS: for (int i = 0; i < 8; i++) { PE.ReferencePositionSpeed[i] = TargetAxisPos[i]; } break; } poKeysDevice.PEv2_Move(ref PE); CheckNewState = false; } else { // Check existing state switch (State) { case PoKeysStepperPositioningState.STOPPED: break; case PoKeysStepperPositioningState.MOVE_TO_POS: // Check if move is complete if (IsMoveComplete(5)) { State = StateAfterMove; if (State == PoKeysStepperPositioningState.STOPPED) { // Well... do nothing... } else { CheckNewState = true; } } break; } } if (CommandMotion) { poKeysDevice.PEv2_Move(ref PE); CommandMotion = false; } Thread.Sleep(10); } PE.PulseEngineStateSetup = (byte)ePoKeysPEState.peSTOPPED; poKeysDevice.PEv2_SetState(ref PE); poKeysDevice.DisconnectDevice(); }