public int ParseTime(string str) { string findstr = "read pulsar calibration time:"; if (str.IndexOf(findstr) != -1) { int nstart = str.IndexOf(findstr); if (nstart + findstr.Length + 8 < str.Length) { string value = str.Substring(nstart + findstr.Length, 8); try { UInt32 num = UInt32.Parse(value, System.Globalization.NumberStyles.HexNumber); m_dt = GT_Function.ConvertIntDateTime((double)num); GT_LEDController.mConfigInfo[tmMarcos.kDueTimeALSC1] = (double)num; return(0); } catch (Exception e) { //如果第一次没有写这个数据的话直接写一个0 m_dt = GT_Function.ConvertIntDateTime((double)0); GT_LEDController.mConfigInfo[tmMarcos.kDueTimeALSC1] = (double)0; return(0); } } } return(-1); }
private void timerCalibtime_Tick(object sender, EventArgs e) { if (TestContext.m_dicConfig[tmMarcos.kDueTimeALSC1] != null && TestContext.m_dicConfig[tmMarcos.kDueTimeALSC2] != null) { try { double alsc1 = (double)TestContext.m_dicConfig[tmMarcos.kDueTimeALSC1]; double alsc2 = (double)TestContext.m_dicConfig[tmMarcos.kDueTimeALSC2]; double minvalue = System.Math.Min(alsc1, alsc2) + (7 * 24 * 60 * 60); DateTime dt = DateTime.Now; double nnow = GT_Function.ConvertDateTimeInt(dt); double nelapse = minvalue - nnow; if (nelapse < 0) { lbDueTime.Text = "Please Calib.the ALSC!"; } else { lbDueTime.Text = string.Format("{0:D2}H:{1:D2}M:{2:D2}S", (int)nelapse / 3600, (int)(nelapse - ((int)nelapse / 3600) * 3600) / 60, (int)nelapse % 60); } } catch (Exception ex) { lbDueTime.Text = "Get Calib. Time Fail!"; } } else { lbDueTime.Text = "Get Calib. Time Fail!"; } }
public int Write_lightCalibDate() { CheckAndConnect(); DateTime dt = DateTime.Now; int nvalue = (int)GT_Function.ConvertDateTimeInt(dt); string str = nvalue.ToString("x"); SetDetectString("@_@"); WriteString("Write Pulsar Calibration Time:" + str + "\r\n"); if (WaitForString(100) != -1) { string ret = ReadString(); if (ret.IndexOf("Write Pulsar Calibration Time:") != -1 && ret.IndexOf("Finish") != -1) { m_lightdata.m_dt = dt; } else { WriteString("Write Pulsar Calibration Time:" + str + "\r\n"); } } else { WriteString("Write Pulsar Calibration Time:" + str + "\r\n"); } return(0); }