/// <summary> /// 监视一个视点 /// </summary> /// <param name="sdmodel">视点模型</param> public void View(SimulateDataModel sdmodel) { if (!viewsdmodels.Contains(sdmodel)) { viewsdmodels.Add(sdmodel); } }
public void Setup(SimulateDataModel _sdmodel) { if (MainCanva.Children.Contains(NameTextInput)) { MainCanva.Children.Remove(NameTextInput); } if (!MainCanva.Children.Contains(NameTextBlock)) { MainCanva.Children.Add(NameTextBlock); } sdmodel = _sdmodel; NameTextBlock.Text = String.Format("{0:s}({1:s})", sdmodel.Name, sdmodel.Var); if (sdmodel.IsLock) { LockFlag.Visibility = Visibility.Visible; } else { LockFlag.Visibility = Visibility.Hidden; } if (sdmodel.IsView) { ViewFlag.Visibility = Visibility.Visible; } else { ViewFlag.Visibility = Visibility.Hidden; } }
public void CursorRemoveValue(SimulateDataModel sdmodel) { int timestart = (int)(CursorTimeStart()); int timeend = (int)(CursorTimeEnd()); RemoveValue(sdmodel, timestart, timeend); }
public void CursorSetValue(SimulateDataModel sdmodel, object value) { int timestart = (int)(CursorTimeStart()); int timeend = (int)(CursorTimeEnd()); SetValue(sdmodel, value, timestart, timeend); }
/// <summary> /// 解除监视一个视点 /// </summary> /// <param name="sdmodel"></param> public void Unview(SimulateDataModel sdmodel) { if (viewsdmodels.Contains(sdmodel)) { viewsdmodels.Remove(sdmodel); } }
/// <summary> /// 解锁一个视点 /// </summary> /// <param name="sdmodel">视点模型</param> public void Unlock(SimulateDataModel sdmodel) { if (locksdmodels.Contains(sdmodel)) { locksdmodels.Remove(sdmodel); SetEnable(sdmodel.Name, 1, 0); } }
/// <summary> /// 锁定一个视点 /// </summary> /// <param name="sdmodel">视点模型</param> public void Lock(SimulateDataModel sdmodel) { if (!locksdmodels.Contains(sdmodel)) { locksdmodels.Add(sdmodel); SetEnable(sdmodel.Name, 1, 1); } }
public void UpdateView(double timestart, double timeend) { StreamReader fin = new StreamReader("simulog.log"); while (!fin.EndOfStream) { string text = fin.ReadLine(); string[] args = text.Split(' '); string name = args[0]; int time = int.Parse(args[1]); ValueSegment vs = null, vsp = null; SimulateDataModel sdmodel = vddict[name]; switch (sdmodel.Type) { case "BIT": vs = new BitSegment(); vs.Value = Int32.Parse(args[2]); break; case "WORD": vs = new WordSegment(); vs.Value = Int32.Parse(args[2]); break; case "DWORD": vs = new DWordSegment(); vs.Value = Int64.Parse(args[2]); break; case "FLOAT": vs = new FloatSegment(); vs.Value = float.Parse(args[2]); break; } if (sdmodel.Values.Count() == 0) { vsp = vs.Clone(); vsp.Value = 0; vsp.TimeStart = (int)(timestart); vs.TimeStart = vsp.TimeEnd = time; sdmodel.Add(vsp); sdmodel.Add(vs); } else { vsp = sdmodel.Values.Last(); vs.TimeStart = vsp.TimeEnd = time; sdmodel.Add(vs); } } foreach (SimulateDataModel sdmodel in vddict.Values) { if (sdmodel.Values.Count() > 0) { sdmodel.Values.Last().TimeEnd = (int)(timeend); } } }
public SimulateDataViewModel() { InitializeComponent(); sdmodel = null; MainCanva.Children.Remove(NameTextBlock); LockFlag.Visibility = Visibility.Hidden; ViewFlag.Visibility = Visibility.Hidden; NameTextInput.KeyUp += OnInputKeyUp; }
public void Setup(SimulateDataModel _sdmodel, int timestart, int timeend) { List <SimulateDataModel> _sdmodels = new List <SimulateDataModel>(); _sdmodels.Add(_sdmodel); this.sdmodels = _sdmodels; this.timestart = timestart; this.timeend = timeend; _Setup(); }
private void OnRunDataFinished(object sender, SimulateDataModelEventArgs e) { foreach (SimulateDataChartModel sdcmodel in SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; if (sdmodel.IsView) { sdcmodel.Update(); } } }
public void View(SimulateDataModel sdmodel) { UpdateStop(); if (!vddict.ContainsKey(sdmodel.Name)) { vddict.Add(sdmodel.Name, sdmodel); //sdmodel.IsView = true; dllmodel.View(sdmodel); } UpdateStart(); }
private void OnSDModelCopy(object sender, SimulateDataModelEventArgs e) { copysdmodels.Clear(); copystart = e.TimeStart; copyend = e.TimeEnd; foreach (SimulateDataChartModel sdcmodel in VChart.CursorCollection()) { SimulateDataModel sdmodel = sdcmodel.SDModel.Clone(); copysdmodels.Add(sdmodel); } }
public void Unlock(SimulateDataModel sdmodel) { UpdateStop(); if (lddict.ContainsKey(sdmodel.Name)) { lddict.Remove(sdmodel.Name); //sdmodel.IsLock = false; dllmodel.Unlock(sdmodel); } UpdateStart(); }
public void Unview(SimulateDataModel sdmodel) { UpdateStop(); if (vddict.ContainsKey(sdmodel.Name)) { vddict.Remove(sdmodel.Name); //sdmodel.IsView = false; dllmodel.Unview(sdmodel); } UpdateStart(); }
public void Lock(SimulateDataModel sdmodel) { UpdateStop(); if (!lddict.ContainsKey(sdmodel.Name)) { lddict.Add(sdmodel.Name, sdmodel); //sdmodel.IsLock = true; dllmodel.Lock(sdmodel); } UpdateStart(); }
private void SaveXml(string filename, int timestart, int timeend) { XDocument xdoc = new XDocument(); XElement node_Root = new XElement("SimuDatas"); XElement node_SDModel = null; foreach (SimulateDataChartModel sdcmodel in VChart.CursorCollection()) { SimulateDataModel sdmodel = sdcmodel.SDModel; node_SDModel = new XElement("SimuDataNode"); sdmodel.SaveXml(node_SDModel, timestart, timeend); node_Root.Add(node_SDModel); } xdoc.Add(node_Root); xdoc.Save(filename); }
private void SaveXml(string filename) { XDocument xdoc = new XDocument(); XElement node_Root = new XElement("SimuDatas"); XElement node_SDModel = null; foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; node_SDModel = new XElement("SimuDataNode"); sdmodel.SaveXml(node_SDModel); node_Root.Add(node_SDModel); } xdoc.Add(node_Root); xdoc.Save(filename); }
public void SetValue(SimulateDataModel sour, SimulateDataModel dest, int sourstart, int sourend, int deststart, int destend) { sour.SortByTime(); destend = deststart + (sourend - sourstart); IEnumerator <ValueSegment> souriter = sour.Values.GetEnumerator(); souriter.MoveNext(); ValueSegment sourvseg = souriter.Current; while (sourvseg != null && sourvseg.TimeEnd < sourstart) { if (!souriter.MoveNext()) { break; } sourvseg = souriter.Current; } RemoveValue(dest, deststart, destend); sourvseg = souriter.Current; while (sourvseg != null && sourvseg.TimeStart < sourend) { int vsegstart = sourvseg.TimeStart; int vsegend = sourvseg.TimeEnd; if (vsegstart < sourstart) { vsegstart = sourstart; } if (vsegend > sourend) { vsegend = sourend; } if (vsegstart > vsegend) { continue; } ValueSegment vseg = sourvseg.Clone(); vseg.TimeStart = vsegstart + (deststart - sourstart); vseg.TimeEnd = vsegend + (deststart - sourstart); dest.Add(vseg); if (!souriter.MoveNext()) { break; } sourvseg = souriter.Current; } }
private void LoadXml(string filename) { XDocument xdoc = XDocument.Load(filename); XElement node_Root = xdoc.Element("SimuDatas"); IEnumerable <XElement> node_SDModels = node_Root.Elements("SimuDataNode"); SimulateDataModelEventArgs e; foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; e = new SimulateDataModelEventArgs(); e.SDModel_old = sdmodel; e.SDModel_new = null; OnSDModelClose(this, e); } //VList.Clear(); //VChart.Clear(); int id = 0; foreach (XElement node_SDModel in node_SDModels) { SimulateDataModel sdmodel = new SimulateDataModel(); sdmodel.LoadXml(node_SDModel); e = new SimulateDataModelEventArgs(); e.SDModel_new = sdmodel; e.ID = id++; if (SDModelSetup != null) { SDModelSetup(this, e); } } foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; e = new SimulateDataModelEventArgs(); e.SDModel_new = sdmodel; if (sdmodel.IsLock && SDModelLock != null) { SDModelLock(this, e); } if (sdmodel.IsView && SDModelView != null) { SDModelView(this, e); } } }
private void OnRunDrawFinished(object sender, SimulateDataModelEventArgs e) { List <SimulateDataModel> views = new List <SimulateDataModel>(); foreach (SimulateDataChartModel sdcmodel in SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; if (sdmodel.IsView) { views.Add(sdmodel); } } e.SDModels = views; if (XYModelCreate != null) { XYModelCreate(this, e); } }
public void SetValue(SimulateDataModel sdmodel, object value, int timestart, int timeend) { RemoveValue(sdmodel, timestart, timeend); ValueSegment vseg; switch (sdmodel.Type) { case "BIT": BitSegment bseg = new BitSegment(); bseg.Value = value; vseg = bseg; break; case "WORD": WordSegment wseg = new WordSegment(); wseg.Value = value; vseg = wseg; break; case "DWORD": DWordSegment dseg = new DWordSegment(); dseg.Value = value; vseg = dseg; break; case "FLOAT": FloatSegment fseg = new FloatSegment(); fseg.Value = value; vseg = fseg; break; default: throw new ArgumentException(); } vseg.TimeStart = timestart; vseg.TimeEnd = timeend; sdmodel.Add(vseg); }
private void LoadXml(string filename, int timestart, int timeend) { XDocument xdoc = XDocument.Load(filename); XElement node_Root = xdoc.Element("SimuDatas"); IEnumerable <XElement> node_SDModels = node_Root.Elements("SimuDataNode"); foreach (XElement node_SDModel in node_SDModels) { string name = (string)(node_SDModel.Element("Name")); foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; if (sdmodel.Name.Equals(name)) { VChart.RemoveValue(sdmodel, timestart, timeend); sdmodel.LoadXml(node_SDModel, timestart, timeend); break; } } } VChart.UpdateChart(); }
private void OnInputKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { string name = NameTextInput.Text; Match m1 = Regex.Match(name, @"^\w+\d+$"); //Match m2 = Regex.Match(name, @"^\w+\[\d+\.\.\d+\]$"); //Match m3 = Regex.Match(name, @"^\w+\b\w+\d+$"); //Match m4 = Regex.Match(name, @"^\w+\b\w+\[\d+\.\.\d+\]$"); if (m1.Success) { SimulateDataModel _sdmodel = SimulateDataModel.Create(name); if (_sdmodel != null && SDModelSetup != null) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDModel_new = _sdmodel; //_e.SDVModel = this; Setup(_sdmodel); SDModelSetup(this, _e); } } } }
/// <summary> /// 变量数据模型解除监视时发生 /// </summary> /// <param name="sender">发送源</param> /// <param name="e">事件</param> private void OnSimulateDataModelUnview(object sender, SimulateDataModelEventArgs e) { SimulateDataModel sdmodel = e.SDModel_new; smanager.Unview(sdmodel); }
public SimulateDataViewModel(SimulateDataModel _sdmodel) { InitializeComponent(); Setup(_sdmodel); }
public void AddLast(SimulateDataModel sdmodel) { SimulateDataViewModel sdvmodel = new SimulateDataViewModel(sdmodel); AddLast(sdvmodel); }
public void Add(SimulateDataModel sdmodel, int id) { SimulateDataViewModel sdvmodel = new SimulateDataViewModel(sdmodel); Add(sdvmodel, id); }
public SimulateDataChartModel(SimulateDataModel _sdmodel, TimeRuler _truler) { InitializeComponent(); truler = _truler; Setup(_sdmodel); }
public void Setup(SimulateDataModel _sdmodel) { this.sdmodel = _sdmodel; Update(); }