コード例 #1
0
ファイル: SqlConfig.cs プロジェクト: ymz000/kpgweigher
        private bool LoadConfigFromFile()
        {
            try
            {
                string CommandText;
                SetConnection();
                sql_con.Open();

                //retrieve current configure
                CommandText = "select id,value from data where grp='" + this.sql_grp + "' and tbl='" + this.sql_tbl + "'";
                DB          = new SQLiteDataAdapter(CommandText, sql_con);
                DS.Reset();
                DB.Fill(DS);
                foreach (DataRow dr in DS.Tables[0].Rows)
                {
                    curr_conf[dr[0].ToString()] = dr[1].ToString();
                }
                sql_con.Close();
                return(true);
            }
            catch (System.Exception e)
            {
                MsgDlg.Show(e.Message);
                return(false);
            }
        }
コード例 #2
0
        private void UpdateStatusBar(object sender, string msg)
        {
            if (msg == "newvalue")
            {
                RX_VAR rv = task.currRx.var;

                AddValue(task.currRx.iChan.ToString(), task.iMeasCnt, rv.rRx, 0, 0);

                lbl_aux1.Text    = UpdateDisplayReading(aux1_mode);
                lbl_aux2.Text    = UpdateDisplayReading(aux2_mode);
                lbl_bigdisp.Text = UpdateDisplayReading(bigdisp_mode);
                DeviceMgr.ReportData(task.iMeasCnt, rv.rRx);
                LogData(task.iMeasCnt, rv.rRx);

                /*
                 * statusBar1.total = syscfg.iMeasTimes;
                 * statusBar1.count = task.iMeasCnt;
                 */
            }
            else if (msg == "complete")
            {
                if (runstate.NumOfRunsLeft > 0)
                {
                    DoNextMeasure();
                }
                else
                {
                    if (Program.sysinfo.bThrow)
                    {
                        ThrowData();
                    }
                    LogComplete();
                    bt_run.Text    = StringResource.str("start");
                    btn_menu.Label = StringResource.str("menu");
                }
            }
            else
            {
                string txt = StringResource.str(msg);
                if (txt == msg)
                {
                    MsgDlg.Show(task.currRx.var.errMsg);
                }
                else
                {
                    bt_run.Text = txt;
                }
            }
        }
コード例 #3
0
 static Program()
 {
     msg        = new MsgDlg();
     kbd        = new kbdWnd();
     syswnd     = new SysConfigWnd();
     rxwnd      = new RxConfigWnd();
     rswnd      = new RsConfigWnd();
     choice     = new ChoiceWnd();
     lst_rxinfo = new List <RxInfo>();
     lst_rsinfo = new List <RsInfo>();
     for (int i = 0; i < 24; i++)
     {
         lst_rxinfo.Add(new RxInfo(i + 1));
         lst_rsinfo.Add(new RsInfo(i + 1));
     }
     DeviceMgr.Dummy();
 }
コード例 #4
0
ファイル: SqlConfig.cs プロジェクト: ymz000/kpgweigher
 private bool SaveConfigToFile(string id, string val)
 {
     try
     {
         //save the current configuration
         SetConnection();
         sql_con.Open();
         sql_cmd             = new SQLiteCommand();
         sql_cmd.Connection  = sql_con;
         sql_cmd.CommandText = "replace into data(id,value,grp,tbl) values('" + id + "','" + val + "','" + this.sql_grp + "','" + this.sql_tbl + "')";
         sql_cmd.ExecuteNonQuery();
         sql_con.Close();
         return(true);
     }
     catch (System.Exception e)
     {
         MsgDlg.Show(e.Message);
         return(false);
     }
 }
コード例 #5
0
        void statusBar1_StartStopClick(object sender, EventArgs e)
        {
            if (task.bRunning)
            {
                btn_menu.Label = StringResource.str("menu");
                bt_run.Text    = StringResource.str("start");
                status         = RUN_STATE.STOPPING;
                task.Stop();
                return;
            }

            btn_menu.Label = StringResource.str("pause");
            runstate.LoadScheme();
            if (runstate.NumOfRunsLeft <= 0)
            {
                MsgDlg.Show("No valid selection");
                return;
            }

            DoNextMeasure();
            Program.testdata.ClearAll();
        }
コード例 #6
0
        public void KbdData(string param, string data)
        {
            try
            {
                if (param == "newtime")
                {
                    if (!Regex.IsMatch(newdate, "^\\d\\d\\d\\d\\d\\d\\d\\d$"))
                    {
                        MsgDlg.Show("日期格式不正确, 请按格式20120131输入");
                        return;
                    }

                    if (!Regex.IsMatch(data, "^\\d\\d\\d\\d\\d\\d$"))
                    {
                        MsgDlg.Show("时间格式不正确, 请按格式235959输入");
                        return;
                    }
                    SystemTime time = new SystemTime();
                    time.wYear        = Convert.ToUInt16(newdate.Substring(0, 4));
                    time.wMonth       = Convert.ToUInt16(newdate.Substring(4, 2));
                    time.wDay         = Convert.ToUInt16(newdate.Substring(6, 2));
                    time.wHour        = Convert.ToUInt16(data.Substring(0, 2));
                    time.wMinute      = Convert.ToUInt16(data.Substring(2, 2));
                    time.wSecond      = Convert.ToUInt16(data.Substring(4, 2));
                    time.wMiliseconds = 0;
                    SetLocalTime(ref time);
                }
                if (param == "newdate")
                {
                    newdate = data;
                    this.Invoke(new Action(() =>
                    {
                        kbdWnd.Init(StringResource.str("enter_newdate"), "newdata", false, KbdData);
                    }));
                    return;
                }
                if (param == "ktt")
                {
                    Program.sysinfo.iKTT = Convert.ToInt32(data);
                }
                if (param == "measdelay")
                {
                    Program.sysinfo.iMeasDelay = Convert.ToInt32(data);
                }
                if (param == "sampletimes")
                {
                    Program.sysinfo.iSampleTimes = Convert.ToInt32(data);
                }
                if (param == "meastimes")
                {
                    Program.sysinfo.iMeasTimes = Convert.ToInt32(data);
                }
                if (param == "shifttimes")
                {
                    Program.sysinfo.iShiftTimes = Convert.ToInt32(data);
                }
                if (param == "fltlength")
                {
                    Program.sysinfo.iFilter = Convert.ToInt32(data);
                }
                if (param == "flttype")
                {
                    Program.sysinfo.sFilterType = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "navmeter")
                {
                    Program.sysinfo.sNavmeter = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "rsscanner")
                {
                    Program.sysinfo.sRsscanner = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "rxscanner")
                {
                    Program.sysinfo.sRxscanner = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }

                if (param == "throw")
                {
                    Program.sysinfo.bThrow = !Program.sysinfo.bThrow;
                }
                InitDisplay();
            }
            catch
            {
                MsgDlg.Show("数据格式不正确。");
            }
        }