Beispiel #1
0
        internal bool[] ReadDiscretes(byte functionCode, byte slaveAddress, ushort startAddress, ushort numberOfPoints)
        {
            ReadCoilsInputsRequest  request  = new ReadCoilsInputsRequest(functionCode, slaveAddress, startAddress, numberOfPoints);
            ReadCoilsInputsResponse response = Transport.UnicastMessage <ReadCoilsInputsResponse>(request);

            return(CollectionUtility.Slice(response.Data, 0, request.NumberOfPoints));
        }
Beispiel #2
0
        public Bin(string fileName, Vector3 position, Vector3 rotation, Vector3 scale)
        {
            // header
            binaryReader = new ABinaryReader(Yay0.Decompress(fileName), Endianness.Big, Encoding.GetEncoding(932));
            unk1         = binaryReader.Read8();
            name         = binaryReader.ReadClampedString(11);
            offsets      = binaryReader.Read32s(21);

            // data
            graphObjects = (HasGraph ? GetGraphObjects(0) : new GraphObject[0]);
            batches      = (HasBatches ? CollectionUtility.Initialize(GetBatchCount(), index => GetBatch(index)) : new Batch[0]);
            shaders      = (HasShaders ? CollectionUtility.Initialize(GetShaderCount(), index => GetShader(index)) : new Shader[0]);
            materials    = (HasMaterials ? CollectionUtility.Initialize(GetMaterialCount(), index => GetMaterial(index)) : new Material[0]);
            textures     = (HasTextures ? CollectionUtility.Initialize(GetTextureCount(), index => GetTexture(index)) : new Texture[0]);
            positions    = (HasPositions ? CollectionUtility.Initialize(GetPositionCount(), index => GetPosition(index)) : new Vector3[0]);
            normals      = (HasNormals ? CollectionUtility.Initialize(GetNormalCount(), index => GetNormal(index)) : new Vector3[0]);
            texCoord0s   = (HasTexCoord0s ? CollectionUtility.Initialize(GetTexCoord0Count(), index => GetTexCoord0(index)) : new Vector2[0]);
            texCoord1s   = (HasTexCoord1s ? CollectionUtility.Initialize(GetTexCoord1Count(), index => GetTexCoord1(index)) : new Vector2[0]);

            // Load textures.
            glTextures = textures.Select(texture => texture.ToGLTexture()).ToArray();

            // Orient.
            Position = position;
            Rotation = rotation;
            Scale    = scale;
        }
Beispiel #3
0
        /// <summary>
        /// Performs a combination of one read operation and one write operation in a single Modbus transaction.
        /// The write operation is performed before the read.
        /// </summary>
        /// <param name="slaveAddress">Address of device to read values from.</param>
        /// <param name="startReadAddress">Address to begin reading (Holding registers are addressed starting at 0).</param>
        /// <param name="numberOfPointsToRead">Number of registers to read.</param>
        /// <param name="startWriteAddress">Address to begin writing (Holding registers are addressed starting at 0).</param>
        /// <param name="writeData">Register values to write.</param>
        public ushort[] ReadWriteMultipleRegisters(byte slaveAddress, ushort startReadAddress, ushort numberOfPointsToRead, ushort startWriteAddress, ushort[] writeData)
        {
            ReadWriteMultipleRegistersRequest request  = new ReadWriteMultipleRegistersRequest(slaveAddress, startReadAddress, numberOfPointsToRead, startWriteAddress, new RegisterCollection(writeData));
            ReadHoldingInputRegistersResponse response = Transport.UnicastMessage <ReadHoldingInputRegistersResponse>(request);

            return(CollectionUtility.ToArray(response.Data));
        }
