예제 #1
0
        /// <summary>
        /// Loads the configuration from the XML node.
        /// </summary>
        public virtual void LoadFromXml(XmlElement xmlElem)
        {
            if (xmlElem == null)
            {
                throw new ArgumentNullException(nameof(xmlElem));
            }

            Active    = xmlElem.GetAttrAsBool("active");
            DataBlock = xmlElem.GetAttrAsEnum("dataBlock", xmlElem.GetAttrAsEnum <DataBlock>("tableType"));
            Address   = xmlElem.GetAttrAsInt("address");
            Name      = xmlElem.GetAttrAsString("name");

            ElemType defaultElemType = DefaultElemType;
            bool     defaultReadOnly = !ReadOnlyEnabled;
            bool     defaultBitMask  = !BitMaskEnabled;
            int      maxElemCnt      = MaxElemCnt;

            foreach (XmlElement elemElem in xmlElem.SelectNodes("Elem"))
            {
                if (Elems.Count >= maxElemCnt)
                {
                    break;
                }

                ElemConfig elemConfig = CreateElemConfig();
                elemConfig.ElemType  = elemElem.GetAttrAsEnum("type", defaultElemType);
                elemConfig.ByteOrder = elemElem.GetAttrAsString("byteOrder");
                elemConfig.ReadOnly  = elemElem.GetAttrAsBool("readOnly", defaultReadOnly);
                elemConfig.IsBitMask = elemElem.GetAttrAsBool("isBitMask", defaultBitMask);
                elemConfig.TagCode   = elemElem.GetAttrAsString("tagCode");
                elemConfig.Name      = elemElem.GetAttrAsString("name");
                Elems.Add(elemConfig);
            }
        }
예제 #2
0
        /// <summary>
        /// Loads the group from the XML node.
        /// </summary>
        public virtual void LoadFromXml(XmlElement groupElem)
        {
            if (groupElem == null)
            {
                throw new ArgumentNullException("groupElem");
            }

            Name    = groupElem.GetAttribute("name");
            Address = (ushort)groupElem.GetAttrAsInt("address");
            Active  = groupElem.GetAttrAsBool("active", true);

            XmlNodeList elemNodes   = groupElem.SelectNodes("Elem");
            int         maxElemCnt  = MaxElemCnt;
            ElemType    defElemType = DefElemType;

            foreach (XmlElement elemElem in elemNodes)
            {
                if (Elems.Count >= maxElemCnt)
                {
                    break;
                }

                Elem elem = CreateElem();
                elem.Name     = elemElem.GetAttribute("name");
                elem.ElemType = elemElem.GetAttrAsEnum("type", defElemType);

                if (ByteOrderEnabled)
                {
                    elem.ByteOrderStr = elemElem.GetAttribute("byteOrder");
                    elem.ByteOrder    = ModbusUtils.ParseByteOrder(elem.ByteOrderStr);
                }

                Elems.Add(elem);
            }
        }
예제 #3
0
        public void Init()
        {
            for (int i = 0; i < Template.Length; i++)
            {
                // add in template characters
                char ch = Template[i];
                if (Elems.ContainsKey(ch))
                {
                    Elems[ch]++;
                }
                else
                {
                    Elems.Add(ch, 1);
                }
            }

            // add in pairs
            for (int i = 0; i < Template.Length - 1; i++)
            {
                var key = Template.Substring(i, 2);
                if (Pairs.ContainsKey(key))
                {
                    Pairs[key]++;
                }
                else
                {
                    Pairs.Add(key, 1);
                }
            }
        }
예제 #4
0
    static void Main()
    {
        var elems      = new Elems();
        var serializer = new XmlSerializer(elems.GetType());

        serializer.Serialize(Console.Out, elems);
    }
예제 #5
0
 public object Clone()
 {
     return(new Day()
     {
         Level = this.Level,
         DayOfWeek = this.DayOfWeek,
         Elems = Elems?.Select(e => e.Clone()).Cast <IScheduleElem>().ToList()
     });
 }
예제 #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)Level;
         hashCode = (hashCode * 397) ^ (Elems != null ? Elems.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)DayOfWeek;
         return(hashCode);
     }
 }
예제 #7
0
 public bool Equals(Day other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Level == other.Level && DayOfWeek == other.DayOfWeek && Elems.UnorderEquals(other.Elems));
 }
