Exemplo n.º 1
0
        private void ShowState()
        {
            DeviceModel DE = DeviceObj.GetDeviceModel();

            lbPort.Caption     = DE.Port.PortName;
            lbInterval.Caption = (DE.Port.ScanningTime / 1000).ToString() + "(s)";
        }
Exemplo n.º 2
0
        //
        private void btOK_Click(object sender, EventArgs e)
        {
            DateTime BeginDate = DtBegin.DateTime.Date + teBegin.Time.TimeOfDay;
            DateTime EndDate   = deEnd.DateTime.Date + teEnd.Time.TimeOfDay;

            if (BeginDate > EndDate)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Desc.SelStartTime, Model_Data.Language.Desc.Warning_ChildUserTab);//modified by zq
            }
            else
            {
                try
                {
                    DeviceModel dm        = DeviceObj.GetDeviceModel();
                    DataTable   dataTable = ACCESSDBDAL.AccessServer.GetHistoricData(BeginDate, EndDate, dm.TableName);
                    ReplaceColumnName(dataTable);
                    GridView_HistoricTable.DataSource = dataTable;
                    Table_Report = dataTable;
                    gridView1.Columns[Model_Data.Language.PublicInfo.DateTime].Width = 130;
                    gridView1.OptionsView.ColumnAutoWidth = false;
                    gridView1.Columns[Model_Data.Language.PublicInfo.DateTime].DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss ";
                }
                catch (Exception str)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("获取数据失败!原因如下:\r\n"+str, "警告");
                    DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Desc.ObtainFailure + "\r\n" + str, Model_Data.Language.Desc.Warning_ChildUserTab);//modified by zq
                }
            }
        }
Exemplo n.º 3
0
        //初始化 信号 下拉框
        public void LoadData()
        {
            cbSignalName.Properties.Items.Clear();
            DeviceModel dbll = DeviceObj.GetDeviceModel();

            if (dbll == null)
            {
                return;
            }
            foreach (AnalogModel item in dbll.Analog)
            {
                if (item.AnalogReadFrequency != AnalogReadFrequency.EveryTime)
                {
                    continue;
                }
                if (!item.SignalType.Contains("decimal") && item.SignalType != "long")
                {
                    continue;
                }
                if (!item.ISRecord)
                {
                    continue;
                }
                cbSignalName.Properties.Items.Add(item.SignalName);
            }
            cbSignalName.SelectedIndex = 0;
        }
Exemplo n.º 4
0
        //根据条件填充实体,并显示
        private void InitionPortDevice()
        {
            DeviceModel dobj = DeviceObj.GetDeviceModel();
            TcpModel    TCPE = dobj.Port.TCP;
            SerialModel SE   = dobj.Port.Serial;

            if (dobj == null || TCPE == null || SE == null)
            {
                return;
            }
            //显示 端口值
            switch (dobj.Port.PortType)
            {
            case Protocol.Modbus_TCPIPPort: cb_Port.Text = "TCP/IP"; break;

            case Protocol.Modbus_SerialPort: cb_Port.Text = SE.PortName; break;

            case Protocol.Modbus_USBPort: cb_Port.Text = "USB"; break;

            default: break;
            }
            tb_IPadr.Text   = TCPE.IP;
            tb_TCPport.Text = TCPE.Port.ToString();

            cb_BaudRate.Text   = SE.BaudRate.ToString();
            cb_Word.Text       = SE.DataBit.ToString();
            cb_Parit.EditValue = ((int)SE.Parity).ToString();
            cb_stop.EditValue  = ((int)SE.StopBit).ToString();
            tb_WaitTime.Text   = SE.RecoveryWaitTime.ToString();
        }
Exemplo n.º 5
0
 //
 public AutoSearchAddr()
 {
     InitializeComponent();
     LoadLanguageInfo();
     adr_variable      = DeviceObj.GetWrapper().DeviceList[0].Device.UnitId;//记录原先的设备地址
     bt_Finish.Enabled = false;
 }
