Exemple #1
0
        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();
                }
            }
        }
Exemple #2
0
        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();
                }
            }
        }
Exemple #3
0
        public bool Initialize(PoKeysStepperBoardConfiguration config, int?pokeysIndex)
        {
            if (Initialized)
            {
                return(false);
            }

            if (poKeysDevice == null)
            {
                if (!pokeysIndex.HasValue)
                {
                    return(false);
                }

                poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(pokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                    return(false);
                }
            }

            // Configure the positioning device...
            poKeysDevice.PEv2_GetStatus(ref PE);
            for (int i = 0; i < 8; i++)
            {
                PE.param1 = (byte)i;
                poKeysDevice.PEv2_GetAxisConfiguration(ref PE);
            }

            UpdateConfiguration(config);

            //
            // Change Pulse Engine State to RUNNING
            //
            PE.PulseEngineStateSetup = (byte)ePoKeysPEState.peRUNNING;
            poKeysDevice.PEv2_SetState(ref PE);

            //
            // Get Pulse Engine Statue and Check to confirm we are RUNNING
            //
            poKeysDevice.PEv2_GetStatus(ref PE);
            StepperRunning = (PE.PulseEngineState == (byte)ePoKeysPEState.peRUNNING);

            Initialized = true;

            if (posThread == null)
            {
                posThread = new Thread(new ThreadStart(StepperPositioningThreadStub));
                posThread.Start();
            }

            return(true);
        }
Exemple #4
0
        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();
        }
Exemple #7
0
        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();
                }
            }
        }
Exemple #8
0
        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();
                }
            }
        }
Exemple #9
0
        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();
        }