Example #1
0
 /// <summary>
 /// 监视一个视点
 /// </summary>
 /// <param name="sdmodel">视点模型</param>
 public void View(SimulateDataModel sdmodel)
 {
     if (!viewsdmodels.Contains(sdmodel))
     {
         viewsdmodels.Add(sdmodel);
     }
 }
Example #2
0
 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;
     }
 }
Example #3
0
        public void CursorRemoveValue(SimulateDataModel sdmodel)
        {
            int timestart = (int)(CursorTimeStart());
            int timeend   = (int)(CursorTimeEnd());

            RemoveValue(sdmodel, timestart, timeend);
        }
Example #4
0
        public void CursorSetValue(SimulateDataModel sdmodel, object value)
        {
            int timestart = (int)(CursorTimeStart());
            int timeend   = (int)(CursorTimeEnd());

            SetValue(sdmodel, value, timestart, timeend);
        }
Example #5
0
 /// <summary>
 /// 解除监视一个视点
 /// </summary>
 /// <param name="sdmodel"></param>
 public void Unview(SimulateDataModel sdmodel)
 {
     if (viewsdmodels.Contains(sdmodel))
     {
         viewsdmodels.Remove(sdmodel);
     }
 }
Example #6
0
 /// <summary>
 /// 解锁一个视点
 /// </summary>
 /// <param name="sdmodel">视点模型</param>
 public void Unlock(SimulateDataModel sdmodel)
 {
     if (locksdmodels.Contains(sdmodel))
     {
         locksdmodels.Remove(sdmodel);
         SetEnable(sdmodel.Name, 1, 0);
     }
 }
Example #7
0
 /// <summary>
 /// 锁定一个视点
 /// </summary>
 /// <param name="sdmodel">视点模型</param>
 public void Lock(SimulateDataModel sdmodel)
 {
     if (!locksdmodels.Contains(sdmodel))
     {
         locksdmodels.Add(sdmodel);
         SetEnable(sdmodel.Name, 1, 1);
     }
 }
Example #8
0
        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);
                }
            }
        }
Example #9
0
 public SimulateDataViewModel()
 {
     InitializeComponent();
     sdmodel = null;
     MainCanva.Children.Remove(NameTextBlock);
     LockFlag.Visibility  = Visibility.Hidden;
     ViewFlag.Visibility  = Visibility.Hidden;
     NameTextInput.KeyUp += OnInputKeyUp;
 }
Example #10
0
        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();
        }
Example #11
0
 private void OnRunDataFinished(object sender, SimulateDataModelEventArgs e)
 {
     foreach (SimulateDataChartModel sdcmodel in SDCModels)
     {
         SimulateDataModel sdmodel = sdcmodel.SDModel;
         if (sdmodel.IsView)
         {
             sdcmodel.Update();
         }
     }
 }
Example #12
0
 public void View(SimulateDataModel sdmodel)
 {
     UpdateStop();
     if (!vddict.ContainsKey(sdmodel.Name))
     {
         vddict.Add(sdmodel.Name, sdmodel);
         //sdmodel.IsView = true;
         dllmodel.View(sdmodel);
     }
     UpdateStart();
 }
Example #13
0
 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);
     }
 }
Example #14
0
 public void Unlock(SimulateDataModel sdmodel)
 {
     UpdateStop();
     if (lddict.ContainsKey(sdmodel.Name))
     {
         lddict.Remove(sdmodel.Name);
         //sdmodel.IsLock = false;
         dllmodel.Unlock(sdmodel);
     }
     UpdateStart();
 }
Example #15
0
 public void Unview(SimulateDataModel sdmodel)
 {
     UpdateStop();
     if (vddict.ContainsKey(sdmodel.Name))
     {
         vddict.Remove(sdmodel.Name);
         //sdmodel.IsView = false;
         dllmodel.Unview(sdmodel);
     }
     UpdateStart();
 }
Example #16
0
 public void Lock(SimulateDataModel sdmodel)
 {
     UpdateStop();
     if (!lddict.ContainsKey(sdmodel.Name))
     {
         lddict.Add(sdmodel.Name, sdmodel);
         //sdmodel.IsLock = true;
         dllmodel.Lock(sdmodel);
     }
     UpdateStart();
 }
Example #17
0
        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);
        }
Example #18
0
        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);
        }
Example #19
0
        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;
            }
        }
Example #20
0
        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);
                }
            }
        }
Example #21
0
        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);
            }
        }
Example #22
0
        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);
        }
Example #23
0
        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();
        }
Example #24
0
 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);
             }
         }
     }
 }
Example #25
0
        /// <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);
        }
Example #26
0
 public SimulateDataViewModel(SimulateDataModel _sdmodel)
 {
     InitializeComponent();
     Setup(_sdmodel);
 }
Example #27
0
        public void AddLast(SimulateDataModel sdmodel)
        {
            SimulateDataViewModel sdvmodel = new SimulateDataViewModel(sdmodel);

            AddLast(sdvmodel);
        }
Example #28
0
        public void Add(SimulateDataModel sdmodel, int id)
        {
            SimulateDataViewModel sdvmodel = new SimulateDataViewModel(sdmodel);

            Add(sdvmodel, id);
        }
Example #29
0
 public SimulateDataChartModel(SimulateDataModel _sdmodel, TimeRuler _truler)
 {
     InitializeComponent();
     truler = _truler;
     Setup(_sdmodel);
 }
Example #30
0
 public void Setup(SimulateDataModel _sdmodel)
 {
     this.sdmodel = _sdmodel;
     Update();
 }