Esempio n. 1
0
        private void btnScanDevice_Click(object sender, EventArgs e)
        {
            checkedListBox1.Items.Clear();
            string px35 = "";
            string px16 = "";

            getDeviceInfo.getActiveDevice();

            for (int i = 0; i < getDeviceInfo.activeDeviceListAl.Count; i++)
            {
                dev35.USBOpen(getDeviceInfo.activeDeviceListAl[i].ToString());
                px35 = getDeviceInfo.nhanDang(dev35.dev);
                px16 = getDeviceInfo.activeSerialAL[i].ToString().Substring(0, 1);


                if (px16 == typeDev)
                {
                    checkedListBox1.Items.Add(getDeviceInfo.activeDeviceListAl[i]);
                }


                else if (px35 == typeDev)
                {
                    checkedListBox1.Items.Add(getDeviceInfo.activeDeviceListAl[i]);
                }


                else if (px16 != "8" && px35 != "PEXO-35" && typeDev == "PEXO-34")
                {
                    checkedListBox1.Items.Add(getDeviceInfo.activeDeviceListAl[i]);
                }

                dev35.Close();
            }
        }
Esempio n. 2
0
        private void btnGraph_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            if (dev_dashboard35 != null)
            {
                dev_dashboard35.Close();
            }

            getDeviceInfo.getActiveDevice();
            DashBoardSelect realTimeSelect = new DashBoardSelect(1);

            realTimeSelect.FormClosed += new FormClosedEventHandler(close);
            this.Hide();
            realTimeSelect.ShowDialog();

            //this.Close();
        }
Esempio n. 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            getDeviceInfo.getActiveDevice();
            if (getDeviceInfo.activeDeviceListAl.Count == 0)
            {
                MessageBox.Show("Troi oi! Chua cam logger kia thim 2!");
                return;
            }
            device35.hostport = getDeviceInfo.activeDeviceListAl[0].ToString();

            if (device35.USBOpen(device35.hostport) == false)
            {
                MessageBox.Show("Open USB fail");
                device35.Close();
                return;
            }


            if (comboBox1.Text == "With WifiReader")
            {
                device35.version = 1;
            }
            else
            {
                device35.version = 0;
            }

            mGlobal.len = 64;

            if (device35.writeFirmVer())
            {
                MessageBox.Show("OK!!!!!!!!!!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Fail! Please try again!!!");
            }

            device35.Close();
        }
Esempio n. 4
0
        private void btnSetting_Click(object sender, EventArgs e)
        {
            if (cbbChannel.Text == "")
            {
                MessageBox.Show(res_man.GetString("Please choose one of channels", cul));
                return;
            }
            if (txtDataOffset.Text == "")
            {
                MessageBox.Show(res_man.GetString("Please set value to calib", cul));
                return;
            }


            int index;

            index = Int32.Parse(cbbChannel.SelectedItem.ToString()) - 1;
            byte channel = byte.Parse((index + 1).ToString());
            byte data    = byte.Parse(channels[index].data.ToString());
            byte dau     = byte.Parse(channels[index].dau.ToString());

            if (channels[index].unit == 175)
            {
                float tamp = data / 10;
                tamp = Convert.ToSingle((tamp / 1.8).ToString("0.0"));
                data = byte.Parse((tamp * 10).ToString());
            }

            dv35.USBOpen(host);
            //HIDFunction.hid_SetNonBlocking(dv35.dev, 1);
            Thread.Sleep(2000);
            if (!dv35.writeCalibOffset(channel, data, dau))
            {
                MessageBox.Show(res_man.GetString("Setting Calib fail", cul));
                dv35.Close();
                return;
            }
            else
            {
                MessageBox.Show(res_man.GetString("Setting successful", cul));
                dv35.Close();
            }

            btnSetting.Enabled = false;
            btnSetting.Refresh();
            Thread.Sleep(4000);
            btnSetting.Enabled = true;

            //for (int i = 0; i < cbbChannel.Items.Count; i++)
            //{
            //    index = Int32.Parse(cbbChannel.Items[i].ToString()) - 1;
            //    byte channel = byte.Parse((index + 1).ToString());
            //    byte data = byte.Parse(channels[index].data.ToString());
            //    byte dau = byte.Parse(channels[index].dau.ToString());
            //    if(!dv35.writeCalibOffset(channel, data, dau))
            //    {
            //        MessageBox.Show("Setting Calib fail!");
            //        dv35.Close();
            //        return;
            //    }
            //}
            //MessageBox.Show("Successfully!");
            //dv35.Close();
        }
