Esempio n. 1
0
        public bool ParseByteData(byte[] Data)
        {
            bool Result = false;

            if (Data[0] == HeaderLo & Data[1] == HeaderHi & Data.Length >= cByteCount && mf.Tls.GoodCRC(Data))
            {
                SW[0] = mf.Tls.BitRead(Data[2], 0);     // auto on
                SW[1] = mf.Tls.BitRead(Data[2], 1);     // master on
                SW[2] = mf.Tls.BitRead(Data[2], 2);     // master off
                SW[3] = mf.Tls.BitRead(Data[2], 3);     // rate up
                SW[4] = mf.Tls.BitRead(Data[2], 4);     // rate down

                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        SW[5 + j + i * 8] = mf.Tls.BitRead(Data[i + 3], j);
                    }
                }

                ReceiveTime = DateTime.Now;
                Result      = true;
            }
            if (Result)
            {
                SwitchPGNargs args = new SwitchPGNargs();
                args.Switches = SW;
                SwitchPGNreceived?.Invoke(this, args);
            }
            return(Result);
        }
Esempio n. 2
0
        public void ParseByteData(byte[] Data)
        {
            bool Result = false;

            if (Data[0] == HeaderHi & Data[1] == HeaderLo & Data.Length >= cByteCount)
            {
                SW[0] = mf.Tls.BitRead(Data[3], 0);     // auto on
                SW[1] = mf.Tls.BitRead(Data[3], 1);     // master on
                SW[2] = mf.Tls.BitRead(Data[3], 2);     // master off
                SW[3] = mf.Tls.BitRead(Data[3], 3);     // rate up
                SW[4] = mf.Tls.BitRead(Data[3], 4);     // rate down
                SW[5] = mf.Tls.BitRead(Data[2], 0);     // s0
                SW[6] = mf.Tls.BitRead(Data[2], 1);     // s1
                SW[7] = mf.Tls.BitRead(Data[2], 2);     // s2
                SW[8] = mf.Tls.BitRead(Data[2], 3);     // s3

                ReceiveTime = DateTime.Now;
                Result      = true;
            }
            if (Result)
            {
                SwitchPGNargs args = new SwitchPGNargs();
                args.Switches = SW;
                SwitchPGNreceived?.Invoke(this, args);
            }
        }
Esempio n. 3
0
        public void PressSwitch(SwIDs ID)
        {
            ReceiveTime = DateTime.Now;

            switch (ID)
            {
            case SwIDs.MasterOn:
                SW[1] = true;
                SW[2] = false;
                break;

            case SwIDs.MasterOff:
                SW[1] = false;
                SW[2] = true;
                break;

            case SwIDs.RateUp:
                SW[3] = true;
                SW[4] = false;
                break;

            case SwIDs.RateDown:
                SW[3] = false;
                SW[4] = true;
                break;

            default:
                SW[(int)ID] = !SW[(int)ID];
                break;
            }
            SwitchPGNargs args = new SwitchPGNargs();

            args.Switches = SW;
            SwitchPGNreceived?.Invoke(this, args);
        }
Esempio n. 4
0
        public bool ParseStringData(string[] Data)
        {
            bool Result = false;

            if (Data.Length >= cByteCount)
            {
                int.TryParse(Data[0], out Tmp);
                if (Tmp == HeaderHi)
                {
                    int.TryParse(Data[1], out Tmp);
                    if (Tmp == HeaderLo)
                    {
                        byte.TryParse(Data[2], out DataLo);
                        byte.TryParse(Data[3], out DataHi);

                        SW[0] = mf.Tls.BitRead(DataHi, 0);     // auto on
                        SW[1] = mf.Tls.BitRead(DataHi, 1);     // master on
                        SW[2] = mf.Tls.BitRead(DataHi, 2);     // master off
                        SW[3] = mf.Tls.BitRead(DataHi, 3);     // rate up
                        SW[4] = mf.Tls.BitRead(DataHi, 4);     // rate down
                        SW[5] = mf.Tls.BitRead(DataLo, 0);     // s0
                        SW[6] = mf.Tls.BitRead(DataLo, 1);     // s1
                        SW[7] = mf.Tls.BitRead(DataLo, 2);     // s2
                        SW[8] = mf.Tls.BitRead(DataLo, 3);     // s3

                        ReceiveTime = DateTime.Now;
                        Result      = true;
                    }
                }
            }
            if (Result)
            {
                SwitchPGNargs args = new SwitchPGNargs();
                args.Switches = SW;
                SwitchPGNreceived?.Invoke(this, args);
            }
            return(Result);
        }