Beispiel #4
0
        /// <summary>
        /// Retrieves subset of data from collection.
        /// </summary>
        /// <typeparam name="T">The collection type.</typeparam>
        /// <typeparam name="U">The type of elements in the collection.</typeparam>
        internal static T ReadData <T, U>(ModbusDataCollection <U> dataSource, ushort startAddress, ushort count) where T : Collection <U>, new()
        {
            int startIndex = startAddress + 1;

            if (startIndex < 0 || startIndex >= dataSource.Count)
            {
                throw new ArgumentOutOfRangeException("Start address was out of range. Must be non-negative and <= the size of the collection.");
            }

            if (dataSource.Count < startIndex + count)
            {
                throw new ArgumentOutOfRangeException("Read is outside valid range.");
            }

            U[] dataToRetrieve = CollectionUtility.Slice(dataSource, startIndex, count);
            T   result         = new T();

            for (int i = 0; i < count; i++)
            {
                result.Add(dataToRetrieve[i]);
            }

            //System.Console.WriteLine("reading " + startAddress + " " + count);
            return(result);
        }
Beispiel #5
0
        internal ushort[] ReadRegisters(byte functionCode, byte slaveAddress, ushort startAddress, ushort numberOfPoints)
        {
            ReadHoldingInputRegistersRequest  request  = new ReadHoldingInputRegistersRequest(functionCode, slaveAddress, startAddress, numberOfPoints);
            ReadHoldingInputRegistersResponse response = Transport.UnicastMessage <ReadHoldingInputRegistersResponse>(request);

            return(CollectionUtility.ToArray(response.Data));
        }
        public static void SortMemberItems(List <Metadata.Member> members)
        {
            CollectionUtility.MergeSort(members, delegate(Metadata.Member m1, Metadata.Member m2)
            {
                int typeIndex1 = GetMemberTypeSortIndex(m1);
                int typeIndex2 = GetMemberTypeSortIndex(m2);
                if (typeIndex1 < typeIndex2)
                {
                    return(-1);
                }
                if (typeIndex1 > typeIndex2)
                {
                    return(1);
                }

                if (m1.Static && !m2.Static)
                {
                    return(-1);
                }
                if (!m1.Static && m2.Static)
                {
                    return(1);
                }

                return(string.Compare(m1.Name + "z", m2.Name + "z"));
            });
        }
Beispiel #7
0
 public static void List_Vector3_Shuffle(List <Vector3> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         CollectionUtility.List_Vector3_Swap(list, i, Random.Range(i, list.Count));
     }
 }
Beispiel #8
0
 private DiffViewLines()
     : base(new List <DiffViewLine>())
 {
     // Called by the other constructors.
     this.diffStartLines = CollectionUtility.EmptyArray <int>();
     this.diffEndLines   = CollectionUtility.EmptyArray <int>();
 }
Beispiel #9
0
        static string SelectTextureFromList(List <string> list)
        {
            //select jpg between jpg, exr
            CollectionUtility.SelectionSort(list, delegate(string v1, string v2)
            {
                var ext1 = Path.GetExtension(v1.ToLower());
                var ext2 = Path.GetExtension(v2.ToLower());

                if (ext1 != ext2)
                {
                    if (ext1 == ".jpg")
                    {
                        return(-1);
                    }
                    if (ext2 == ".jpg")
                    {
                        return(1);
                    }
                }

                return(0);
            });

            if (list.Count != 0)
            {
                return(list[0]);
            }
            else
            {
                return("");
            }
        }
Beispiel #10
0
        public static List <PackageInfo> GetPackagesInfo()
        {
            var result = new List <PackageInfo>();

            for (int nExtension = 0; nExtension < 2; nExtension++)
            {
                var filter = nExtension == 0 ? "*.neoaxispackage" : "*.zip";

                if (Directory.Exists(PackagesFolder))
                {
                    foreach (var fileName in Directory.GetFiles(PackagesFolder, filter))
                    {
                        var fileBase = Path.GetFileNameWithoutExtension(fileName);
                        var strings  = fileBase.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                        if (strings.Length >= 2)
                        {
                            var info = new PackageInfo();
                            info.FullFilePath = fileName;
                            info.Identifier   = strings[0];
                            info.Title        = strings[0].Replace('_', ' ');
                            info.Version      = strings[1];
                            result.Add(info);
                        }
                    }
                }
            }

            CollectionUtility.MergeSort(result, delegate(PackageInfo p1, PackageInfo p2)
            {
                return(string.Compare(p1.Identifier, p2.Identifier));
            });

            return(result);
        }
        //

        public UndoActionListAddRemove(object list, ICollection <int> objectIndexes, bool add)         //, bool callDeleteObjects )
        {
            this.list          = list;
            this.objectIndexes = new List <int>(objectIndexes);

            //!!!!!
            //if( this.objectIndexes.Count > 1 )
            //	Log.Fatal( "check this.objectIndexes.Count > 1" );

            CollectionUtility.MergeSort(this.objectIndexes, delegate(int index1, int index2)
            {
                if (index1 < index2)
                {
                    return(-1);
                }
                if (index1 > index2)
                {
                    return(1);
                }
                return(0);
            });

            this.add = add;

            if (!add)             //&& callDeleteObjects )
            {
                RemoveObjects();
            }
            //else
            //{
            //ContentBrowserItem_NoSpecialization.AllObjects_PerformChildrenChanged( list );
            //}
        }
