public void Init(int starttime) { values.Clear(); ValueSegment vs; switch (Type) { case "BIT": vs = new BitSegment(); vs.Value = 0; break; case "WORD": vs = new WordSegment(); vs.Value = 0; break; case "DWORD": vs = new DWordSegment(); vs.Value = 0; break; case "FLOAT": vs = new FloatSegment(); vs.Value = 0.0; break; default: throw new ArgumentException(); } vs.TimeStart = starttime; vs.TimeEnd = starttime; values.Add(vs); }
public override ValueSegment Clone() { FloatSegment fseg = new FloatSegment(); fseg.Value = Value; return(_Clone(fseg)); }
public void LoadXml(XElement node_SDModel) { string name = (string)(node_SDModel.Attribute("Name")); string type = (string)(node_SDModel.Attribute("Type")); string var = (string)(node_SDModel.Attribute("var")); SVUnit = SimulateVariableUnit.Create(name, type); SVUnit.Var = var; IEnumerable <XElement> node_VSs = node_SDModel.Elements("ValueSegment"); values = new List <ValueSegment>(); foreach (XElement node_VS in node_VSs) { ValueSegment vs; switch (Type) { case "BIT": vs = new BitSegment(); vs.Value = (Int32)node_VS.Attribute("Value"); break; case "WORD": vs = new WordSegment(); vs.Value = (Int32)node_VS.Attribute("Value"); break; case "DWORD": vs = new DWordSegment(); vs.Value = (Int64)node_VS.Attribute("Value"); break; case "FLOAT": vs = new FloatSegment(); vs.Value = (double)node_VS.Attribute("Value"); break; default: throw new FormatException(); } vs.TimeStart = (int)(node_VS.Attribute("TimeStart")); vs.TimeEnd = (int)(node_VS.Attribute("TimeEnd")); values.Add(vs); } IsLock = (bool)(node_SDModel.Attribute("IsLock")); IsView = (bool)(node_SDModel.Attribute("IsView")); }