Esempio n. 1
0
        private void SetInputStates(object args, EventArgs e)
        {
            simINDevice device = (simINDevice)((object[])args)[0];
            int         index  = (int)((object[])args)[1];
            int         states = (int)(byte)((object[])args)[2];

            for (int i = 0; i < inputsGrid.Rows.Count; i++)
            {
                Key key = (Key)inputsGrid.Rows[i].Tag;
                if (key.KeysDevice == device)
                {
                    bool oldState = key.State;
                    if (oldState != key.CheckState(index, states))
                    {
                        if (key.State)
                        {
                            inputsGrid.Rows[i].Cells[2].Style.BackColor = Color.GreenYellow;
                        }
                        else
                        {
                            inputsGrid.Rows[i].Cells[2].Style.BackColor = inputsGrid.Columns[2].DefaultCellStyle.BackColor;
                        }
                        inputsGrid.Rows[i].Cells[2].Value = key.State.ToString();
                        inputsGrid.Refresh();
                    }
                }
            }
        }
Esempio n. 2
0
        private void sim_ReceivedReportEvent(simINDevice device, byte reportType, byte dataLength, byte[] data)
        {
            if (Working)
            {
                switch (reportType)
                {
                case 1:                         // GET_KEYS
                    if (dataLength == 2)
                    {
                        int index = data[0] * 8;
                        BeginInvoke(new EventHandler(SetInputStates), new object [] { device, index, data[1] }, EventArgs.Empty);
                    }
                    else
                    {
                        throw new Exception("Nieprawidłowa ilość danych w pakiecie typu GET_KEYS.");
                    }
                    break;

                case 2:                         // GET_KEYS2
                    if (dataLength == 3)
                    {
                        int index = data[1] * 8;
                        BeginInvoke(new EventHandler(SetInputStates), new object [] { device, index, data[2] }, EventArgs.Empty);
                    }
                    else
                    {
                        throw new Exception("Nieprawidłowa ilość danych w pakiecie typu GET_KEYS2.");
                    }
                    break;
                }
            }
        }
Esempio n. 3
0
 private void OnReceivedReport(simINDevice device, byte reportType, byte dataLength, byte [] data)
 {
     if (ReceivedReportEvent != null)
     {
         ReceivedReportEvent(device, reportType, dataLength, data);
     }
 }
Esempio n. 4
0
        void simin_ReceivedReportEvent(simINDevice device, byte reportType, byte dataLength, byte[] data)
        {
            switch (reportType)
            {
            case 1:                     // GET_KEYS
                if (dataLength == 2)
                {
                    int index = data[0] * 8;
                    if (_deviceKeys.ContainsKey(device))
                    {
                        List <Key> keys = _deviceKeys[device];
                        for (int i = 0; i < keys.Count; i++)
                        {
                            keys[i].CheckState(index, data[1]);
                        }
                    }
                    else
                    {
                        throw new Exception("Nieprawidłowa ilość danych w pakiecie typu GET_KEYS.");
                    }
                }
                break;

            case 2:                     // GET_KEYS2
                if (dataLength == 3)
                {
                    int index = data[1] * 8;
                    if (_deviceKeys.ContainsKey(device))
                    {
                        List <Key> keys = _deviceKeys[device];
                        for (int i = 0; i < keys.Count; i++)
                        {
                            keys[i].CheckState(index, data[2]);
                        }
                    }
                }
                else
                {
                    throw new Exception("Nieprawidłowa ilość danych w pakiecie typu GET_KEYS2.");
                }
                break;
            }
        }