Beispiel #12
0
        internal void AddAdditionalInfo(bool addForm, bool addQueryString, bool addCookies)
        {
            if (_httpContext != null)
            {
                var unvalidatedCollections =
                    _httpContext.Request.TryGetUnvalidatedCollections((form, queryString, cookie) => new
                {
                    Form        = form,
                    QueryString = queryString,
                    Cookie      = cookie
                });

                EnsureAdditionalInfo();

                AdditionalInfo.Add(AdditionalInfo_ServerVariables,
                                   CollectionUtility.CopyCollection(_httpContext.Request.ServerVariables));

                if (addForm)
                {
                    AdditionalInfo.Add(AdditionalInfo_Form,
                                       CollectionUtility.CopyCollection(unvalidatedCollections.Form));
                }
                if (addQueryString)
                {
                    AdditionalInfo.Add(AdditionalInfo_QueryString,
                                       CollectionUtility.CopyCollection(unvalidatedCollections.QueryString));
                }
                if (addCookies)
                {
                    AdditionalInfo.Add(AdditionalInfo_Cookies,
                                       CollectionUtility.CopyCollection(unvalidatedCollections.Cookie));
                }
            }
        }
        internal static byte[] GetMbapHeader(IModbusMessage message)
        {
            byte[] transactionID = BitConverter.GetBytes((short)IPAddress.HostToNetworkOrder((short)(message.TransactionID)));
            byte[] protocol      = { 0, 0 };
            byte[] length        = BitConverter.GetBytes((short)IPAddress.HostToNetworkOrder((short)(message.ProtocolDataUnit.Length + 1)));

            return(CollectionUtility.Concat(transactionID, protocol, length, new byte[] { message.SlaveAddress }));
        }
Beispiel #14
0
        static void ProcessTouch(Viewport viewport, TouchData data)
        {
            bool handled = false;

            viewport.PerformTouch(data, ref handled);
            if (handled)
            {
                return;
            }

            //requested actions
            if (data.TouchDownRequestToControlActions.Count != 0)
            {
                //!!!!
                int maxDistance = viewport.SizeInPixels.MinComponent() / 20;


                var filtered = new List <TouchData.TouchDownRequestToProcessTouch>();
                foreach (var i in data.TouchDownRequestToControlActions)
                {
                    if (i.DistanceInPixels <= maxDistance)
                    {
                        filtered.Add(i);
                    }
                }

                //sort by priority and distance to the control
                CollectionUtility.SelectionSort(filtered,
                                                delegate(TouchData.TouchDownRequestToProcessTouch item1, TouchData.TouchDownRequestToProcessTouch item2)
                {
                    if (item1.ProcessPriority > item2.ProcessPriority)
                    {
                        return(-1);
                    }
                    else if (item1.ProcessPriority < item2.ProcessPriority)
                    {
                        return(1);
                    }

                    if (item1.DistanceInPixels < item2.DistanceInPixels)
                    {
                        return(-1);
                    }
                    else if (item1.DistanceInPixels > item2.DistanceInPixels)
                    {
                        return(1);
                    }

                    return(0);
                });

                if (filtered.Count != 0)
                {
                    var item2 = filtered[0];
                    item2.Action(item2.Sender, data, item2.AnyData);
                }
            }
        }