Esempio n. 5
0
        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();
            }
        }
Esempio n. 6
0
        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;
            //    }
            //}
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        private void AddData()
        {
            DateTime timeStamp = DateTime.Now;
            int      channel   = 0;

            int dem = 0;

            double[] data = new double[12];
            byte[]   buf  = new byte[64];

            string StrDevs = host;

            try
            {
                device_dashboard.Close();
                device_dashboard.USBOpen(host);
                //if (device_dashboard.USBOpen(StrDevs) == true)
                //{
                device_dashboard.readSettingDevice();
                if (device_dashboard.byteLogging == 0xaa)
                {
                    if (addDataRunner.IsAlive == true)
                    {
                        addDataRunner.Suspend();
                    }
                    this.Close();
                }
                //Thread.Sleep(500);

                //HIDFunction.hid_SetNonBlocking(device_dashboard.dev, 1);
                device_dashboard.readDataProbe(ref buf);

                if (buf[1] != 28)
                {
                    device_dashboard.Close();
                    HIDFunction.hid_Exit();
                    device_dashboard.USBOpen(StrDevs);
                    //MessageBox.Show(res_man.GetString("Read data fail", cul));
                    return;
                }

                int count = 0;
                //for (int i = 0; i < 4; i++)
                //{
                //    string hexSensor = buf[2 + i * 7].ToString("X");
                //    if (hexSensor != "0")
                //    {
                //        if (hexSensor.Substring(1, 1) == "3")
                //        {
                //            for (int j = 0; j < 3; j++)
                //            {
                //                data[count] = mGlobal.get_temp(buf[3 + i * 7 + 2 * j], buf[3 + i * 7 + 2 * j + 1]) / 1000;
                //                count += 1;
                //            }
                //        }
                //        else if (hexSensor.Substring(1, 1) == "1" || hexSensor.Substring(1, 1) == "2")
                //        {
                //            data[count] = mGlobal.get_temp(buf[3 + i * 7], buf[3 + i * 7 + 1]) / 10.0;
                //            count += 1;
                //        }
                //        else if (hexSensor.Substring(1, 1) == "0")
                //        {
                //            continue;
                //        }
                //        else
                //        {
                //            data[count] = mGlobal.get_temp(buf[3 + i * 7], buf[3 + i * 7 + 1]);
                //            count += 1;
                //        }
                //    }

                //    //for (int j = 0; j < 6; j++)
                //    //{
                //    //    if (buf[3 + i * 7 + j] != 0)
                //    //    {
                //    //        data[i * j] = buf[3 + i * 7 + j];
                //    //    }
                //    //}
                //}

                for (int i = 0; i < 4; i++)
                {
                    string hexSensor = buf[2 + i * 7].ToString("X");
                    if (hexSensor != "0")
                    {
                        if (hexSensor.Substring(1, 1) == "3")
                        {
                            for (int j = 0; j < 3; j++)
                            {
                                data[i * 3 + j] = mGlobal.get_temp(buf[3 + i * 7 + 2 * j], buf[3 + i * 7 + 2 * j + 1]) / 1000.0;
                                //data[i * 3 + j] = mGlobal.get_temp(buf[3 + i * 7 + 2 * j], buf[3 + i * 7 + 2 * j + 1]) / 1000.0;
                                count += 1;
                            }
                        }
                        else if (hexSensor.Substring(1, 1) == "1" || hexSensor.Substring(1, 1) == "2")
                        {
                            data[i * 3] = mGlobal.get_temp(buf[3 + i * 7], buf[3 + i * 7 + 1]) / 10.0;
                            count      += 1;
                        }
                        else if (hexSensor.Substring(1, 1) == "0")
                        {
                            continue;
                        }
                        else
                        {
                            data[i * 3] = mGlobal.get_temp(buf[3 + i * 7], buf[3 + i * 7 + 1]);
                            count      += 1;
                        }
                    }

                    //for (int j = 0; j < 6; j++)
                    //{
                    //    if (buf[3 + i * 7 + j] != 0)
                    //    {
                    //        data[i * j] = buf[3 + i * 7 + j];
                    //    }
                    //}
                }
                //device_dashboard.Close();
                //}
            }
            catch
            {
                MessageBox.Show(device_dashboard.dev.ToString());
                device_dashboard.Close();
            }
            //device_dashboard.Close();


            int c = 0;

            foreach (Series ptSeries in chart1.Series)
            {
                //channel += 1;
                string num = "";
                num = ptSeries.Name.ToString().Substring(8, 1);
                string name = "";
                name = ptSeries.Name.ToString().Substring(10, 1);

                if (name == "(" || name == "X")
                {
                    dem = (Int32.Parse(num) - 1) * 3;
                    AddNewPoint(timeStamp, ptSeries, dem, data, c);
                    c = c + 1;
                }
                else if (name == "Y")
                {
                    dem = (Int32.Parse(num) - 1) * 3 + 1;
                    AddNewPoint(timeStamp, ptSeries, dem, data, c);
                    c = c + 1;
                }
                else
                {
                    dem = (Int32.Parse(num) - 1) * 3 + 2;
                    AddNewPoint(timeStamp, ptSeries, dem, data, c);
                    c = c + 1;
                }

                //channel = Int32.Parse(name.Substring(8, 1));

                //AddNewPoint(timeStamp, ptSeries, channel);


                //ptSeries.Points.AddXY(timeStamp.ToOADate(), );
                //dem += 1;
                //AddNewPoint(timeStamp, ptSeries, dem, data);
            }
        }
