Пример #1
0
        private void DoRead(bool fouceRead)
        {
            if (!ReadDone || fouceRead)
            {
                try{
                    if (spt == null || !spt.connected)
                    {
                        connectDevice();
                    }
                    devInfo    = new DeviceInfo(spt.SendGetInfo());
                    devSetting = new DeviceSetting(spt.SentGetSetting());

                    string tempListstr = spt.SentGetRecords();
                    TempList = new DeviceTempList(tempListstr, devInfo.usedSpace, devInfo.RecordDateTime, devSetting.recordIntervalInSecond);

                    //Console.WriteLine(temps);
                    //string s = TempSenHelper.GetTempListCString(tempList, spt.ItemCount, devInfo.RecordDateTime, devSetting.recordInterval);
                }catch (Exception ex) {
                    ReadDone = false;
                    Console.WriteLine(ex.Message + ex.StackTrace);
                    throw new Exception("do read failed.");
                }
            }

            if (devInfo != null && devSetting != null && TempList != null)
            {
                ReadDone = true;
            }
        }
Пример #2
0
        public string Report()
        {
            {
                SerialPortTran spt      = this.ITAG.spt;
                var            dinfo    = new DeviceInfo(spt.SendGetInfo());
                string         filename = dinfo.sn + ".txt";
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                StreamWriter sw = new StreamWriter(filename);

                Console.WriteLine("===============" + DateTime.Now.ToString() + "===========================================================================");
                sw.WriteLine("===============" + DateTime.Now.ToString() + "===========================================================================");


                string deviceinfo = dinfo.ToString();
                Console.WriteLine(deviceinfo);
                sw.WriteLine(deviceinfo);
                var    dsetting      = new DeviceSetting(spt.SentGetSetting());
                string devicesetting = dsetting.ToString();
                Console.WriteLine(devicesetting);
                sw.WriteLine(devicesetting);
                string temps = spt.SentGetRecords();
                //Console.WriteLine(temps);
                string s = TempSenHelper.GetTempListCString(temps, spt.ItemCount, dinfo.RecordDateTime, dsetting.recordIntervalInSecond);
                sw.WriteLine(s);
                //Console.WriteLine(s);
                Console.WriteLine("===============end" + DateTime.Now.ToString() + "===========================================================================");
                sw.WriteLine("===============end" + DateTime.Now.ToString() + "===========================================================================");

                sw.Close();
                this.textBox1.Text = File.ReadAllText(filename, Encoding.UTF8);

                Process vProcess = Process.Start(Directory.GetCurrentDirectory() + "\\" + filename);
                return("");
            }
        }