Exemplo n.º 6
0
        //搜索/停止
        private void bt_SearchDevice_Click(object sender, EventArgs e)
        {
            if (bt_SearchDevice.Text == Model_Data.Language.ChildForm.SearchDev)
            {
                bt_SearchDevice.Text = Model_Data.Language.ChildForm.Termination;
                bt_Finish.Enabled    = false;
                cb_adr.Properties.Items.Clear();

                SearcheThread = new Thread(ThreadWork);
                SearcheThread.Start(adr_variable);
            }
            else
            {
                //终止线程
                SearcheThread.Abort();
                SearcheThread.Join();
                DeviceObj.GetWrapper().ReCommunication();
                //恢复内存现场
                DeviceObj.GetWrapper().DeviceList[0].Device.UnitId = (byte)adr_variable;
                Communication.CommandCreat.CreatDeviceCommandList(DeviceObj.GetWrapper().Port.PortType, DeviceObj.GetWrapper().DeviceList[0]);

                marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.SearchEnd;
                list_Info.Items.Add(Model_Data.Language.ChildForm.SearchEnd);
                list_Info.SelectedIndex = list_Info.ItemCount - 1;

                //改变文字
                bt_SearchDevice.Text = Model_Data.Language.ChildForm.SearchDev;

                //是否可以应用地址
                if (cb_adr.Properties.Items.Count > 0)
                {
                    bt_Finish.Enabled = true;
                }
            }
        }
