Exemple #1
0
        void m_Connection_Error(object sender, ConnectionErrorEventArgs e)
        {
            var args = new ClientInterfaceResponseStringEventArgs();

            args.Text = e.ErrorMessage;

            OnResponseLog(args);
        }
Exemple #2
0
        protected virtual void OnResponseTracker(ClientInterfaceResponseStringEventArgs e)
        {
            var handler = ResponseTracker;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemple #3
0
        private void ParseMessage(byte[] Message)
        {
            //Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): Found Message");
            //Log.HexDump(Log.LogLevelType.Debug, Message);

            ClientInterfaceResponseStringEventArgs ArgsS;
            ClientInterfaceResponseBitsEventArgs   ArgsB;

            if (Message == null)
            {
                return;
            }

            if (Message.Count() == 0)
            {
                return;
            }

            String s = System.Text.Encoding.UTF8.GetString(Message, 0, COMMAND_LENGTH);
            int    Command;

            byte[] BitBlock1, BitBlock2, BitBlock;

            if (int.TryParse(s, out Command) == false)
            {
                return;
            }

            switch (Command)
            {
            case 4:     //outputs
                ArgsB     = new ClientInterfaceResponseBitsEventArgs();
                BitBlock1 = new byte[2];
                BitBlock2 = new byte[2];
                BitBlock  = new byte[4];

                Array.Copy(Message, COMMAND_LENGTH, BitBlock1, 0, 2);
                Array.Reverse(BitBlock1);

                Array.Copy(Message, COMMAND_LENGTH + 2, BitBlock2, 0, 2);
                Array.Reverse(BitBlock2);

                Array.Copy(BitBlock1, 0, BitBlock, 0, 2);
                Array.Copy(BitBlock2, 0, BitBlock, 2, 2);

                ArgsB.Bits = new BitArray(BitBlock);

                //Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): OUTPUTS: ");
                // Log.HexDump(Log.LogLevelType.Debug, BitBlock);

                OnResponseOutputs(ArgsB);
                break;

            case 5:     //inputs
                ArgsB     = new ClientInterfaceResponseBitsEventArgs();
                BitBlock1 = new byte[2];
                BitBlock2 = new byte[2];
                BitBlock  = new byte[4];

                Array.Copy(Message, COMMAND_LENGTH, BitBlock1, 0, 2);
                Array.Reverse(BitBlock1);

                Array.Copy(Message, COMMAND_LENGTH + 2, BitBlock2, 0, 2);
                Array.Reverse(BitBlock2);

                Array.Copy(BitBlock1, 0, BitBlock, 0, 2);
                Array.Copy(BitBlock2, 0, BitBlock, 2, 2);

                ArgsB.Bits = new BitArray(BitBlock);

                // Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): INPUTS: ");
                // Log.HexDump(Log.LogLevelType.Debug, BitBlock);

                OnResponseInputs(ArgsB);
                break;

            case 6:     //alarms
                ArgsB     = new ClientInterfaceResponseBitsEventArgs();
                BitBlock1 = new byte[2];
                BitBlock2 = new byte[2];
                BitBlock  = new byte[4];

                Array.Copy(Message, COMMAND_LENGTH, BitBlock1, 0, 2);
                Array.Reverse(BitBlock1);

                Array.Copy(Message, COMMAND_LENGTH + 2, BitBlock2, 0, 2);
                Array.Reverse(BitBlock2);

                Array.Copy(BitBlock1, 0, BitBlock, 0, 2);
                Array.Copy(BitBlock2, 0, BitBlock, 2, 2);

                ArgsB.Bits = new BitArray(BitBlock);

                //Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): ALARMS: ");
                //Log.HexDump(Log.LogLevelType.Debug, BitBlock);

                OnResponseAlarms(ArgsB);
                break;

            case 7:     //log messages
                ArgsS      = new ClientInterfaceResponseStringEventArgs();
                ArgsS.Text = System.Text.Encoding.UTF8.GetString(Message, COMMAND_LENGTH, Message.Length - COMMAND_LENGTH);

                // Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): LOG: " + ArgsS.Text);
                OnResponseLog(ArgsS);
                break;

            case 8:     //tracker
                ArgsS      = new ClientInterfaceResponseStringEventArgs();
                ArgsS.Text = System.Text.Encoding.UTF8.GetString(Message, COMMAND_LENGTH, Message.Length - COMMAND_LENGTH);

                //Log.WriteLog(Log.LogLevelType.Debug, "ClientInterface::ParseMessage(): TRACKER: " + ArgsS.Text);
                OnResponseTracker(ArgsS);
                break;
            }
        }