Beispiel #15
0
        void UpdateOpenScenes()
        {
            string[] newFiles = new string[0];
            try
            {
                newFiles = VirtualDirectory.GetFiles("", "*.scene", SearchOption.AllDirectories);

                CollectionUtility.MergeSort(newFiles, delegate(string name1, string name2)
                {
                    var s1 = name1.Replace("\\", " \\");
                    var s2 = name2.Replace("\\", " \\");
                    return(string.Compare(s1, s2));
                });
            }
            catch { }

            bool needUpdate = !newFiles.SequenceEqual(currentOpenScenes);

            if (!needUpdate)
            {
                return;
            }

            currentOpenScenes = newFiles;

            //add items
            try
            {
                var items = new List <ContentBrowser.Item>();

                foreach (var file in currentOpenScenes)
                {
                    if (!file.Contains(@"Base\Tools\NewResourceTemplates"))
                    {
                        var realFileName = VirtualPathUtility.GetRealPathByVirtual(file);

                        var item = new ContentBrowserItem_File(contentBrowserOpenScene, null, realFileName, false);
                        item.SetText(file);
                        item.Tag      = file;
                        item.imageKey = "Scene";

                        items.Add(item);
                    }
                }

                contentBrowserOpenScene.SetData(items, false);
                if (items.Count != 0)
                {
                    contentBrowserOpenScene.SelectItems(new ContentBrowser.Item[] { items[0] });
                }
            }
            catch (Exception exc)
            {
                Log.Warning(exc.Message);
                //contentBrowserOpenScene.SetError( "Error: " + exc.Message );
            }
        }
Beispiel #16
0
 public static void List_Vector3Color_Shuffle(List <Vector3> _Vector3List, List <Color> _ColorList)
 {
     for (int i = 0; i < _Vector3List.Count && i < _ColorList.Count; i++)
     {
         int shuffleIndex = Random.Range(i, _Vector3List.Count);
         CollectionUtility.List_Vector3_Swap(_Vector3List, i, shuffleIndex);
         CollectionUtility.List_T_Swap(_ColorList, i, shuffleIndex);
     }
 }
Beispiel #17
0
        internal override IModbusMessage ReadResponse <T>()
        {
            byte[] frameStart = Read(ResponseFrameStartLength);
            byte[] frameEnd   = Read(ResponseBytesToRead(frameStart));
            byte[] frame      = CollectionUtility.Concat(frameStart, frameEnd);
            _log.InfoFormat("RX: {0}", StringUtility.Join(", ", frame));

            return(CreateResponse <T>(frame));
        }
Beispiel #18
0
        internal override byte[] ReadRequest()
        {
            byte[] frameStart = Read(RequestFrameStartLength);
            byte[] frameEnd   = Read(RequestBytesToRead(frameStart));
            byte[] frame      = CollectionUtility.Concat <byte>(frameStart, frameEnd);
            _log.InfoFormat("RX: {0}", StringUtility.Join(", ", frame));

            return(frame);
        }
Beispiel #19
0
        public DirectoryData(string error)
        {
            this.DataType        = DirectoryDataType.Error;
            this.treeMapNode.Tag = this;

            this.SetName(error, error);
            this.SetSize(0);
            this.subData = CollectionUtility.EmptyArray <DirectoryData>();
            this.PullNodes();
        }
        protected override void InitializeUnique(byte[] frame)
        {
            if (frame.Length < 3 + frame[2])
            {
                throw new FormatException("Message frame data segment does not contain enough bytes.");
            }

            ByteCount = frame[2];
            Data      = new DiscreteCollection(CollectionUtility.Slice <byte>(frame, 3, ByteCount));
        }
        protected override void InitializeUnique(byte[] frame)
        {
            if (frame.Length < _minimumFrameSize + frame[2])
            {
                throw new FormatException("Message frame does not contain enough bytes.");
            }

            ByteCount = frame[2];
            Data      = new RegisterCollection(CollectionUtility.Slice <byte>(frame, 3, ByteCount));
        }
