Esempio n. 1
0
 public FileCallOrSelect(int objectAddress, NameOfFile nof, byte nameOfSection, SelectAndCallQualifier scq)
     : base(objectAddress)
 {
     this.nof           = nof;
     this.nameOfSection = nameOfSection;
     this.scq           = scq;
 }
Esempio n. 2
0
        internal FileLastSegmentOrSection(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            nameOfSection = msg[startIndex++];

            /* parse LSQ (last section or segment qualifier) */
            lsq = (LastSectionOrSegmentQualifier)msg[startIndex++];

            chs = msg[startIndex++];
        }
Esempio n. 3
0
        public FileDirectory(int objectAddress, NameOfFile nof, int lengthOfFile, int status, bool LFD, bool FOR, bool FA, CP56Time2a creationTime)
            : base(objectAddress)
        {
            this.nof          = nof;
            this.lengthOfFile = lengthOfFile;

            if (status < 0)
            {
                status = 0;
            }
            else if (status > 31)
            {
                status = 31;
            }

            byte sof = (byte)status;

            if (LFD)
            {
                sof += 0x20;
            }

            if (FOR)
            {
                sof += 0x40;
            }

            if (FA)
            {
                sof += 0x80;
            }

            this.sof          = sof;
            this.creationTime = creationTime;
        }
Esempio n. 4
0
        internal FileDirectory(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            lengthOfFile  = msg[startIndex++];
            lengthOfFile += (msg[startIndex++] * 0x100);
            lengthOfFile += (msg[startIndex++] * 0x10000);

            sof = msg[startIndex++];

            /* parse CP56Time2a (creation time of file) */
            creationTime = new CP56Time2a(msg, startIndex);
        }
Esempio n. 5
0
        internal SectionReady(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            nameOfSection = msg[startIndex++];

            lengthOfSection  = msg[startIndex++];
            lengthOfSection += (msg[startIndex++] * 0x100);
            lengthOfSection += (msg[startIndex++] * 0x10000);

            /* parse SRQ (section read qualifier) */
            srq = msg[startIndex++];
        }
Esempio n. 6
0
 public TransparentFile(int ca, int ioa, NameOfFile nof)
 {
     this.ca  = ca;
     this.ioa = ioa;
     this.nof = nof;
     time     = DateTime.Now;
 }
