Ejemplo n.º 1
0
        private void RetrieveCounterSettings(XmlTextWriter writer, int FirstBlock, int BlockCount, IJPCountConditionCollection cc)
        {
            for (int i = 0; i < BlockCount; i++)
            {
                IJPCountCondition c = cc[FirstBlock + i];
                writer.WriteStartElement("Counter"); // Start Counter
                {
                    writer.WriteAttributeString("Block", (i + 1).ToString());
                    writer.WriteStartElement("Range"); // Start Range
                    {
                        writer.WriteAttributeString("Range1", c.LowerRange);
                        writer.WriteAttributeString("Range2", c.UpperRange);
                        writer.WriteAttributeString("JumpFrom", c.JumpFrom);
                        writer.WriteAttributeString("JumpTo", c.JumpTo);
                    }
                    writer.WriteEndElement();          //  End Range

                    writer.WriteStartElement("Count"); // Start Count
                    {
                        writer.WriteAttributeString("InitialValue", c.Value);
                        writer.WriteAttributeString("Increment", c.Increment.ToString());
                        writer.WriteAttributeString("Direction", c.Direction.ToString());
                        writer.WriteAttributeString("ZeroSuppression", c.SuppressesZero.ToString());
                    }
                    writer.WriteEndElement(); //  End Count

                    //writer.WriteStartElement("Reset"); // Start Reset
                    //{
                    //   writer.WriteAttributeString("Type", c.ResetSignal.ToString());
                    //   writer.WriteAttributeString("Value", c.Reset.ToString());
                    //}
                    //writer.WriteEndElement(); //  End Reset

                    writer.WriteStartElement("Misc"); // Start Misc
                    {
                        writer.WriteAttributeString("UpdateIP", c.UpdateInProgress.ToString());
                        writer.WriteAttributeString("UpdateUnit", c.UpdateUnit.ToString());
                        writer.WriteAttributeString("ExternalCount", c.UsesExternalSignalCount.ToString());
                        //writer.WriteAttributeString("Multiplier",c.Multiplier.ToString());
                        //writer.WriteAttributeString("SkipCount",c.CountSkip.ToString());
                    }
                    writer.WriteEndElement(); //  End Misc
                }
                writer.WriteEndElement();     //  End Counter
            }
        }
Ejemplo n.º 2
0
        // Send counter related information
        private bool LoadCount(IJPCountConditionCollection ccc, XmlNode obj, int CountBlockCount, int FirstCountBlock)
        {
            bool    success = true;
            XmlNode n;

            foreach (XmlNode c in obj)
            {
                if (c is XmlWhitespace)
                {
                    continue;
                }
                if (c.Name == "Counter" && int.TryParse(GetXmlAttr(c, "Block"), out int b) && b <= CountBlockCount)
                {
                    IJPCountCondition cc = ccc[FirstCountBlock + b - 1];
                    if ((n = c.SelectSingleNode("Range")) != null)
                    {
                        foreach (XmlAttribute a in n.Attributes)
                        {
                            switch (a.Name)
                            {
                            case "Range1":
                                cc.LowerRange = a.Value;
                                break;

                            case "Range2":
                                cc.UpperRange = a.Value;
                                break;

                            case "JumpFrom":
                                cc.JumpFrom = a.Value;
                                break;

                            case "JumpTo":
                                cc.JumpTo = a.Value;
                                break;
                            }
                        }
                    }

                    if ((n = c.SelectSingleNode("Count")) != null)
                    {
                        foreach (XmlAttribute a in n.Attributes)
                        {
                            switch (a.Name)
                            {
                            case "InitialValue":
                                cc.Value = a.Value;
                                break;

                            case "Increment":
                                cc.Increment = (byte)Convert.ToInt32(a.Value);
                                break;

                            case "Direction":
                                cc.Direction = ParseEnum <IJPCountConditionDirection>(a.Value);
                                break;

                            case "ZeroSuppression":
                                cc.SuppressesZero = Convert.ToBoolean(a.Value);
                                break;
                            }
                        }
                    }

                    if ((n = c.SelectSingleNode("Reset")) != null)
                    {
                        foreach (XmlAttribute a in n.Attributes)
                        {
                            switch (a.Name)
                            {
                            case "Value":
                                cc.Reset = a.Value;
                                break;

                            case "Type":
                                cc.ResetSignal = ParseEnum <IJPCountConditionResetSignal>(a.Value);
                                break;
                            }
                        }
                    }

                    if ((n = c.SelectSingleNode("Misc")) != null)
                    {
                        foreach (XmlAttribute a in n.Attributes)
                        {
                            switch (a.Name)
                            {
                            case "UpdateIP":
                                cc.UpdateInProgress = Convert.ToUInt32(a.Value);
                                break;

                            case "UpdateUnit":
                                cc.UpdateUnit = Convert.ToUInt32(a.Value);
                                break;

                            case "ExternalCount":
                                cc.UsesExternalSignalCount = Convert.ToBoolean(a.Value);
                                break;

                            case "Multiplier":
                                cc.Multiplier = a.Value;
                                break;

                            case "Skip":
                                cc.CountSkip = a.Value;
                                break;
                            }
                        }
                    }
                }
            }
            return(success);
        }