Beispiel #22
0
    public static void GetBuildResources(List <string> resourceList, string pathname, params ResourceType[] filter)
    {
        pathname = PathUtility.FormatPath(pathname);

        if (!Directory.Exists(PathUtility.ProjectPathToFullPath(pathname)))
        {
            if (CollectionUtility.Contains(filter, ResourcesUtility.GetResourceTypeByPath(pathname)))
            {
                resourceList.Add(pathname);
            }
        }
        else
        {
            //SCENES
            if (pathname.Contains("res/scenes"))
            {
                filter = CollectionUtility.Remove(filter, sceneFilterRemoves);
            }

            //ALWAYS BUILD
            else if (
                pathname.Contains("res/player") ||
                pathname.Contains("res/bullet") ||
                pathname.Contains("res/enemy") ||
                pathname.Contains("res/effects_tex") ||
                pathname.Contains("res/drawing"))
            {
                filter = buildFilter;
            }
            //Only Prefabs, No Scenes
            else
            {
                filter = CollectionUtility.Remove(filter, directoryFilterRemoves);
            }



            string[] fileList = Directory.GetFiles(pathname, "*");
            foreach (string resource in fileList)
            {
                if (CollectionUtility.Contains(
                        filter, ResourcesUtility.GetResourceTypeByPath(resource)))
                {
                    resourceList.Add(PathUtility.FullPathToProjectPath(resource));
                }
            }

            string[] dictList = Directory.GetDirectories(pathname);
            foreach (string dictname in dictList)
            {
                GetBuildResources(resourceList, dictname, filter);
            }
        }
    }
Beispiel #23
0
        /// <summary>
        /// Gets a hashcode for the rule
        /// </summary>
        /// <returns>A hashcode representing this rule</returns>
        public override int GetHashCode()
        {
            var result = 0;

            if (null != Left)
            {
                result = Left.GetHashCode();
            }
            result ^= CollectionUtility.GetHashCode(Right);
            return(result);
        }
Beispiel #24
0
        //Editors == Translators (applicable for collected works/edited books etc. AND contributions therein)
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            Reference currentReference = citation.Reference;
            Reference parentReference  = currentReference.ParentReference;

            bool currentReferenceHasEditors =
                currentReference.HasCoreField(ReferenceTypeCoreFieldId.Editors) &&
                currentReference.Editors != null &&
                currentReference.Editors.Any();

            bool currentReferenceHasTranslators =
                currentReference.Translators != null &&
                currentReference.Translators.Any();

            bool parentReferenceHasEditors =
                parentReference != null &&
                parentReference.HasCoreField(ReferenceTypeCoreFieldId.Editors) &&
                parentReference.Editors != null &&
                parentReference.Editors.Any();

            bool parentReferenceHasTranslators =
                parentReference != null &&
                parentReference.Translators != null &&
                parentReference.Translators.Any();


            if (currentReferenceHasTranslators && currentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(currentReference.Translators, currentReference.Editors, false));
            }

            if (currentReferenceHasTranslators && parentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(currentReference.Translators, parentReference.Editors, false));
            }

            if (parentReferenceHasTranslators && parentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(parentReference.Translators, parentReference.Editors, false));
            }


            //still here? then condition is not fulfilled
            return(false);
        }
        internal IModbusMessage CreateMessageAndInitializeTransactionID <T>(byte[] fullFrame) where T : IModbusMessage, new()
        {
            byte[] mbapHeader   = CollectionUtility.Slice(fullFrame, 0, 6);
            byte[] messageFrame = CollectionUtility.Slice(fullFrame, 6, fullFrame.Length - 6);

            IModbusMessage response = base.CreateResponse <T>(messageFrame);

            response.TransactionID = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(mbapHeader, 0));

            return(response);
        }
Beispiel #26
0
        public DirectoryData(string name, string fullName, long size, long fileCount)
        {
            this.DataType        = DirectoryDataType.Files;
            this.treeMapNode.Tag = this;

            this.SetName(name, fullName);
            this.SetSize(size);
            this.fileCount = fileCount;
            this.subData   = CollectionUtility.EmptyArray <DirectoryData>();
            this.PullNodes();
        }
Beispiel #27
0
        protected override void InitializeUnique(byte[] frame)
        {
            if (frame.Length < _minimumFrameSize + frame[6])
            {
                throw new FormatException("Message frame does not contain enough bytes.");
            }

            StartAddress   = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(frame, 2));
            NumberOfPoints = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(frame, 4));
            ByteCount      = frame[6];
            Data           = new RegisterCollection(CollectionUtility.Slice <byte>(frame, 7, ByteCount));
        }
