Exemple #1
0
 public MonitorData(int id, int tickcount, byte[] data, MonitorDataType type)
 {
     _id        = id;
     _tickcount = tickcount;
     _type      = type;
     _data      = data;
 }
Exemple #2
0
        public MonitorFrame(byte[] buf)
        {
            if (buf.Length < frame_len)
            {
                return;
            }
            frame_head_tag = BitConverter.ToUInt16(buf, 0);
            if (frame_head_tag != 0xAA50)
            {
                return;
            }

            frame_sn     = BitConverter.ToUInt16(buf, 2);
            time_stamp   = BitConverter.ToUInt32(buf, 4);
            data_type    = (MonitorDataType)BitConverter.ToUInt16(buf, 8);
            series_state = (SeriesState)buf[10];
            cpu_state    = (CpuState)buf[11];
            data_length  = BitConverter.ToUInt16(buf, 12);

            crc = BitConverter.ToUInt16(buf, 14);

            UInt16 new_crc = Crc16.GetCrc(buf, 14);

            if (new_crc != crc)
            {
                return;
            }
            is_ok = true;
            return;
        }
 public void Add(string dtusn, byte[] data, MonitorDataType type)
 {
     if (_dlg != null && _dlg.IsVisible)
     {
         if (_dtuSn.CompareTo(dtusn) == 0)
         {
             _dlg.Add(data, type);
         }
     }
 }
 public void Add(byte[] data, MonitorDataType type)
 {
     System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
     {
         if (!_isPause)
         {
             DateTime timenow = DateTime.Now;
             if (_lasttime == DateTime.Parse("1/1/1970") || timenow < _lasttime)
             {
                 _lasttime = timenow;
             }
             TimeSpan ts             = timenow - _lasttime;
             MonitorData monitordata = new MonitorData(datas.Items.Count, (int)ts.TotalMilliseconds, data, type);
             datas.Items.Add(monitordata);
             ScrollToEnd();
         }
     });
 }