Esempio n. 7
0
        internal CS101n104File GetFile(int ca, int ioa, NameOfFile nof)
        {
            lock (availableFiles)
            {
                foreach (CS101n104File file in availableFiles)
                {
                    if ((file.provider.GetCA() == ca) && (file.provider.GetIOA() == ioa))
                    {
                        if (nof == NameOfFile.DEFAULT)
                        {
                            return(file);
                        }
                        else
                        {
                            if (nof == file.provider.GetNameOfFile())
                            {
                                return(file);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 8
0
 public FileSegment(int objectAddress, NameOfFile nof, byte nameOfSection, byte[] data)
     : base(objectAddress)
 {
     this.nof           = nof;
     this.nameOfSection = nameOfSection;
     this.data          = data;
     this.los           = (byte)data.Length;
 }
Esempio n. 9
0
 public FileLastSegmentOrSection(int objectAddress, NameOfFile nof, byte nameOfSection, LastSectionOrSegmentQualifier lsq, byte checksum)
     : base(objectAddress)
 {
     this.nof           = nof;
     this.nameOfSection = nameOfSection;
     this.lsq           = lsq;
     this.chs           = checksum;
 }
Esempio n. 10
0
 public FileACK(int objectAddress, NameOfFile nof, byte nameOfSection, AcknowledgeQualifier qualifier, FileError errorCode)
     : base(objectAddress)
 {
     this.nof           = nof;
     this.nameOfSection = nameOfSection;
     this.AckQualifier  = qualifier;
     this.ErrorCode     = errorCode;
 }
Esempio n. 11
0
 public FileDirectory(int objectAddress, NameOfFile nof, int lengthOfFile, byte sof, CP56Time2a creationTime)
     : base(objectAddress)
 {
     this.nof          = nof;
     this.lengthOfFile = lengthOfFile;
     this.sof          = sof;
     this.creationTime = creationTime;
 }
Esempio n. 12
0
        public override void SendFile(int ca, int ioa, NameOfFile nof, IFileProvider fileProvider)
        {
            if (fileClient == null)
            {
                fileClient = new FileClient(this, DebugLog);
            }

            fileClient.SendFile(ca, ioa, nof, fileProvider);
        }
Esempio n. 13
0
        public override void GetFile(int ca, int ioa, NameOfFile nof, IFileReceiver receiver)
        {
            if (fileClient == null)
            {
                fileClient = new FileClient(this, DebugLog);
            }

            fileClient.RequestFile(ca, ioa, nof, receiver);
        }
Esempio n. 14
0
        public void RequestFile(int ca, int ioa, NameOfFile nof, IFileReceiver fileReceiver)
        {
            this.ca           = ca;
            this.ioa          = ioa;
            this.nof          = nof;
            this.fileReceiver = fileReceiver;

            ASDU selectFile = NewAsdu(new FileCallOrSelect(ioa, nof, 0, SelectAndCallQualifier.SELECT_FILE));

            master.SendASDU(selectFile);

            state = FileClientState.WAITING_FOR_FILE_READY;
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="lib60870.CS101.FileReady"/> class.
        /// </summary>
        /// <param name="objectAddress">information object address (IOA)</param>
        /// <param name="nof">NOF (file type)</param>
        /// <param name="lengthOfFile">Length of file.</param>
        /// <param name="positive">If set to <c>true</c> positive ACK.</param>
        public FileReady(int objectAddress, NameOfFile nof, int lengthOfFile, bool positive)
            : base(objectAddress)
        {
            this.nof          = nof;
            this.lengthOfFile = lengthOfFile;

            if (positive)
            {
                frq = 0x00;
            }
            else
            {
                frq = 0x80;
            }
        }
Esempio n. 16
0
        public SectionReady(int objectAddress, NameOfFile nof, byte nameOfSection, int lengthOfSection, bool notReady)
            : base(objectAddress)
        {
            this.nof             = nof;
            this.nameOfSection   = nameOfSection;
            this.lengthOfSection = lengthOfSection;

            if (notReady)
            {
                srq = 0x80;
            }
            else
            {
                srq = 0;
            }
        }
Esempio n. 17
0
        internal FileSegment(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            nameOfSection = msg[startIndex++];

            los = msg[startIndex++];

            if (los > GetMaxDataSize(parameters))
            {
                throw new ASDUParsingException("Payload data too large");
            }

            if ((msg.Length - startIndex) < los)
            {
                throw new ASDUParsingException("Message too small");
            }

            data = new byte[los];

            for (int i = 0; i < los; i++)
            {
                data[i] = msg[startIndex++];
            }
        }
Esempio n. 18
0
        internal FileCallOrSelect(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            nameOfSection = msg[startIndex++];

            /* parse SCQ (select and call qualifier) */
            scq = (SelectAndCallQualifier)msg[startIndex++];
        }
Esempio n. 19
0
        internal FileACK(ApplicationLayerParameters parameters, byte[] msg, int startIndex, bool isSequence)
            : base(parameters, msg, startIndex, isSequence)
        {
            if (!isSequence)
            {
                startIndex += parameters.SizeOfIOA; /* skip IOA */
            }
            if ((msg.Length - startIndex) < GetEncodedSize())
            {
                throw new ASDUParsingException("Message too small");
            }

            int nofValue;

            nofValue  = msg[startIndex++];
            nofValue += (msg[startIndex++] * 0x100);

            nof = (NameOfFile)nofValue;

            nameOfSection = msg[startIndex++];

            /* parse AFQ (acknowledge file or section qualifier) */
            afq = msg[startIndex++];
        }
Esempio n. 20
0
 public SimpleFile(int ca, int ioa, NameOfFile nof)
     : base(ca, ioa, nof)
 {
 }
Esempio n. 21
0
 /// <summary>
 /// Sends the file to slave (download file)
 /// </summary>
 /// <param name="ca">CA</param>
 /// <param name="ioa">IOA</param>
 /// <param name="nof">Name of file (file type)</param>
 /// <param name="fileProvider">File provider instance</param>
 public abstract void SendFile(int ca, int ioa, NameOfFile nof, IFileProvider fileProvider);
Esempio n. 22
0
 /// <summary>
 /// Read the file from slave (upload file)
 /// </summary>
 /// <param name="ca">CA</param>
 /// <param name="ioa">IOA</param>
 /// <param name="nof">Name of file (file type)</param>
 /// <param name="receiver">file receiver instance</param>
 public abstract void GetFile(int ca, int ioa, NameOfFile nof, IFileReceiver receiver);