コード例 #1
0
        /// <summary>Update byte array
        /// Data from header strucutres, except dynamic structures are parsed back into the byte array</summary>
        public override void Parse()
        {
            // Configuration header
            mBlockData[0] = mTaskAnzahl;
            mBlockData[1] = NumberOfUsedDatamaps;
            mBlockData[2] = (byte)(ConfigVersion.Hauptversion % 256);
            mBlockData[3] = (byte)(ConfigVersion.Hauptversion / 256);
            mBlockData[4] = ConfigVersion.Nebenversion;
            mBlockData[5] = ConfigVersion.Revision;
            mBlockData[6] = AbwaertsVersion;
            mBlockData[7] = SoftwareType;
            mBlockData[8] = PasswordLevel;

            // Task arrays
            TaskVector[] tvt = new TaskVector[25];
            TaskError[,] tet = new TaskError[25, 7];
            for (int i = 0; i < 25; i++)
            {
                mBlockData[9 + (i * 3)]  = (byte)(GetTaskIdentifier(i));
                mBlockData[10 + (i * 3)] = (byte)(GetTaskOffset(i) % 256);
                mBlockData[11 + (i * 3)] = (byte)(GetTaskOffset(i) / 256);
                mBlockData[84 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 0) * 4) + (GetTaskErrorRingFlag(i, 0) ? 1 : 0));
                mBlockData[85 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 1) * 4) + (GetTaskErrorRingFlag(i, 1) ? 1 : 0));
                mBlockData[86 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 2) * 4) + (GetTaskErrorRingFlag(i, 2) ? 1 : 0));
                mBlockData[87 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 3) * 4) + (GetTaskErrorRingFlag(i, 3) ? 1 : 0));
                mBlockData[88 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 4) * 4) + (GetTaskErrorRingFlag(i, 4) ? 1 : 0));
                mBlockData[89 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 5) * 4) + (GetTaskErrorRingFlag(i, 5) ? 1 : 0));
                mBlockData[90 + (i * 7)] = (byte)((GetTaskErrorNumber(i, 6) * 4) + (GetTaskErrorRingFlag(i, 6) ? 1 : 0));
            }
            GenerateChecksum();
        }
コード例 #2
0
        /// <summary>Import from base block</summary>
        /// <param name="Source">Source block</param>
        /// <param name="KeepVersion">Flag if Target version should remain</param>
        /// <returns></returns>
        public override ReturnValue Import(ref Block Source, bool KeepVersion)
        {
            ReturnValue _ret = ReturnValue.NoError;
            byte        b    = 0;

            //Import block header
            if (Source.Type != Type)
            {
                _ret = ReturnValue.BlockNotFound;
            }
            else
            {
                if (KeepVersion)
                {
                    if (Source.Version != Version)
                    {
                        _ret = ReturnValue.VersionMismatch;
                    }
                    else
                    {
                        Source.GetData(out mBlockData);
                        if (DataSize != (UInt16)mBlockData.Length)
                        {
                            _ret = ReturnValue.SizeMismatch;
                        }
                    }
                }
                else
                {
                    Version = Source.Version;
                    Source.GetData(out mBlockData);
                    if (DataSize != (UInt16)mBlockData.Length)
                    {
                        _ret = ReturnValue.SizeMismatch;
                    }
                }
                mChecksum = Source.Checksum;
            }
            if (_ret == ReturnValue.NoError && mBlockData != null)
            {
                //Import configuration header
                mTaskAnzahl          = mBlockData[0];
                NumberOfUsedDatamaps = mBlockData[1];
                VersionT ver;
                ver.Hauptversion = (UInt16)(mBlockData[2] + (mBlockData[3] * 256));
                ver.Nebenversion = mBlockData[4];
                ver.Revision     = mBlockData[5];
                ConfigVersion    = ver;
                AbwaertsVersion  = mBlockData[6];
                SoftwareType     = mBlockData[7];
                PasswordLevel    = mBlockData[8];
                //Import task arrays
                TaskVector[] tvt = new TaskVector[25];
                TaskError[,] tet = new TaskError[25, 7];
                for (int i = 0; i < 25; i++)
                {
                    tvt[i].Tasknummer = (TaskIdentifier)mBlockData[9 + (i * 3)];
                    tvt[i].Offset     = BitConverter.ToUInt16(mBlockData, 10 + (i * 3));
                    b = mBlockData[84 + (i * 7)];
                    tet[i, 0].ErrNo   = (byte)(b / 4);
                    tet[i, 0].Ring    = (b & 0x01) > 0;
                    tet[i, 0].reserve = (b & 0x02) > 1;
                    b = mBlockData[85 + (i * 7)];
                    tet[i, 1].ErrNo   = (byte)(b / 4);
                    tet[i, 1].Ring    = (b & 0x01) > 0;
                    tet[i, 1].reserve = (b & 0x02) > 1;
                    b = mBlockData[86 + (i * 7)];
                    tet[i, 2].ErrNo   = (byte)(b / 4);
                    tet[i, 2].Ring    = (b & 0x01) > 0;
                    tet[i, 2].reserve = (b & 0x02) > 1;
                    b = mBlockData[87 + (i * 7)];
                    tet[i, 3].ErrNo   = (byte)(b / 4);
                    tet[i, 3].Ring    = (b & 0x01) > 0;
                    tet[i, 3].reserve = (b & 0x02) > 1;
                    b = mBlockData[88 + (i * 7)];
                    tet[i, 4].ErrNo   = (byte)(b / 4);
                    tet[i, 4].Ring    = (b & 0x01) > 0;
                    tet[i, 4].reserve = (b & 0x02) > 1;
                    b = mBlockData[89 + (i * 7)];
                    tet[i, 5].ErrNo   = (byte)(b / 4);
                    tet[i, 5].Ring    = (b & 0x01) > 0;
                    tet[i, 5].reserve = (b & 0x02) > 1;
                    b = mBlockData[90 + (i * 7)];
                    tet[i, 6].ErrNo   = (byte)(b / 4);
                    tet[i, 6].Ring    = (b & 0x01) > 0;
                    tet[i, 6].reserve = (b & 0x02) > 1;
                }
                SetTaskVectorTable(tvt);
                SetTaskErrorTable(tet);
                //Import initial values
                InitValueImport();

                //Import tasks
                maTask = new TaskConfiguration[mTaskAnzahl];
                for (int i = 0; i < mTaskAnzahl; i++)
                {
                    maTask[i] = new TaskConfiguration(GetTaskIdentifier(i));
                    if (!maTask[i].Import8(GetTaskOffset(i), ref mBlockData))
                    {
                        _ret = ReturnValue.SizeMismatch;
                    }
                }
            }
            return(_ret);
        }