Esempio n. 9
0
        private void btnReadSetting_Click(object sender, EventArgs e)
        {
            getDeviceInfo.getActiveDevice();
            if (getDeviceInfo.activeDeviceListAl.Count == 0)
            {
                MessageBox.Show("Troi oi! Chua cam logger kia thim 2!");
                return;
            }
            device35.hostport = getDeviceInfo.activeDeviceListAl[0].ToString();

            lblStatus.Text = "Reading.....Please wait";
            lblStatus.Update();

            string StrDevs = device35.hostport;

            //Open Device
            if (device35.USBOpen(StrDevs) == false)
            {
                MessageBox.Show("Open USB fail. Please try again.");
                lockButton(false);
                this.Close();
                return;
            }
            //read Serial
            if (device35.readSerial() == false)
            {
                MessageBox.Show("Read Eeprom fail. Please check USB caple!");
                lockButton(false);
                device35.Close();
                return;
            }
            txtSerial.Text = device35.Serial;
            rtxtEventLog.Clear();
            rtxtEventLog.Text += "Hardware: " + device35.HardVer + " Firmware: " + device35.FirmVer;
            device35.Close();


            //read Location
            device35.USBOpen(StrDevs);
            if (device35.readLocation() == false)
            {
                MessageBox.Show("Read Location fail");
                lockButton(false);
                device35.Close();
                return;
            }
            txtLocation.Text = device35.Location;
            device35.Close();


            //read Description
            device35.USBOpen(StrDevs);
            if (device35.readDescription() == false)
            {
                MessageBox.Show("Read description fail");
                lockButton(false);
                device35.Close();
                return;
            }

            txtDescription.Text = device35.Description;
            device35.Close();


            //read Description
            device35.USBOpen(StrDevs);

            //--------------read Setting (Time, TimeZone, Delay, Duration)
            if (device35.readSettingDevice() == false)
            {
                MessageBox.Show("Read Setting fail");
                lockButton(false);
                device35.Close();
                return;
            }


            string TimeZone = mGlobal.FindSystemTimeZoneFromString(device35.Timezone.ToString()).ToString();

            for (int i = 0; i <= cbbTimeZone.Items.Count - 1; i++)
            {
                if (cbbTimeZone.Items[i].ToString() == TimeZone)
                {
                    cbbTimeZone.Text = cbbTimeZone.Items[i].ToString();
                }
            }
            if (device35.Duration != 65535)
            {
                int sec1 = 0;
                int min2 = 0;

                if (Convert.ToInt32(device35.Duration) > 60)
                {
                    min2             = Convert.ToInt32(device35.Duration) / 60;
                    sec1             = Convert.ToInt32(device35.Duration) % 60;
                    lb_interval.Text = "Sample interval: " + min2 + " min " + sec1 + " sec.";
                }
                else
                {
                    lb_interval.Text = "Sample interval: " + Convert.ToInt32(device35.Duration) + " sec.";
                }
            }
            else
            {
                lb_interval.Text = 0.ToString();
            }

            if (device35.Delay == 255)
            {
                cbbStartDelay.Text = cbbStartDelay.Items[0].ToString();
            }
            else
            {
                cbbStartDelay.Text = device35.Delay.ToString();
            }

            if (device35.Duration == 65535)
            {
                cbbDuration.Text = cbbDuration.Items[0].ToString();
            }
            else
            {
                cbbDuration.Text = device35.Duration.ToString();
            }

            device35.Close();

            for (int i = 0; i < 4; i++)
            {
                device35.USBOpen(StrDevs);
                if (device35.readSettingChannel1(i) == false)
                {
                    MessageBox.Show("Read Setting fail");
                    lockButton(false);
                    device35.Close();
                    return;
                }
                device35.Close();
            }

            cbbChannel_SelectedIndexChanged(sender, e);

            lblStatus.Text = ".....";
        }
