private void Calib35_Load(object sender, EventArgs e) { switch (mGlobal.language) { case "Spanish": cul = CultureInfo.CreateSpecificCulture("es-ES"); break; case "Korean": cul = CultureInfo.CreateSpecificCulture("ko-KR"); break; case "Japanese": cul = CultureInfo.CreateSpecificCulture("ja-JP"); break; default: cul = CultureInfo.CreateSpecificCulture("en-US"); break; } label1.Text = res_man.GetString("Chanel", cul); label4.Text = res_man.GetString("Unit", cul); label2.Text = res_man.GetString("Data offset", cul); btnSetting.Text = res_man.GetString("Write Setting", cul); cbbChannel.Items.Clear(); string channel1 = ""; string channel2 = ""; string channel3 = ""; string channel4 = ""; dv35 = Device35.DelInstance(); dv35 = Device35.Instance; dv35.Channels = new Channel[4]; for (int i = 0; i < 4; i++) { dv35.Channels[i] = new Channel(); } dv35.USBOpen(host); //HIDFunction.hid_SetNonBlocking(dv35.dev, 1); Thread.Sleep(200); byte[] buf = new byte[64]; dv35.readSettingDevice(); if (dv35.byteLogging == 68) { MessageBox.Show("Logger is recording. Please stop to calibrate"); dv35.Close(); this.Close(); } dv35.readInfo4Device(ref buf); Thread.Sleep(2000); dv35.readSettingChannel(); dv35.Close(); byte[] temp1 = new byte[7]; for (int i = 0; i < 7; i++) { if (buf[2 + i] != 0) { temp1[i] = buf[2 + i]; } } channel1 += Encoding.UTF8.GetString(temp1); byte[] temp2 = new byte[7]; for (int i = 0; i < 7; i++) { if (buf[9 + i] != 0) { temp2[i] = buf[9 + i]; } } channel2 += Encoding.UTF8.GetString(temp2); byte[] temp3 = new byte[7]; for (int i = 0; i < 7; i++) { if (buf[16 + i] != 0) { temp3[i] = buf[16 + i]; } } channel3 += Encoding.UTF8.GetString(temp3); byte[] temp4 = new byte[7]; for (int i = 0; i < 7; i++) { if (buf[23 + i] != 0) { temp4[i] = buf[23 + i]; } } channel4 += Encoding.UTF8.GetString(temp4); if (channel1 == "PEXO-37") { cbbChannel.Items.Add("1"); channels[0].unit = dv35.Channels[0].Unit; } else if (channel1 == "PEXO-40") { cbbChannel.Items.Add("1"); channels[0].unit = 2; } if (channel2 == "PEXO-37") { cbbChannel.Items.Add("2"); channels[1].unit = dv35.Channels[1].Unit; } else if (channel2 == "PEXO-40") { cbbChannel.Items.Add("2"); channels[1].unit = 2; } if (channel3 == "PEXO-37") { cbbChannel.Items.Add("3"); channels[2].unit = dv35.Channels[2].Unit; } else if (channel3 == "PEXO-40") { cbbChannel.Items.Add("3"); channels[2].unit = 2; } if (channel4 == "PEXO-37") { cbbChannel.Items.Add("4"); channels[3].unit = dv35.Channels[3].Unit; } else if (channel4 == "PEXO-40") { cbbChannel.Items.Add("4"); channels[3].unit = 2; } //cbbChannel.Text = cbbChannel.Items[0].ToString(); //cbbSign.Text = cbbSign.Items[0].ToString(); cbbUnit.DropDownStyle = ComboBoxStyle.DropDownList; if (cbbUnit.Items.Count > 0) { cbbUnit.Text = cbbUnit.Items[0].ToString(); } if (cbbChannel.Items.Count > 0) { cbbChannel.Text = cbbChannel.Items[0].ToString(); } }
private void DashBoardGraph35_Load(object sender, EventArgs e) { WindowState = FormWindowState.Maximized; switch (mGlobal.language) { case "Spanish": cul = CultureInfo.CreateSpecificCulture("es-ES"); break; case "Korean": cul = CultureInfo.CreateSpecificCulture("ko-KR"); break; case "Japanese": cul = CultureInfo.CreateSpecificCulture("ja-JP"); break; default: cul = CultureInfo.CreateSpecificCulture("en-US"); break; } //chkArea1.Text = res_man.GetString("Show chart area", cul) + " 1"; //chkArea2.Text = res_man.GetString("Show chart area", cul) + " 2"; device_dashboard = Device35.Instance; for (int i = 0; i < getDeviceInfo.activeDeviceListAl.Count; i++) { if (frmSelect.selectedLogger == getDeviceInfo.activeDeviceListAl[i].ToString()) { host = getDeviceInfo.activeDeviceListAl[i].ToString(); break; } } bool check = device_dashboard.USBOpen(host); if (check) { if (device_dashboard.readSettingDevice()) { if (device_dashboard.byteLogging != 68) { MessageBox.Show(res_man.GetString("Please start logging to view data with realtime", cul)); ThreadStart addDataThreadStart1 = new ThreadStart(AddDataThreadLoop); addDataRunner = new Thread(addDataThreadStart1); btnStop.Text = res_man.GetString("Stop", cul); device_dashboard.Close(); this.Close(); return; } } else { //this.Close(); return; } } else { MessageBox.Show(res_man.GetString("Connect to device fail", cul)); return; } device_dashboard.Channels = new Channel[4]; for (int i = 0; i < 4; i++) { device_dashboard.Channels[i] = new Channel(); } device_dashboard.readSettingChannel(); int numOfChannel = 0; for (int i = 0; i < 4; i++) { if (device_dashboard.Channels[i].Sensor == 3) { numOfChannel += 3; } else { numOfChannel += 1; } } int[] unit = new int[4]; for (int i = 0; i < 4; i++) { if (device_dashboard.Channels[i].Sensor == 1) { unit[i] = device_dashboard.Channels[i].Unit; } else { unit[i] = device_dashboard.Channels[i].Sensor; } } //device_dashboard = Device35.DelInstance(); //device_dashboard = Device35.Instance; //device_dashboard.Channels = new Channel[numOfChannel]; ////for (int i = 0; i < numOfChannel; i++) ////{ //// device_dashboard.Channels[i] = new Channel(); ////} //int count = 0; //for (int i = 0; i < 4; i++) //{ // if(unit[i] == 3) // { // device_dashboard.Channels[count] = new Channel(); // device_dashboard.Channels[count].Unit = 3; // device_dashboard.Channels[count + 1] = new Channel(); // device_dashboard.Channels[count + 1].Unit = 3; // device_dashboard.Channels[count + 2] = new Channel(); // device_dashboard.Channels[count + 2].Unit = 3; // count += 3; // } // else //if(device_dashboard.Channels[i].Sensor == 0) // { // device_dashboard.Channels[count] = new Channel(); // //if (unit[i] == 1) // device_dashboard.Channels[count].Unit = byte.Parse(unit[i].ToString()); // //else // //{ // // device_dashboard.Channels[i].Unit = device_dashboard.Channels[i].Sensor; // //} // count += 1; // } //} int count = 0; for (int i = 0; i < 4; i++) { if (device_dashboard.Channels[i].Sensor == 3) { count += 3; } else { count += 1; } } device_dashboard.numOfChannel = count; for (int i = 0; i < 4; i++) { if (device_dashboard.Channels[i].Sensor != 1 && device_dashboard.Channels[i].Sensor != 3) { device_dashboard.Channels[i].Unit = device_dashboard.Channels[i].Sensor; } } device_dashboard.Close(); //device_dashboard.USBOpen(host); ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop); addDataRunner = new Thread(addDataThreadStart); // create a delegate for adding Data addDataDel += new AddDataDelegate(AddData); btnStop.Text = res_man.GetString("Run", cul); //device_dashboard.Close(); }
private void btnRead_Click(object sender, EventArgs e) { chDesAl.Clear(); btnPrint.Enabled = true; StrDev = txtHostPort.Text; dev_general.USBOpen(StrDev); if (!dev_general.readSerial()) { MessageBox.Show(res_man.GetString("Read setting fail", cul) + "1"); dev_general.Close(); return; } //if (dev_general.FirmVer > 128) //{ // txtFirmWare.Text = "No Wifi _ " + (dev_general.FirmVer - 128).ToString(); //} //else //{ // txtFirmWare.Text = "Wifi _ " + dev_general.FirmVer.ToString(); //} //txtHardWare.Text = dev_general.HardVer.ToString(); txtFirmWare.Text = dev_general.HardVer + "." + dev_general.FirmVer; txtSerialNum.Text = dev_general.Serial; dev_general.Close(); dev_general.USBOpen(StrDev); if (!dev_general.readDescription()) { MessageBox.Show(res_man.GetString("Read setting fail", cul) + "2"); dev_general.Close(); return; } textBox1.Text = dev_general.Description; dev_general.Close(); dev_general.USBOpen(StrDev); if (!dev_general.readLocation()) { MessageBox.Show(res_man.GetString("Read setting fail", cul) + "3"); dev_general.Close(); return; } txtLocation.Text = dev_general.Location; dev_general.Close(); dev_general.USBOpen(StrDev); if (!dev_general.readSettingDevice()) { MessageBox.Show(res_man.GetString("Read setting fail", cul) + "4"); dev_general.Close(); return; } txtTimeSetting.Text = dev_general.SettingTime.ToLongTimeString(); txtDelay.Text = dev_general.Delay.ToString() + " Min(s)"; txtDuration.Text = dev_general.Duration.ToString() + " Day(s)"; if (!dev_general.readSettingChannel()) { MessageBox.Show(res_man.GetString("Read setting fail", cul) + "5"); dev_general.Close(); return; } this.Refresh(); if (!dev_general.readDataProbe(ref buf)) { //MessageBox.Show(res_man.GetString("Read data fail", cul)); dev_general.Close(); //return; } dev_general.Close(); int num = 0; for (int i = 0; i < 4; i++) { if (dev_general.Channels[i].Sensor == 0) { num += 0; } else if (dev_general.Channels[i].Sensor == 3) { num += 3; } else { num += 1; } } int sec = 0; int min = 0; int tg = 0; int x = 0; if (num != 0) { x = (128 * 1024) / num; } else { x = 128 * 1024; } tg = mGlobal.duration35(Convert.ToInt32(dev_general.Duration), x); dev_general.Interval = tg.ToString(); if (tg > 60) { min = tg / 60; sec = tg % 60; txtMeasurenment.Text = min + " min(s) " + sec + " sec(s)."; } else { txtMeasurenment.Text = tg + " sec(s)."; } txtChannel = new TextBox[num]; txtCurrentValue = new TextBox[num]; txtUnit = new TextBox[num]; txtHighAlarm = new TextBox[num]; txtLowAlarm = new TextBox[num]; txtDescription = new TextBox[num]; //declare for (int i = 0; i < num; i++) { txtChannel[i] = new TextBox(); txtChannel[i].Name = "txtChannel" + i.ToString(); txtChannel[i].Width = 80; txtChannel[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtChannel[i].Left = 20; txtChannel[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtChannel[i]); txtUnit[i] = new TextBox(); txtUnit[i].Name = "txtUnit" + i.ToString(); txtUnit[i].Width = 90; txtUnit[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtUnit[i].Left = 140; txtUnit[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtUnit[i]); txtCurrentValue[i] = new TextBox(); txtCurrentValue[i].Name = "txtValue" + i.ToString(); txtCurrentValue[i].Width = 110; txtCurrentValue[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtCurrentValue[i].Left = 260; txtCurrentValue[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtCurrentValue[i]); txtHighAlarm[i] = new TextBox(); txtHighAlarm[i].Name = "txtHigh" + i.ToString(); txtHighAlarm[i].Width = 130; txtHighAlarm[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtHighAlarm[i].Left = 410; txtHighAlarm[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtHighAlarm[i]); txtLowAlarm[i] = new TextBox(); txtLowAlarm[i].Name = "txtLow" + i.ToString(); txtLowAlarm[i].Width = 130; txtLowAlarm[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtLowAlarm[i].Left = 580; txtLowAlarm[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtLowAlarm[i]); txtDescription[i] = new TextBox(); txtDescription[i].Name = "txtDescription" + i.ToString(); txtDescription[i].Width = 200; txtDescription[i].Top = (int)(220 + 1.5 * i * txtChannel[i].Height); txtDescription[i].Left = 760; txtDescription[i].TextAlign = HorizontalAlignment.Center; this.groupBox1.Controls.Add(txtDescription[i]); } addData(); ////add data //int channel = 0; //for (int i = 0; i < 4; i++) //{ // int tmpDiv; // if (dev_general.Channels[i].Unit == 175 || dev_general.Channels[i].Unit == 172 || dev_general.Channels[i].Sensor == 2) // { // tmpDiv = 10; // } // else if (dev_general.Channels[i].Sensor == 3) // { // tmpDiv = 1000; // } // else // { // tmpDiv = 1; // } // if (dev_general.Channels[i].Sensor == 3) // { // int dem = 0; // for (int j = 0; j < 3; j++) // { // switch (dem) // { // case 0: // txtChannel[channel].Text = (i + 1).ToString() + "(X)"; // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Sensor); // txtHighAlarm[channel].Text = res_man.GetString("No Alarm",cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[3 + 7 * i], buf[4 + 7 * i])/tmpDiv).ToString(); // channel += 1; // dem += 1; // break; // case 1: // txtChannel[channel].Text = (i + 1).ToString() + "(Y)"; // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Sensor); // txtHighAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[5 + 7 * i], buf[6 + 7 * i]) / tmpDiv).ToString(); // channel += 1; // dem += 1; // break; // case 2: // txtChannel[channel].Text = (i + 1).ToString() + "(Z)"; // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Sensor); // txtHighAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[7 + 7 * i], buf[8 + 7 * i]) / tmpDiv).ToString(); // channel += 1; // dem += 1; // break; // } // } // } // else if (dev_general.Channels[i].Sensor == 1) // { // txtChannel[channel].Text = (i + 1).ToString(); // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Unit); // if (dev_general.Channels[i].NoAlarm) // { // txtHighAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // } // else // { // txtHighAlarm[channel].Text = (dev_general.Channels[i].AlarmMax / 10).ToString(); // txtLowAlarm[channel].Text = (dev_general.Channels[i].AlarmMin / 10).ToString(); // } // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[3 + 7 * i], buf[4 + 7 * i]) / tmpDiv).ToString(); // channel += 1; // } // else if (dev_general.Channels[i].Sensor == 2) // { // txtChannel[channel].Text = (i + 1).ToString(); // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Sensor); // if (dev_general.Channels[i].NoAlarm) // { // txtHighAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // } // else // { // txtHighAlarm[channel].Text = (dev_general.Channels[i].AlarmMax / 10).ToString(); // txtLowAlarm[channel].Text = (dev_general.Channels[i].AlarmMin / 10).ToString(); // } // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[3 + 7 * i], buf[4 + 7 * i]) / tmpDiv).ToString(); // channel += 1; // } // else if(dev_general.Channels[i].Sensor == 4) // { // txtChannel[channel].Text = (i + 1).ToString(); // txtUnit[channel].Text = mGlobal.IntToUnit35(dev_general.Channels[i].Sensor); // txtHighAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtLowAlarm[channel].Text = res_man.GetString("No Alarm", cul); // txtDescription[channel].Text = dev_general.Channels[i].Desc; // txtCurrentValue[channel].Text = (mGlobal.get_temp(buf[3 + 7 * i], buf[4 + 7 * i]) / tmpDiv).ToString(); // channel += 1; // } //} }
private void btnStart_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); string str_device = ""; int numofChannel = 0; int count = 0; for (int i = 0; i < getDeviceInfo.activeDeviceListAl.Count; i++) { dev_dashboard35 = Device35.DelInstance(); dev_dashboard35 = Device35.Instance; str_device = getDeviceInfo.activeDeviceListAl[i].ToString(); if (getDeviceInfo.activeDeviceListAl[i].ToString().Contains("Pexo35 Custm HID")) { dev_dashboard35.USBOpen(str_device); dev_dashboard35.readLocation(); dev_dashboard35.readDescription(); dev_dashboard35.readSerial(); dev_dashboard35.readSettingDevice(); dev_dashboard35.Channels = new Channel[4]; for (int k = 0; k < 4; k++) { dev_dashboard35.Channels[k] = new Channel(); } dev_dashboard35.readSettingChannel(); for (int j = 0; j < 4; j++) { if (dev_dashboard35.Channels[j].Sensor == 3) { numofChannel += 3; } else if (dev_dashboard35.Channels[j].Sensor != 0) { numofChannel += 1; } } for (int j = 0; j < 4; j++) { if (dev_dashboard35.byteLogging == 0x44) { arrUnit[i, j] = mGlobal.IntToUnit_Dashboard35(dev_dashboard35.Channels[j].Unit, dev_dashboard35.Channels[j].Sensor); } else { arrUnit[i, j] = "--"; } if (!dev_dashboard35.Channels[j].NoAlarm) { arrMax[i, j] = (double)dev_dashboard35.Channels[j].AlarmMax / 10.0; arrMin[i, j] = (double)dev_dashboard35.Channels[j].AlarmMin / 10.0; } else { arrMax[i, j] = 65535; arrMin[i, j] = 65535; } } dataGridView1.Rows.Add("", ""); dataGridView1.Rows[count].Cells[0].Value = count.ToString(); dataGridView1.Rows[count].Cells[1].Value = getDeviceInfo.activeDeviceListAl[i].ToString(); dataGridView1.Rows[count].Cells[2].Value = dev_dashboard35.Location; dataGridView1.Rows[count].Cells[3].Value = dev_dashboard35.Description; dataGridView1.Rows[count].Cells[4].Value = dev_dashboard35.Serial; count += 1; dev_dashboard35.Close(); } } if (btnStart.Text == "Run") { btnStart.Text = "Stop"; timer1.Enabled = true; } else { btnStart.Text = "Run"; timer1.Enabled = false; } if (count == 0) { btnGraph.Enabled = false; btnStart.Enabled = false; } }