示例#1
0
        public int GetPlcDateTime(DateTime DateTime)
        {
            int Length;

            LastError = 0;
            SendPacket(S7_GET_DT);
            if (LastError == 0)
            {
                Length = RecvIsoPacket();
                if (Length > 30) // the minimum expected
                {
                    if ((S7.GetWordAt(PDU, 27) == 0) && (PDU[29] == (byte)0xFF))
                    {
                        DateTime = S7.GetDateAt(PDU, 34);
                    }
                    else
                    {
                        LastError = errS7FunctionError;
                    }
                }
                else
                {
                    LastError = errS7InvalidPDU;
                }
            }

            return(LastError);
        }