Esempio n. 10
0
        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;
            }
        }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //string a = Send_Email("*****@*****.**", "*****@*****.**", "abcdefgh", "hgedcba");
            //MessageBox.Show(a);
            //timer1.Enabled = true;

            emailDevice.USBOpen(host);

            if (emailDevice.readSettingDevice() == false)
            {
                emailDevice.Close();
                return;
            }

            emailDevice.Close();

            if (emailDevice.byteLogging == 0x44)
            {
                MessageBox.Show("Logger is recording. Cannot write setting email");
                return;
            }

            emailDevice.USBOpen(host);

            string cc  = "";
            int    lan = 0;

            cc = richTextBox1.Text.Replace("\n", ";");
            //string dsEmail = textBox1.Text + ";" + cc;
            string dsEmail = cc;

            if (dsEmail.Substring(dsEmail.Length - 1, 1) == ";")
            {
                dsEmail = dsEmail.Substring(0, dsEmail.Length - 1);
            }
            //byte[] arrEmail = new byte[dsEmail.Length];
            byte[] arrEmail = new byte[600];

            int tmp = 0;

            if (arrEmail.Length <= 60)
            {
                tmp = arrEmail.Length;
            }
            else
            {
                tmp = 60;
            }

            for (int i = 0; i < dsEmail.Length; i++)
            {
                arrEmail[i] = Encoding.ASCII.GetBytes(dsEmail.Substring(i, 1))[0];
            }
            for (int i = dsEmail.Length; i < 600; i++)
            {
                arrEmail[i] = 0xff;
            }
            if (arrEmail.Length > 600)
            {
                MessageBox.Show(res_man.GetString("Emails are too long to save", cul));
                emailDevice.Close();
                return;
            }
            else
            {
                if (arrEmail.Length % 60 > 0)
                {
                    lan = arrEmail.Length / 60 + 1;
                }
                else
                {
                    lan = arrEmail.Length / 60;
                }
                for (int i = 0; i < 10; i++)
                {
                    byte[] buf = new byte[64];
                    buf[0] = 0x01;
                    buf[1] = 0xb6;
                    buf[2] = 0x00;
                    buf[3] = byte.Parse((i + 1).ToString());
                    //if (i == lan - 1)
                    //{
                    //    tmp = arrEmail.Length % 60;
                    //}
                    for (int j = 0; j < tmp; j++)
                    {
                        buf[j + 4] = arrEmail[60 * i + j];
                    }
                    Thread.Sleep(200);
                    if (!emailDevice.writeEmailSetting(buf))
                    {
                        emailDevice.Close();
                        MessageBox.Show(res_man.GetString("Write Setting fail", cul));
                        return;
                    }
                }
                saveEmail(dsEmail);
                btnRead.Enabled = true;
                emailDevice.Close();
                MessageBox.Show(res_man.GetString("Write setting successfully", cul));
            }
        }
