示例#1
0
文件: Program.cs 项目: ttgzs/IEC104-1
        private static bool asduHandler(object parameter, IMasterConnection connection, ASDU asdu)
        {
            if (asdu.TypeId == TypeID.C_SC_NA_1)
            {
                Console.WriteLine("Single command");

                SingleCommand sc = (SingleCommand)asdu.GetElement(0);

                Console.WriteLine(sc.ToString());
            }
            else if (asdu.TypeId == TypeID.M_EI_NA_1)
            {
                Console.WriteLine("End of initialization received");
            }
            else if (asdu.TypeId == TypeID.F_DR_TA_1)
            {
                Console.WriteLine("Received file directory");
            }
            else if (asdu.TypeId == TypeID.C_CS_NA_1)
            {
                ClockSynchronizationCommand qsc = (ClockSynchronizationCommand)asdu.GetElement(0);

                Console.WriteLine("Received clock sync command with time " + qsc.NewTime.ToString());
            }

            return(true);
        }
示例#2
0
        private static bool asduHandler(object parameter, IMasterConnection connection, ASDU asdu)
        {
            if (asdu.TypeId == TypeID.C_SC_NA_1)
            {
                Console.WriteLine("Single command");

                SingleCommand sc = (SingleCommand)asdu.GetElement(0);

                if (sc.Select)
                {
                    Console.WriteLine("  received select");
                }
                else
                {
                    Console.WriteLine("  received execute");
                }

                Console.WriteLine(sc.ToString());

                connection.SendACT_CON(asdu, false);
            }
            else if (asdu.TypeId == TypeID.C_CS_NA_1)
            {
                ClockSynchronizationCommand qsc = (ClockSynchronizationCommand)asdu.GetElement(0);

                Console.WriteLine("Received clock sync command with time " + qsc.NewTime.ToString());

                connection.SendACT_CON(asdu, false);
            }

            return(true);
        }
示例#3
0
        private static bool asduHandler(object parameter, IMasterConnection connection, ASDU asdu)
        {
            if (asdu.TypeId == TypeID.C_SC_NA_1)
            {
                Console.WriteLine("Single command");

                SingleCommand sc = (SingleCommand)asdu.GetElement(0);

                Console.WriteLine(sc.ToString());
            }
            else if (asdu.TypeId == TypeID.C_CS_NA_1)
            {
                ClockSynchronizationCommand qsc = (ClockSynchronizationCommand)asdu.GetElement(0);

                Console.WriteLine("Received clock sync command with time " + qsc.NewTime.ToString());
            }

            if (asdu.TypeId == TypeID.M_ME_TF_1)
            {
                MeasuredValueShortWithCP56Time2a sc = (MeasuredValueShortWithCP56Time2a)asdu.GetElement(0);
                Console.WriteLine(sc.ToString());
            }
            if (asdu.TypeId == TypeID.M_ME_NC_1)
            {
                MeasuredValueShort sc = (MeasuredValueShort)asdu.GetElement(0);
                Console.WriteLine(sc.ToString());
            }
            return(true);
        }
示例#4
0
        private static bool asduHandler(object parameter, IMasterConnection connection, ASDU asdu)
        {
            if (asdu.TypeId == TypeID.C_SC_NA_1)
            {
                SingleCommand sc = (SingleCommand)asdu.GetElement(0);

                if (sc.ObjectAddress != 100)
                {
                    // Unkown IOA --> send negative confirmation
                    asdu.Cot        = CauseOfTransmission.UNKNOWN_INFORMATION_OBJECT_ADDRESS;
                    asdu.IsNegative = true;
                    connection.SendASDU(asdu);
                }
                else
                {
                    // execute command

                    // send positive confirmation
                    connection.SendACT_CON(asdu, false);
                }
            }

            if (asdu.TypeId == TypeID.C_SC_NA_1)
            {
                Console.WriteLine("Single command");

                SingleCommand sc = (SingleCommand)asdu.GetElement(0);

                Console.WriteLine(sc.ToString());
            }
            else if (asdu.TypeId == TypeID.M_EI_NA_1)
            {
                Console.WriteLine("End of initialization received");
            }
            else if (asdu.TypeId == TypeID.F_DR_TA_1)
            {
                Console.WriteLine("Received file directory");
            }
            else if (asdu.TypeId == TypeID.C_CS_NA_1)
            {
                ClockSynchronizationCommand qsc = (ClockSynchronizationCommand)asdu.GetElement(0);

                Console.WriteLine("Received clock sync command with time " + qsc.NewTime.ToString());
            }

            return(true);
        }