コード例 #1
0
        private async void sendCurrentStatus()
        {
            /*
             *
             *  Byte1
             *  0 - I0.0 butonul care stinge toate pompele
             *  1 - I0.7 senzor mijloc
             *  2 - Q0.0 prima pompa
             *  3 - Q0.1 pompa 2
             *  4 - Q0.2 pompa 3
             *  5 - Q0.3 pompa 4
             *  6 - I0.6 senzor alarma
             *  7 - 0
             *
             *
             *  Byte 2
             *  0 - Q0.5 alarma
             *  1 - I0.1 p1
             *  2 - I0.2 p2
             *  3 - I0.3 p3
             *  4 - I0.4 p4
             *  5 - I8.0 sus
             *  6 - I8.1 jos
             *  7 - 1
             */
            byte byte1 = 0, byte2 = 0;

            byte1 = BitHelper.AddBit(byte1, 0, stingeToateButton.Checked);
            byte1 = BitHelper.AddBit(byte1, 1, sensorPictureBoxes[1].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 2, pumpPictureBoxes[0].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 3, pumpPictureBoxes[1].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 4, pumpPictureBoxes[2].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 5, pumpPictureBoxes[3].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 6, sensorPictureBoxes[2].BackColor == Color.Red);
            byte1 = BitHelper.AddBit(byte1, 7, false);

            byte2 = BitHelper.AddBit(byte2, 0, alarmPicture.Visible);
            byte2 = BitHelper.AddBit(byte2, 1, p1Button.Checked);
            byte2 = BitHelper.AddBit(byte2, 2, p2Button.Checked);
            byte2 = BitHelper.AddBit(byte2, 3, p3Button.Checked);
            byte2 = BitHelper.AddBit(byte2, 4, p4Button.Checked);
            byte2 = BitHelper.AddBit(byte2, 5, sensorPictureBoxes[3].BackColor == Color.Red);
            byte2 = BitHelper.AddBit(byte2, 6, sensorPictureBoxes[0].BackColor == Color.Red);
            byte2 = BitHelper.AddBit(byte2, 7, true);
            await Client.sendByte(byte1);

            await Client.sendByte(byte2);
        }