コード例 #1
0
 /// <summary>
 /// Start or stop the timer depending upon the current state.
 /// </summary>
 private void btnStartStopTimer_Click(object sender, RoutedEventArgs e)
 {
     if (DataTimer.IsEnabled)
     {
         DataTimer.Stop();
         btnStartStopTimer.Content = "Start";
     }
     else
     {
         DataTimer.Start();
         btnStartStopTimer.Content = "Stop";
     }
 }
コード例 #2
0
ファイル: frmMonitor.cs プロジェクト: msuksan/piyawin
        private void LoadData()
        {
            try
            {
                DataRow row = dataManager.RetriveNowData("01");
                if (row != null)
                {
                    //AlertPowerAC = (ObjFloat(row["power"]) < al.MinPowerAC || ObjFloat(row["power"]) > al.MaxPowerAC) ? true : false;
                    //lbPowerAC.BackColor = (AlertPowerAC) ? BackColorAlarm : BackColorNormal;
                    //lbPowerAC.ForeColor = (AlertPowerAC) ? ForeColorAlarm : ForeColorNormal;
                    //lbPowerAC.Text = ObjString(row["power"]);

                    //AlertCurrentAC = (ObjFloat(row["current"]) < al.MinCurrentAC || ObjFloat(row["current"]) > al.MaxCurrentAC) ? true : false;
                    //lbCurrentAC.BackColor = (AlertCurrentAC) ? BackColorAlarm : BackColorNormal;
                    //lbCurrentAC.ForeColor = (AlertCurrentAC) ? ForeColorAlarm : ForeColorNormal;
                    //lbCurrentAC.Text = ObjString(row["current"]);

                    AlertVoltAC    = (ObjFloat(row["VG"]) < al.MinVoltAC || ObjFloat(row["VG"]) > al.MaxVoltAC) ? true : false;
                    lbVG.BackColor = (AlertVoltAC) ? BackColorAlarm : BackColorNormal;
                    lbVG.ForeColor = (AlertVoltAC) ? ForeColorAlarm : ForeColorNormal;
                    lbVG.Text      = ObjString(row["VG"]);

                    AlertCurrentAC = (ObjFloat(row["IG"]) < al.MinCurrentAC || ObjFloat(row["IG"]) > al.MaxCurrentAC) ? true : false;
                    lbIG.BackColor = (AlertCurrentAC) ? BackColorAlarm : BackColorNormal;
                    lbIG.ForeColor = (AlertCurrentAC) ? ForeColorAlarm : ForeColorNormal;
                    lbIG.Text      = ObjString(row["IG"]);

                    lbPG.Text  = ObjString(row["PG"]);
                    lbFG.Text  = ObjString(row["FG"]);
                    lbDWH.Text = ObjString(row["DWH"]);
                    lbTWH.Text = ObjString(row["TWH"]);

                    lbVIN1.Text = ObjString(row["VIN1"]);
                    lbIIN1.Text = ObjString(row["IIN1"]);
                    lbPIN1.Text = ObjString(row["PIN1"]);

                    lbVIN2.Text = ObjString(row["VIN2"]);
                    lbIIN2.Text = ObjString(row["IIN2"]);
                    lbPIN2.Text = ObjString(row["PIN2"]);

                    lbDate.Text = ObjString(row["Rectime"]);
                }

/*
 *              row = dataManager.RetriveNowData("90");
 *              if (row != null)
 *              {
 *                  lbTemp1.BackColor = (AlertVoltPoly1) ? BackColorAlarm : BackColorNormal;
 *                  lbTemp1.ForeColor = (AlertVoltPoly1) ? ForeColorAlarm : ForeColorNormal;
 *                  lbTemp1.Text = ObjString(row["temperature1"]);
 *
 *                  AlertVoltPoly1 = (ObjFloat(row["temperature2"]) < al.MinVoltPoly1 || ObjFloat(row["temperature2"]) > al.MaxVoltPoly1) ? true : false;
 *                  lbTemp2.BackColor = (AlertVoltPoly1) ? BackColorAlarm : BackColorNormal;
 *                  lbTemp2.ForeColor = (AlertVoltPoly1) ? ForeColorAlarm : ForeColorNormal;
 *                  lbTemp2.Text = ObjString(row["temperature2"]);
 *
 *                  AlertCurrentPoly1 = (ObjFloat(row["humid1"]) < al.MinCurrentPoly1 || ObjFloat(row["humid1"]) > al.MaxCurrentPoly1) ? true : false;
 *                  lbHumid1.BackColor = (AlertCurrentPoly1) ? BackColorAlarm : BackColorNormal;
 *                  lbHumid1.ForeColor = (AlertCurrentPoly1) ? ForeColorAlarm : ForeColorNormal;
 *                  lbHumid1.Text = ObjString(row["humid1"]);
 *
 *                  lbIrr1.Text = ObjString(row["irr1"]);
 *                  if (ObjString(row["control_code"]) != "0") errorPvd.SetError(lbTemp2, "Error: " + ObjString(row["remark"]));
 *                  else errorPvd.SetError(lbTemp2, "");
 *              }
 *
 *              row = dataManager.RetriveNowData("10");
 *              if (row != null)
 *              {
 *
 *                  AlertPowerAC = (ObjFloat(row["power"]) < al.MinPowerAC || ObjFloat(row["power"]) > al.MaxPowerAC) ? true : false;
 *                  lbPowerAC.BackColor = (AlertPowerAC) ? BackColorAlarm : BackColorNormal;
 *                  lbPowerAC.ForeColor = (AlertPowerAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbPowerAC.Text = ObjString(row["power"]);
 *
 *                  AlertVoltAC = (ObjFloat(row["voltage"]) < al.MinVoltAC || ObjFloat(row["voltage"]) > al.MaxVoltAC) ? true : false;
 *                  lbVoltAC.BackColor = (AlertVoltAC) ? BackColorAlarm : BackColorNormal;
 *                  lbVoltAC.ForeColor = (AlertVoltAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbVoltAC.Text = ObjString(row["voltage"]);
 *
 *                  AlertCurrentAC = (ObjFloat(row["current"]) < al.MinCurrentAC || ObjFloat(row["current"]) > al.MaxCurrentAC) ? true : false;
 *                  lbCurrentAC.BackColor = (AlertCurrentAC) ? BackColorAlarm : BackColorNormal;
 *                  lbCurrentAC.ForeColor = (AlertCurrentAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbCurrentAC.Text = ObjString(row["current"]);
 *
 *                  lbPF.Text = ObjString(row["pf"]);
 *                  lbFrequency.Text = ObjString(row["frequency"]);
 *
 *
 *                  if (ObjString(row["control_code"]) != "0") errorPvd.SetError(lbVoltAC, "Error: " + ObjString(row["remark"]));
 *                  else errorPvd.SetError(lbVoltAC, "");
 *
 *                  lbDate.Text = "data update: " + ObjDateTime(row["create_date"]).ToString("d/MM/yyyy H:mm");
 *
 *              }
 *              row = dataManager.RetriveNowData("11");
 *              if (row != null)
 *              {
 *
 *                  AlertPowerAC = (ObjFloat(row["power"]) < al.MinPowerAC || ObjFloat(row["power"]) > al.MaxPowerAC) ? true : false;
 *                  lbPower2.BackColor = (AlertPowerAC) ? BackColorAlarm : BackColorNormal;
 *                  lbPower2.ForeColor = (AlertPowerAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbPower2.Text = ObjString(row["power"]);
 *
 *                  AlertVoltAC = (ObjFloat(row["voltage"]) < al.MinVoltAC || ObjFloat(row["voltage"]) > al.MaxVoltAC) ? true : false;
 *                  lbVolt2.BackColor = (AlertVoltAC) ? BackColorAlarm : BackColorNormal;
 *                  lbVolt2.ForeColor = (AlertVoltAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbVolt2.Text = ObjString(row["voltage"]);
 *
 *                  AlertCurrentAC = (ObjFloat(row["current"]) < al.MinCurrentAC || ObjFloat(row["current"]) > al.MaxCurrentAC) ? true : false;
 *                  lbAmp2.BackColor = (AlertCurrentAC) ? BackColorAlarm : BackColorNormal;
 *                  lbAmp2.ForeColor = (AlertCurrentAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbAmp2.Text = ObjString(row["current"]);
 *
 *                  lbPF2.Text = ObjString(row["pf"]);
 *                  lbFreq2.Text = ObjString(row["frequency"]);
 *
 *                  if (ObjString(row["control_code"]) != "0") errorPvd.SetError(lbVolt2, "Error: " + ObjString(row["remark"]));
 *                  else errorPvd.SetError(lbVoltAC, "");
 *
 *              }
 *
 *
 *              row = dataManager.RetriveNowData("12");
 *              if (row != null)
 *              {
 *
 *                  AlertPowerAC = (ObjFloat(row["power"]) < al.MinPowerAC || ObjFloat(row["power"]) > al.MaxPowerAC) ? true : false;
 *                  lbPower3.BackColor = (AlertPowerAC) ? BackColorAlarm : BackColorNormal;
 *                  lbPower3.ForeColor = (AlertPowerAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbPower3.Text = ObjString(row["power"]);
 *
 *                  AlertVoltAC = (ObjFloat(row["voltage"]) < al.MinVoltAC || ObjFloat(row["voltage"]) > al.MaxVoltAC) ? true : false;
 *                  lbVolt3.BackColor = (AlertVoltAC) ? BackColorAlarm : BackColorNormal;
 *                  lbVolt3.ForeColor = (AlertVoltAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbVolt3.Text = ObjString(row["voltage"]);
 *
 *                  AlertCurrentAC = (ObjFloat(row["current"]) < al.MinCurrentAC || ObjFloat(row["current"]) > al.MaxCurrentAC) ? true : false;
 *                  lbAmp3.BackColor = (AlertCurrentAC) ? BackColorAlarm : BackColorNormal;
 *                  lbAmp3.ForeColor = (AlertCurrentAC) ? ForeColorAlarm : ForeColorNormal;
 *                  lbAmp3.Text = ObjString(row["current"]);
 *
 *                  lbPF3.Text = ObjString(row["pf"]);
 *                  lbFreq3.Text = ObjString(row["frequency"]);
 *
 *                  if (ObjString(row["control_code"]) != "0") errorPvd.SetError(lbVolt3, "Error: " + ObjString(row["remark"]));
 *                  else errorPvd.SetError(lbVoltAC, "");
 *
 *              }
 */
            }
            catch (Exception ex)
            {
                DataTimer.Stop();
                MessageBox.Show("Error Loading!!" + ex.Message, "มีข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DataTimer.Start();
                //throw (ex);
            }
        }