Esempio n. 12
0
        private void EmailSetting_Load(object sender, EventArgs e)
        {
            CenterToScreen();
            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;
            }


            emailDevice = Device35.DelInstance();
            emailDevice = Device35.Instance;
            byte[] buf    = new byte[600];
            string emails = "";

            string[] email;

            //emailDevice.USBOpen(host);
            for (int i = 0; i < 10; i++)
            {
                emailDevice.USBOpen(host);
                byte[] data = new byte[64];
                if (!emailDevice.readEmailSetting(ref data, i + 1))
                {
                    MessageBox.Show(res_man.GetString("Read Email Setting fail", cul));
                    emailDevice.Close();
                    return;
                }
                else
                {
                    for (int j = 0; j < 60; j++)
                    {
                        buf[60 * i + j] = data[j + 2];
                    }
                }
                emailDevice.Close();
            }

            //emailDevice.Close();
            int count = 0;

            for (int i = 0; i < buf.Length; i++)
            {
                if (buf[i] != 255 && buf[i] != 0)
                {
                    count += 1;
                }
            }

            emails = mGlobal.ArrayToStr(ref buf, 0, count);
            email  = emails.Split(';');
            //textBox1.Text = email[0];
            richTextBox1.Clear();
            for (int i = 0; i < email.Length; i++)
            {
                richTextBox1.Text += email[i] + Environment.NewLine;
            }

            if (richTextBox1.Text != "")
            {
                richTextBox1.Text = richTextBox1.Text.Substring(0, richTextBox1.Text.Length - 1);
            }


            //Read SMS
            byte[] SMSlist = new byte[200];
            for (int i = 0; i < 5; i++)
            {
                emailDevice.USBOpen(host);
                byte[] data = new byte[44];
                if (!emailDevice.readSMSSetting(ref data, i + 1))
                {
                    MessageBox.Show("Read SMS Setting fail");
                    emailDevice.Close();
                    return;
                }
                else
                {
                    for (int j = 0; j < 40; j++)
                    {
                        SMSlist[40 * i + j] = data[j + 2]; //bo report + byte length
                    }
                }
                emailDevice.Close();
            }
            rtxtSMS.Clear();

            byte[] singleSMS = new byte[20];
            for (int i = 0; i < 10; i++)
            {
                Array.Copy(SMSlist, i * 20, singleSMS, 0, 20);
                string singleText = Encoding.ASCII.GetString(singleSMS).Replace('\0', ' ').Trim();
                if (singleText.Length > 0)
                {
                    rtxtSMS.Text += singleText + Environment.NewLine;
                }
            }

            string FileName = "";

            FileName = mGlobal.app_patch(FileName);

            FileName += "\\dataEmail.txt";

            if (System.IO.File.Exists(FileName))
            {
                btnRead.Enabled = true;
            }
            else
            {
                btnRead.Enabled = false;
            }
        }