Esempio n. 1
0
        //定时器刷新
        private void timer_Tick_1(object sender, EventArgs e)
        {
            DeviceBll device = DeviceObj.GetDevice();

            //通讯状态实在
            if (device == null)
            {
                return;
            }


            if (device.Device.ComState == Model_Data.CommunicateEntity.DivCommStateEnum.Success) //通讯成功,则开始画图
            {
                lbComState.Text        = Model_Data.Language.EaSolar.Connected;                  //2
                lbComState.ForeColor   = Color.Green;
                btnPauseResume.Enabled = true;
                TimeDrawLine();
            }
            else if (device.Device.ComState == Model_Data.CommunicateEntity.DivCommStateEnum.Failed)
            {
                lbComState.Text        = Model_Data.Language.EaSolar.Disconnected;//3
                btnPauseResume.Enabled = false;
                lbComState.ForeColor   = Color.Red;
            }
            else//通讯失败,突出显示
            {
                lbComState.Text        = Model_Data.Language.EaSolar.UnConnect;//1
                btnPauseResume.Enabled = false;
                lbComState.ForeColor   = Color.Gray;
            }
        }
Esempio n. 2
0
        //定时器刷新
        private void timer_RTValue_Tick(object sender, EventArgs e)
        {
            DeviceBll   device = DeviceObj.GetDevice();
            DeviceModel dm     = DeviceObj.GetDeviceModel();

            if (device == null)
            {
                return;
            }
            //视图界面更新
            UIOffGrid.SetParaMeter(device, dm);
        }
Esempio n. 3
0
        private bool send(short address, byte[] data)
        {
            CommDeviceModbuseControlEntity command = new CommDeviceModbuseControlEntity();

            command.DivID           = DeviceObj.GetDevice().Device.UnitId;
            command.functioncode    = FunctionCode.WriteSingleRegister;
            command.SetInfoStartAdr = address;
            command.RegisterLen     = 2;
            command.SetData         = data;
            DeviceObj.GetWrapper().sendCommand(command);
            return(command.IsSuccess);
        }
Esempio n. 4
0
        // 初始化 信号 下拉框 只显示变化的数字量,过滤掉常量和字符量
        private void LoadSignalNameCombobox()
        {
            cbSignalName.Properties.Items.Clear();
            DeviceBll dbll = DeviceObj.GetDevice();

            if (dbll == null)
            {
                return;
            }
            foreach (AnalogBll item in dbll.AnalogList)
            {
                if (item.AnalogInfo.AnalogReadFrequency != AnalogReadFrequency.EveryTime)
                {
                    continue;
                }
                if (!item.AnalogInfo.SignalType.Contains("decimal") && item.AnalogInfo.SignalType != "long")
                {
                    continue;
                }
                string SignalName = item.AnalogInfo.SignalName;
                cbSignalName.Properties.Items.Add(SignalName);
            }
            cbSignalName.SelectedIndex = 0;
        }
Esempio n. 5
0
        private void TimeDrawLine()
        {
            if (chartControl1.Series.Count < 1)
            {
                return;
            }
            //构建 表格,用于绑定
            AnalogBll al = DeviceObj.GetDevice().AnalogList.Find(delegate(AnalogBll abll) { return(abll.AnalogInfo.SignalName == cbSignalName.Text ? true : false); });
            object   svalue = al.AnalogInfo.Value;
            DateTime dtime  = DateTime.Now;

            //如果图中最后一个点 的时间 是最新一个点的时间,则直接返回
            if (chartControl1.Series[0].Points.Count > 0)
            {
                if (PreTime != null)
                {
                    if (PreTime == dtime)
                    {
                        return;
                    }
                }
            }
            //否则,将最新点的时间 记录下来
            PreTime = dtime;

            DateTime argument = PreTime;

            DateTime minDate = argument.AddSeconds(-TimeInterval);
            //需要移除的点个数
            int pointsToRemoveCount = 0;

            //如果 某个点的时间小于坐标轴最小时间,则+1
            foreach (SeriesPoint point in chartControl1.Series[0].Points)
            {
                if (point.DateTimeArgument < minDate)
                {
                    pointsToRemoveCount++;
                }
            }
            //如果 ........?
            if (pointsToRemoveCount < chartControl1.Series[0].Points.Count)
            {
                pointsToRemoveCount--;
            }

            SeriesPoint pointsToUpdate = new SeriesPoint(argument, svalue);//Convert.ToDouble(String.Format("{0:F}", Dr[0]["信号值"]))

            //将最新点 添加到显示序列
            chartControl1.Series[0].Points.Add(pointsToUpdate);

            if (pointsToRemoveCount > 0)
            {
                chartControl1.Series[0].Points.RemoveRange(0, pointsToRemoveCount);
            }
            SwiftPlotDiagram diagram = chartControl1.Diagram as SwiftPlotDiagram;

            if (diagram != null && diagram.AxisX.DateTimeMeasureUnit == DateTimeMeasurementUnit.Millisecond)
            {
                diagram.AxisX.Range.SetMinMaxValues(minDate, argument);
            }

            diagram.EnableAxisYScrolling = true;
            diagram.EnableAxisYZooming   = true;
        }