Esempio n. 1
0
 public Connection(string hostname, int tcpPort, ConnectionParameters parameters)
 {
     Setup(hostname, parameters.clone(), tcpPort);
 }
Esempio n. 2
0
        internal override void Encode(Frame frame, ConnectionParameters parameters, bool isSequence)
        {
            base.Encode(frame, parameters, isSequence);

            frame.SetNextByte(qpa);
        }
Esempio n. 3
0
 public ASDU(ConnectionParameters parameters, CauseOfTransmission cot, bool isTest, bool isNegative, byte oa, int ca, bool isSequence)
     : this(parameters, TypeID.M_SP_NA_1, cot, isTest, isNegative, oa, ca, isSequence)
 {
     this.hasTypeId = false;
 }
Esempio n. 4
0
 public Connection(string hostname, ConnectionParameters parameters)
 {
     Setup(hostname, parameters.clone(), 2404);
 }
Esempio n. 5
0
        internal override void Encode(Frame frame, ConnectionParameters parameters, bool isSequence)
        {
            base.Encode(frame, parameters, isSequence);

            frame.AppendBytes(timestamp.GetEncodedValue());
        }
Esempio n. 6
0
 internal StepCommand(ConnectionParameters parameters, byte[] msg, int startIndex) :
     base(parameters, msg, startIndex)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Create a new server using the provided connection parameters.
 /// 使用给定参数创建一个server
 /// </summary>
 /// <param name="parameters">Connection parameters</param>
 public Server(ConnectionParameters parameters)
 {
     this.parameters = parameters;
 }
Esempio n. 8
0
 /// <summary>
 /// Create a new server using default connection parameters
 /// 使用默认参数创建一个server
 /// </summary>
 public Server()
 {
     this.parameters = new ConnectionParameters();
 }
Esempio n. 9
0
        /// <summary>
        /// 将ASDU内容编码入frame中。。
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="parameters"></param>
        public void Encode(Frame frame, ConnectionParameters parameters)
        {
            //先编码类型标识
            frame.SetNextByte((byte)typeId);
            //然后就是可变结构限定词
            frame.SetNextByte(vsq);

            #region  送原因
            byte cotByte = (byte)cot;

            //测试标志
            if (isTest)
            {
                cotByte = (byte)(cotByte | 0x80);
            }
            //确认标志
            if (isNegative)
            {
                cotByte = (byte)(cotByte | 0x40);
            }

            frame.SetNextByte(cotByte);

            //如果2字节传送原因的话,多编码一个“源发地址”进去
            if (parameters.SizeOfCOT == 2)
            {
                frame.SetNextByte((byte)oa);
            }
            #endregion

            #region ASDU公共地址
            frame.SetNextByte((byte)(ca % 256));

            if (parameters.SizeOfCA > 1)
            {
                frame.SetNextByte((byte)(ca / 256));
            }
            #endregion

            //接下来编码内容
            if (payload != null)
            {
                frame.AppendBytes(payload);
            }
            else
            {
                bool isFirst = true;

                foreach (InformationObject io in informationObjects)
                {
                    if (isFirst)
                    {
                        //第一条,必须编码地址进去
                        io.Encode(frame, parameters, false);
                        isFirst = false;
                    }
                    else
                    {
                        //后面的,根据是否为连续,决定是否编码地址
                        if (IsSquence)
                        {
                            io.Encode(frame, parameters, true);
                        }
                        else
                        {
                            io.Encode(frame, parameters, false);
                        }
                    }
                }
            }
        }