Beispiel #28
0
        public GraphObject(ABinaryReader binaryReader)
        {
            Visible     = true;
            ParentIndex = binaryReader.ReadS16();
            ChildIndex  = binaryReader.ReadS16();
            NextIndex   = binaryReader.ReadS16();
            PrevIndex   = binaryReader.ReadS16();

            if (binaryReader.Read8() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            RenderFlags = (GraphObjectRenderFlags)binaryReader.Read8();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            Scale       = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Rotation    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Position    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            BoundingBox = new BoundingBox(binaryReader.ReadVector3D().ToVector3(), binaryReader.ReadVector3D().ToVector3());
            unk3        = binaryReader.ReadSingle();

            int partCount = binaryReader.ReadS16();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            int partOffset = binaryReader.ReadS32();

            if (binaryReader.Read32s(7).Any(zero => zero != 0))
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            binaryReader.Goto(partOffset);
            parts = CollectionUtility.Initialize <Part>(partCount, () => new Part(binaryReader));
            binaryReader.Back();
        }
Beispiel #29
0
        private async void FilterConfig_Load(object sender, EventArgs e)
        {
            lvCustomize.Items.AddRange(AppContext.Instance.Options.RuleCollection.Select(s =>
            {
                var item = new ListViewItem(new[] { s.Rules.JoinAsString(";"), s.IsRegex ? "是" : "" })
                {
                    Tag = s
                };
                item.ImageIndex = s.Behaviour == FilterBehaviour.Hide ? 1 : 2;
                return(item);
            }).ToArray());

            //在线列表
            var client = new HttpClient();
            var ctx    = client.Create(HttpMethod.Post, "https://www.fishlee.net/app/getfiles/605", result: new
            {
                response = CollectionUtility.CreateAnymousTypeList(new { id = 0, name = "", downloadCount = 0, updateTime = DateTime.Now }, 4)
            });
            await ctx.SendAsync().ConfigureAwait(true);

            var list = ctx.Result?.response;

            if (list == null || list.Count == 0)
            {
                return;
            }

            lvRss.Items.AddRange(list.Select(s =>
            {
                var item = new ListViewItem(s.name.DefaultForEmpty("未命名订阅"))
                {
                    ImageIndex = 0, Checked = AppContext.Instance.Options.RssRuleCollection.ContainsKey(s.id), Tag = s.id
                };
                item.SubItems.AddRange(new[] { s.updateTime.MakeDateTimeFriendly(), s.downloadCount.ToString("N0") });
                return(item);
            }).ToArray());
            lvRss.ItemChecked += (s, ex) =>
            {
                var item = ex.Item;
                var id   = (int)item.Tag;
                if (item.Checked)
                {
                    AppContext.Instance.Options.RssRuleCollection.Add(id, null);
                    AppContext.Instance.Options.RssRuleCollection.CheckUpdate(id);
                }
                else
                {
                    AppContext.Instance.Options.RssRuleCollection.Remove(id);
                }
            };
        }
        protected override void InitializeUnique(byte[] frame)
        {
            if (frame.Length < _minimumFrameSize + frame[10])
            {
                throw new FormatException("Message frame does not contain enough bytes.");
            }

            byte[] readFrame  = CollectionUtility.Slice(frame, 2, 4);
            byte[] writeFrame = CollectionUtility.Slice(frame, 6, frame.Length - 6);
            byte[] header     = { SlaveAddress, FunctionCode };

            _readRequest  = ModbusMessageFactory.CreateModbusMessage <ReadHoldingInputRegistersRequest>(CollectionUtility.Concat(header, readFrame));
            _writeRequest = ModbusMessageFactory.CreateModbusMessage <WriteMultipleRegistersRequest>(CollectionUtility.Concat(header, writeFrame));
        }
 public void Setup()
 {
     _collectionUtility = new CollectionUtility();
     _testList = new ArrayList(5) {_object1, _object2, _object3, _object4, _object5};
 }