コード例 #1
0
        public override byte[] PackRequest()
        {
            byte[] request = new byte[20];

            DNP3ReadCommandParameters commadnParam = (DNP3ReadCommandParameters)CommandParameters;

            CommandParameters.Length = 0x0d; //20 - 2*(2 CRC) - 2 Start - 1 len
            Buffer.BlockCopy(headerBuilder.Build(CommandParameters), 0, request, 0, 10);
            request[10] = commadnParam.TransportControl;
            request[11] = commadnParam.AplicationControl;
            request[12] = commadnParam.FunctionCode;
            Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)commadnParam.ObjectTypeField)), 0, request, 13, 2);
            request[15] = commadnParam.Qualifier;
            request[16] = (byte)commadnParam.RangeField;
            request[17] = (byte)commadnParam.RangeField;
            ushort crc = 0;

            for (int i = 10; i < 18; i++)
            {
                CrcCalculator.computeCRC(request[i], ref crc);
            }
            crc = (ushort)(~crc);
            Buffer.BlockCopy(BitConverter.GetBytes(crc), 0, request, 18, 2);

            return(request);
        }
コード例 #2
0
        public void ExecuteReadCommand(RegisterType type, uint index)
        {
            log.Log(new SCADA.Common.Logging.LogEventModel()
            {
                EventType = SCADA.Common.Logging.LogEventType.INFO, Message = $"ReadCommand ({type},{index})"
            });
            DNP3ReadCommandParameters dnp3CommandParam = new DNP3ReadCommandParameters(GetApplicationSequence(), (byte)DNP3FunctionCode.READ, GetTypeField(type),
                                                                                       (byte)Qualifier.PREFIX_2_OCTET_COUNT_OF_OBJECTS_2_OCTET, index, GetTransportSequence());
            IDNP3Function dnp3Fn = DNP3FunctionFactory.CreateReadFunction(dnp3CommandParam);

            this.functionExecutor.EnqueueCommand(dnp3Fn);
        }
コード例 #3
0
 public static IDNP3Function CreateReadFunction(DNP3ReadCommandParameters parameters)
 {
     return(new Read(parameters));
 }