예제 #8
0
 public void AddFrom(MfModelDicts dict)
 {
     foreach (var c in dict.Cates)
     {
         if (!Cates.ContainsKey(c.Key))
         {
             Cates.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Elems)
     {
         if (!Elems.ContainsKey(c.Key))
         {
             Elems.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Fams)
     {
         if (!Fams.ContainsKey(c.Key))
         {
             Fams.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Floors)
     {
         if (!Floors.ContainsKey(c.Key))
         {
             Floors.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Mats)
     {
         if (!Mats.ContainsKey(c.Key))
         {
             Mats.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Types)
     {
         if (!Types.ContainsKey(c.Key))
         {
             Types.Add(c.Key, c.Value);
         }
     }
     foreach (var c in dict.Views)
     {
         if (!Views.ContainsKey(c.Key))
         {
             Views.Add(c.Key, c.Value);
         }
     }
 }
예제 #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)Level;
         hashCode = (hashCode * 397) ^ (Elems != null ? Elems.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsOnEvenWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ (Discipline != null ? Discipline.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Teacher != null ? Teacher.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Place != null ? Place.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ BeginTime.GetHashCode();
         hashCode = (hashCode * 397) ^ Duration.GetHashCode();
         hashCode = (hashCode * 397) ^ (Notation != null ? Notation.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #10
0
 public bool Equals(Lesson other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Level == other.Level && IsOnEvenWeek == other.IsOnEvenWeek &&
            string.Equals(Discipline, other.Discipline) && string.Equals(Teacher, other.Teacher) &&
            string.Equals(Place, other.Place) && BeginTime.Equals(other.BeginTime) &&
            string.Equals(Notation, other.Notation) &&
            Duration.Equals(other.Duration) && Elems.UnorderEquals(other.Elems));
 }
예제 #11
0
파일: Services.cs 프로젝트: xguppy/ALS
        public void Init(List <Param> Structss)
        {
            Elems = new Elems();
            foreach (Param p in Structss)
            {
                switch (p.Name.ToLower())
                {
                case _arithmFuncs:
                    Elems.SetFuncs(p.Data.Select(x => x.Value).ToList());
                    break;

                case _arithmSigns:
                    Elems.SetSigns(p.Data.Select(x => x.Value).ToList());
                    break;

                default:
                    break;
                }
            }
        }
예제 #12
0
        public void PairInsertion()
        {
            NewPairs = new Dictionary <string, long>();

            foreach (var pair in Pairs)
            {
                char ch = Converter[pair.Key][0];
                if (Elems.ContainsKey(ch))
                {
                    Elems[ch] += pair.Value;
                }
                else
                {
                    Elems.Add(ch, pair.Value);
                }

                AddNewPair($"{pair.Key[0]}{ch}", pair.Value);
                AddNewPair($"{ch}{pair.Key[1]}", pair.Value);
            }

            Pairs = NewPairs;
        }
예제 #13
0
        /// <summary>
        /// Copies the group properties from the source group.
        /// </summary>
        public virtual void CopyFrom(ElemGroup srcGroup)
        {
            if (srcGroup == null)
            {
                throw new ArgumentNullException("srcGroup");
            }

            Name          = srcGroup.Name;
            Address       = srcGroup.Address;
            Active        = srcGroup.Active;
            StartKPTagInd = srcGroup.StartKPTagInd;
            StartSignal   = srcGroup.StartSignal;
            Elems.Clear();

            foreach (Elem srcElem in srcGroup.Elems)
            {
                Elem destElem = CreateElem();
                destElem.Name         = srcElem.Name;
                destElem.ElemType     = srcElem.ElemType;
                destElem.ByteOrder    = srcElem.ByteOrder; // copy the array reference
                destElem.ByteOrderStr = srcElem.ByteOrderStr;
                Elems.Add(destElem);
            }
        }
 public static bool Logged(Elems elem)
 {
     return(list.Where(e => e.Equals(elem)).Count() > 0);
 }
예제 #15
0
파일: GenExprFrac.cs 프로젝트: xguppy/ALS
 public GenExprFrac(Elems e, bool multypleReturnDatas = false) : base(e, multypleReturnDatas)
 {
     _makeFrac = true;
 }
예제 #16
0
 public void InitDefault(string tempDir = default)
 {
     Elems = new Elems();
     Elems.Default();
     TempDir = tempDir;
 }
예제 #17
0
 public GenExpr(Elems e, bool multypleReturnDatas = false)
 {
     _arithmExpr         = new ArithmExpr(e);
     MultypleReturnDatas = multypleReturnDatas;
 }
예제 #18
0
파일: Services.cs 프로젝트: xguppy/ALS
 public void InitDefault()
 {
     Elems = new Elems();
     Elems.Default();
 }
 public static bool ExistKey(string key)
 {
     return(Elems.Where(a => a.Key == key).Count() != 0 ? true : false);
 }
 /*public static bool operator == (Elems a, Elems b)
  * {
  *  return a.ip == b.ip;
  * }
  * public static bool operator != (Elems a, Elems b)
  * {
  *  return a.ip != b.ip;
  * }*/
 public bool Equals(Elems b)
 {
     return(this.ip == b.ip);
 }