Exemplo n.º 7
0
        //确定按键
        private void bt_Confirm_Click(object sender, EventArgs e)
        {
            if (!dxValidation_NoNull.Validate())
            {
                XtraMessageBox.Show(Model_Data.Language.Serial_Info_Set.NoEmptyStr);//modified by zq
                return;
            }
            //更新
            try
            {
                DM.Port.PortName        = tb_PortName.Text;
                DM.Port.Description     = tb_Decribe.Text;
                DM.Port.ScanningTime    = Convert.ToInt32(tb_PollTime.Text);
                DM.Port.OverTime        = Convert.ToInt32(tb_Timeout.Text);
                DM.Port.ReconnectNumber = Convert.ToInt32(tb_ReconNum.Text);
                DM.Port.RecoveryTime    = Convert.ToInt32(tb_RecoverTime.Text);
                DM.Port.ReadOverTime    = Convert.ToInt32(tb_ReadTimeout.Text);
                DM.Port.WriteOverTime   = Convert.ToInt32(tb_WriteTimeout.Text);

                DM.DeviceName  = tb_DeviceName.Text;
                DM.UnitId      = (byte)Convert.ToInt32(cb_DeviceAddr.Text);
                DM.WriteDBTime = Convert.ToInt32(tb_WriteToDBtime.Text);
                DeviceObj.UpdateDevice(DM);
            }
            catch (Exception er_upDevice)
            {
                XtraMessageBox.Show(er_upDevice.ToString());
            }
            this.Close();
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
        //
        private void Form1_Load(object sender, EventArgs e)
        {
            //1.初始化基本信息
            MainContent1.LoadData();

            //2.初始化 一些事件订阅(回调函数)
            DeviceObj.RegistEventCallback(ShowAlarm);

            WorkStart(false);//第一次载入的时候开始通讯
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        private void btStop_ItemClick(object sender, ItemClickEventArgs e)
        {
            btStop.Enabled = false;//否能 停止通讯

            //停止轮询
            DeviceObj.StopPoll();

            lbEvent.Caption   = string.Empty;
            btSetting.Enabled = true;
            btStart.Enabled   = true; //使能 开始通讯
            btQuery.Enabled   = true; //使能 地址搜索
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        private void btStart_ItemClick(object sender, ItemClickEventArgs e)
        {
            btStart.Enabled = false;
            btStop.Enabled  = false;

            //开启轮询
            DeviceObj.StartPoll();

            btSetting.Enabled = false;
            btStop.Enabled    = true;  //使能 停止通讯
            btQuery.Enabled   = false; //否能 地址搜索
        }
Exemplo n.º 14
0
        //设置遥控量部分
        private void SetInfoFunction(object SetInfo)
        {
            CommDeviceModbuseControlEntity TempEntity;

            if (SetInfo is CommDeviceModbuseControlEntity)
            {
                TempEntity = (CommDeviceModbuseControlEntity)SetInfo;
                if (EASolar_Info != null)
                {
                    TempEntity.DivID = EASolar_Info.UnitId;
                    DeviceObj.SetInfoFunction(TempEntity);
                }
            }
        }
Exemplo n.º 15
0
        private void WorkStart(bool isReload)
        {
            btStart.Enabled = false;
            btStop.Enabled  = false;

            if (isReload)
            {
                DeviceObj.ReLoad();
            }
            //开启轮询
            DeviceObj.StartPoll();

            ShowState();

            btSetting.Enabled = false;
            btStop.Enabled    = true;  //使能 停止通讯
            btQuery.Enabled   = false; //否能 地址搜索
        }
Exemplo n.º 16
0
        //初始化
        public void LoadData()
        {
            //初始化 信号框
            LoadSignalNameCombobox();

            //将定时器刷新时间 设定为端口扫描时间
            int ScanTime     = DeviceObj.GetDeviceModel().Port.ScanningTime;
            int pollInterval = ScanTime / 1000;//获取端口轮询时间(单位:秒)

            //设定X轴最小时间间隔
            //最大点数:1000点  最小点数:100点  增加间隔:1点
            spnTimeInterval.Properties.MinValue  = pollInterval * 100;
            spnTimeInterval.Properties.MaxValue  = pollInterval * 1000;
            spnTimeInterval.Properties.Increment = pollInterval;
            spnTimeInterval.EditValue            = pollInterval * 200; //默认显示200个点

            timer.Interval = ScanTime;                                 //将定时器 时间设定为 扫描时间
        }
Exemplo n.º 17
0
        //构造函数
        public AdvancedOptionForm()
        {
            InitializeComponent();
            LoadLanguageFunction();
            InitionDeviceAddressBox();

            //绑定
            DM = DeviceObj.GetDeviceModel();
            if (DM == null)
            {
                MessageBox.Show("Get Data Faild!");//这些代码应该永远不会被执行
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                this.Close();
            }
            else
            {
                LoadData();
            }
        }
Exemplo n.º 18
0
        //应用 新的设备地址
        private void bt_Finish_Click(object sender, EventArgs e)
        {
            //更新 地址到数据库
            marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.RenewDB;
            int         address = Convert.ToInt32(cb_adr.Text);
            DeviceModel de      = DeviceObj.GetDeviceModel();

            de.UnitId = (byte)address;
            DeviceObj.UpdateDevice(de);

            //更新内存:重新创建查询命令
            DeviceObj.GetWrapper().DeviceList[0].Device.UnitId = (byte)address;
            Communication.CommandCreat.CreatDeviceCommandList(DeviceObj.GetWrapper().Port.PortType, DeviceObj.GetWrapper().DeviceList[0]);

            //更新显示
            marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.StartNewAddr;
            list_Info.Items.Add(Model_Data.Language.ChildForm.StartNewAddr);
            list_Info.SelectedIndex = list_Info.ItemCount - 1;
        }
Exemplo n.º 19
0
        private void ReplaceColumnName(DataTable valueTable)
        {
            valueTable.Columns.Remove("KeyId");
            valueTable.Columns[0].ColumnName = (Model_Data.Language.PublicInfo.DateTime);
            DeviceModel dm = DeviceObj.GetDeviceModel();

            if (dm == null)
            {
                return;
            }
            int i = 1;

            foreach (AnalogModel item in dm.Analog)
            {
                if (!item.ISRecord)
                {
                    continue;
                }
                valueTable.Columns[i].ColumnName = string.Format("{0}({1})", item.SignalName, item.SignalUnit);
                i++;
            }
        }
Exemplo n.º 20
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;
        }
Exemplo n.º 21
0
        //还原为最初状态
        public void Inition()
        {
            foreach (Control item in tableLayoutPanel2.Controls)
            {
                if (item is System.Windows.Forms.Button)
                {
                    ((Button)item).Text = "0";
                }
            }
            foreach (Control item in tableLayoutPanel3.Controls)
            {
                if (item is System.Windows.Forms.Button)
                {
                    ((Button)item).Text = "0";
                }
            }

            DeviceModel dm = DeviceObj.GetDeviceModel();

            if (dm == null)
            {
                return;
            }

            List <AnalogModel> AnalogArray = dm.Analog;

            //AC输入电压
            label2.Text = AnalogArray[1].SignalName;

            //逆变输出电压
            label5.Text = AnalogArray[2].SignalName;


            //AC输入频率
            label9.Text = AnalogArray[3].SignalName;

            //--------------------------------------------

            //PV输入电压
            label10.Text = AnalogArray[6].SignalName;

            //负载百分比
            label11.Text = AnalogArray[4].SignalName;

            //电池容量百分比
            label12.Text = AnalogArray[9].SignalName;

            //PV充电电流
            label13.Text = AnalogArray[7].SignalName;

            //额定电压
            label14.Text = AnalogArray[18].SignalName;

            //额定电池额定
            label15.Text = AnalogArray[17].SignalName;

            //--------------------------------------------

            //产品类型
            label16.Text = AnalogArray[15].SignalName;

            //产品规格型号
            label17.Text = AnalogArray[16].SignalName;

            //充电电流等级
            label18.Text = AnalogArray[19].SignalName;

            //通讯版本号
            label19.Text = AnalogArray[25].SignalName;

            //控制版本号
            label20.Text = AnalogArray[0].SignalName;
        }
Exemplo n.º 22
0
        //搜索执行
        private void ThreadWork(object adrr)
        {
            //如果有数据 则轮询所有设备
            for (int i = 1; i < 256; i++)
            {
                DeviceObj.GetWrapper().DeviceList[0].Device.UnitId = (byte)i;
                Communication.CommandCreat.CreatDeviceCommandList(DeviceObj.GetWrapper().Port.PortType, DeviceObj.GetWrapper().DeviceList[0]);
                int result = DeviceObj.GetWrapper().PollTest();
                //Thread.Sleep(10);
                if (result == -1)//如果端口无法打开,则直接退出
                {
                    Invoke((MethodInvoker) delegate()
                    {
                        marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.PortOpenFail;
                        list_Info.Items.Add(Model_Data.Language.ChildForm.PortOpenFail);
                        list_Info.SelectedIndex = list_Info.ItemCount - 1;
                    });
                    break;
                }
                else if (result == 0)//通讯失败
                {
                    Invoke((MethodInvoker) delegate()
                    {
                        marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.Addr + i.ToString() + Model_Data.Language.ChildForm.ConnFail;
                    });
                }
                else if (result > 0)//通讯成功
                {
                    Invoke((MethodInvoker) delegate()
                    {
                        marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.Addr + i.ToString() + " " + Model_Data.Language.ChildForm.ConnSucc;
                        list_Info.Items.Add(Model_Data.Language.ChildForm.Addr + i.ToString() + Model_Data.Language.ChildForm.ConnSucc);
                        list_Info.SelectedIndex = list_Info.ItemCount - 1;
                        cb_adr.Properties.Items.Add(i);
                        cb_adr.Text = i.ToString();
                    });
                }
            }
            //还原以前的状态
            DeviceObj.GetWrapper().DeviceList[0].Device.UnitId = (byte)adr_variable;
            Communication.CommandCreat.CreatDeviceCommandList(DeviceObj.GetWrapper().Port.PortType, DeviceObj.GetWrapper().DeviceList[0]);
            //搜索完成
            Invoke((MethodInvoker) delegate()
            {
                marqueeProgressBarControl1.Text = Model_Data.Language.ChildForm.TestComplete;
                list_Info.Items.Add(Model_Data.Language.ChildForm.TestComplete);
                list_Info.SelectedIndex = list_Info.ItemCount - 1;

                bt_SearchDevice.Text = Model_Data.Language.ChildForm.SearchDev;
                bt_Finish.Enabled    = true;
                if (cb_adr.Properties.Items.Count > 0)
                {
                    cb_adr.SelectedIndex = 0;
                }
                else
                {
                    cb_adr.SelectedIndex = -1;
                    bt_Finish.Enabled    = false;
                }
            });
        }
Exemplo n.º 23
0
        private void btOK_Click(object sender, EventArgs e)
        {
            DevExpress.XtraCharts.LineSeriesView lineSeriesView = new DevExpress.XtraCharts.LineSeriesView();

            DateTime BeginDate = DtBegin.DateTime.Date + teBegin.Time.TimeOfDay;
            DateTime EndDate   = deEnd.DateTime.Date + teEnd.Time.TimeOfDay;

            if (BeginDate > EndDate)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Desc.SelStartTime, Model_Data.Language.Desc.Warning_ChildUserTab);//modified by zq
                return;
            }
            DeviceModel dm = DeviceObj.GetDeviceModel();

            if (dm == null)
            {
                return;
            }
            string Value = "sid" + (dm.Analog.Find(delegate(AnalogModel ab) { return(ab.SignalName == cbSignalName.Text); })).SignalId.ToString();

            try
            {
                DataTable DT = ACCESSDBDAL.AccessServer.GetHistoricData(BeginDate, EndDate, dm.TableName);
                if (DT == null || DT.Rows.Count < 1)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("该时间段内不存在数据记录!", "提示");
                    DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Desc.TimeNotData, Model_Data.Language.Desc.Prompting_ChildUserTab);//modified by zq
                    return;
                }
                BeginDate = Convert.ToDateTime(DT.Rows[0]["dtime"].ToString());
                EndDate   = Convert.ToDateTime(DT.Rows[DT.Rows.Count - 1]["dtime"].ToString());
                TimeSpan TimeSpan = EndDate - BeginDate;
                //开始调配 曲线资源
                //清理以前的数据
                hSeries.DataSource = null;
                //1.为 序列绑定信号值名称
                hSeries.Name = cbSignalName.Text;
                //2.X轴的数据字段
                hSeries.ArgumentDataMember = "dtime";
                //3.Y轴的数据字段
                hSeries.ValueDataMembers[0] = Value;
                //4.标签可视化设置
                //hSeries.LabelsVisibility = DevExpress.Utils.DefaultBoolean.Default;
                //5.参数刻度类型
                hSeries.ArgumentScaleType = ScaleType.DateTime;

                AxisBase axis = Diagram.AxisX;
                AxisBase ayis = Diagram.AxisY;
                axis.DateTimeOptions.Format = DateTimeFormat.Custom;
                //根据 实际数据的时间跨度 来设定 X轴的时间跨度
                DateTimeAlignment(TimeSpan, axis);
                //X轴刻度 范围
                axis.GridLines.Visible        = true;
                axis.Range.SideMarginsEnabled = false;//设定X轴从0开始
                axis.GridSpacingAuto          = false;

                //Y轴的相关设定
                ayis.Range.Auto      = true;
                ayis.GridSpacingAuto = true;
                //ayis.Range.AlwaysShowZeroLevel = false;
                //绑定数据
                try
                {
                    hSeries.DataSource = DT;
                }
                catch (Exception)
                {
                    MessageBox.Show("Faild to DataBinding!");
                }
                //设置 Y轴 可自行收缩
                Diagram.EnableAxisYScrolling = true;
                Diagram.EnableAxisYZooming   = true;
            }
            catch (Exception str)
            {
                //DevExpress.XtraEditors.XtraMessageBox.Show("获取数据失败!原因如下:/r/n" + str, "错误");
                DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Desc.ObtainFailure + "/r/n" + str, Model_Data.Language.Desc.Fault_ChildUserTab);//modified by zq
            }
        }
Exemplo n.º 24
0
        //按键:确认
        private void bt_Confirm_Click(object sender, EventArgs e)
        {
            DeviceModel dm = DeviceObj.GetDeviceModel();

            if (dm == null)
            {
                return;
            }
            PortModel PE = dm.Port;

            PE.PortName = cb_Port.Text;

            if (group_tcp.Enabled)
            {
                PE.PortType = Protocol.Modbus_TCPIPPort;
            }
            else if (group_serial.Enabled)
            {
                PE.PortType = Protocol.Modbus_SerialPort;
            }
            else
            {
                PE.PortType = Protocol.Modbus_USBPort;
            }

            if (tb_IPadr.Text == string.Empty || tb_TCPport.Text == string.Empty)
            {
                XtraMessageBox.Show(Model_Data.Language.Serial_Info_Set.NoEmptyStr);
                return;
            }
            PE.TCP.IP   = tb_IPadr.Text;
            PE.TCP.Port = Convert.ToInt32(tb_TCPport.Text);

            if (tb_WaitTime.Text == string.Empty)
            {
                XtraMessageBox.Show(Model_Data.Language.Serial_Info_Set.NoEmptyStr);
                return;
            }
            if (Convert.ToInt32(tb_WaitTime.Text) > PE.ScanningTime)
            {
                string er_scan_wait = string.Format(Model_Data.Language.Serial_Info_Set.WaitAndScanningTimeInfo1 + "{0}ms\r\n" + Model_Data.Language.Serial_Info_Set.WaitAndScanningTimeInfo2 + "{1}ms\r\n" + Model_Data.Language.Serial_Info_Set.WaitAndScanningTimeInfo3, PE.ScanningTime, tb_WaitTime.Text);
                XtraMessageBox.Show(er_scan_wait, Model_Data.Language.Serial_Info_Set.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            PE.Serial.PortName         = cb_Port.Text;
            PE.Serial.Parity           = (System.IO.Ports.Parity)Convert.ToInt32(cb_Parit.EditValue);
            PE.Serial.StopBit          = (System.IO.Ports.StopBits)Convert.ToInt32(cb_stop.EditValue);
            PE.Serial.DataBit          = Convert.ToInt32(cb_Word.Text);
            PE.Serial.BaudRate         = Convert.ToInt32(cb_BaudRate.Text);
            PE.Serial.RecoveryWaitTime = Convert.ToInt32(tb_WaitTime.Text);

            if (DeviceObj.UpdateDevice(dm))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(Model_Data.Language.Serial_Info_Set.FailSelection);
                this.DialogResult = System.Windows.Forms.DialogResult.No;
                this.Close();
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            //1.防止软件重复启动
            bool result;
            var  mutex = new System.Threading.Mutex(true, "7CC5E20A-8572-4D6E-919A-FDAB6331D0BB", out result);

            if (!result)
            {
                MessageBox.Show("program has opened!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DevExpress.Skins.SkinManager.EnableFormSkins();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");

            //如果是第一次运行,则读取语言配置信息,并修改配置
            //配置完成以后,设置第一次运行标志位
            string Inition = ConfigurationManager.AppSettings["Inition"];

            if (Inition == "No")
            {
                System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                string cnfile = Application.StartupPath + "\\DeviceCN.xml";           //中文配置文件
                string enfile = Application.StartupPath + "\\DeviceEN.xml";           //英文配置文件
                if (!System.IO.File.Exists(cnfile) && !System.IO.File.Exists(enfile)) //都不存在
                {
                    MessageBox.Show("cannot find configfile!");
                    return;
                }
                if (System.IO.File.Exists(cnfile) && System.IO.File.Exists(enfile))//都存在
                {
                    //语言版本设置为英文
                    //config.AppSettings.Settings["Culture"].Value = "EN";
                    config.AppSettings.Settings["Culture"].Value = "CN";
                }
                else if (System.IO.File.Exists(enfile))//只存在英文
                {
                    //语言版本设置为英文
                    config.AppSettings.Settings["Culture"].Value = "EN";
                }
                else if (System.IO.File.Exists(cnfile))//只存在中文
                {
                    //语言版本设置为中文
                    config.AppSettings.Settings["Culture"].Value = "CN";
                }
                //更新初始化状态
                config.AppSettings.Settings["Inition"].Value = "Yes";
                //重新载入
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
            }


            //convert
            SolarMonitor.SolarSchedule.ScheduleManager manager = SolarMonitor.SolarSchedule.ScheduleManager.getInstance();
            manager.loadTask();
            manager.start();

            //
            string culture = ConfigurationManager.AppSettings["Culture"];

            if (string.IsNullOrEmpty(culture))
            {
                culture = "CN";
            }
            string lanPathName = Application.StartupPath + "\\" + culture + ".xml";        //路径

            Model_Data.Language.LoadLanguageEntity.LoadLanguageInfo(culture, lanPathName); //mark_zq

            //载入数据,如果不成功则直接退出程序
            if (!DeviceObj.Inition())
            {
                MessageBox.Show("Get Data Faild!");
                return;
            }

            Application.Run(new SolarMonitor.MainForm.Smachine());

            manager.stop();
            ACCESSDBDAL.AccessDbHelper.DisposeConn();//断开数据库连接
        }
Exemplo n.º 26
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;
        }