예제 #1
0
 public DeviceTempList(string str, int length, DateTime start, int interval)
 {
     this.length        = length;
     this.interval      = interval;
     this.startDateTime = start;
     this.orgiStr       = str;
     TempIntList        = TempSenHelper.GetTempListC(str, length);
     TempStrList        = TempSenHelper.GetTempListCStringList(str, length);
     TempDateStrList    = TempSenHelper.GetTempListCStringList(str, length, start, interval);
     //tempDic=TempSenHelper.GetTempListCStringDic(str,length,startDateTime,interval);
     TempString     = TempSenHelper.GetTempListCString(str, length);
     TempDateString = TempSenHelper.GetTempListCString(str, length, start, interval);
 }
예제 #2
0
        private bool _SendSetConfigTime(DateTime dtNow, DateTime correctTime, double TempNow, int trytimes)
        {
            string        head  = "681013";
            StringBuilder msgsb = new StringBuilder();

            msgsb.Append(Utils.IntToHexString(dtNow.Year % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Month % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Day % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Hour % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Minute % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Second % 100, 1));
            msgsb.Append(Utils.IntToHexString(correctTime.Year % 100, 1));
            msgsb.Append(Utils.IntToHexString(correctTime.Month % 100, 1));
            msgsb.Append(Utils.IntToHexString(correctTime.Day % 100, 1));
            msgsb.Append(Utils.IntToHexString(correctTime.Hour % 100, 1));
            msgsb.Append(Utils.IntToHexString(correctTime.Minute % 100, 1));
            msgsb.Append(Utils.ToHexString(TempSenHelper.TempDouble2Byte(TempNow)));
            string msg = msgsb.ToString();

            msg = AddFCS(msg);
            string end = "0A";


            SPWrite(Utils.HexToByte(head + msg + end));
            if (autoreceive)
            {
                return(true);
            }
            string result = spRead();

            if (!result.StartsWith("68110000"))
            {
                if (trytimes > 0)
                {
                    return(_SendSetConfigTime(dtNow, correctTime, TempNow, --trytimes));
                }
                else
                {
                    throw new Exception("retry n times all faild .");
                }
            }
            return(true);
        }
예제 #3
0
 public int bytesToTemp(byte b0, byte b2)
 {
     return(TempSenHelper.bytesToTemp(b0, b2));
 }
예제 #4
0
        private bool _SendSetConfigInfo(int sn, string recordtype, string alerttype, double upTemp, double downTemp, DateTime alertDelay,
                                        DateTime startDelay, DateTime dtNow, bool isFastRecord, int trytimes)
        {
            string        head  = "681222";
            StringBuilder msgsb = new StringBuilder();

            msgsb.Append(Utils.IntToHexString(sn, 4));
            msgsb.Append(recordtype);
            msgsb.Append(alerttype);
            msgsb.Append(Utils.ToHexString(TempSenHelper.TempDouble2Byte(upTemp)));
            msgsb.Append(Utils.ToHexString(TempSenHelper.TempDouble2Byte(downTemp)));

            msgsb.Append(Utils.IntToHexString(alertDelay.Hour % 100, 1));
            msgsb.Append(Utils.IntToHexString(alertDelay.Minute % 100, 1));
            msgsb.Append(Utils.IntToHexString(alertDelay.Second % 100, 1));
            msgsb.Append(Utils.IntToHexString(startDelay.Hour % 100, 1));
            msgsb.Append(Utils.IntToHexString(startDelay.Minute % 100, 1));
            msgsb.Append(Utils.IntToHexString(startDelay.Second % 100, 1));


            msgsb.Append(Utils.IntToHexString(dtNow.Year % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Month % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Day % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Hour % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Minute % 100, 1));
            msgsb.Append(Utils.IntToHexString(dtNow.Second % 100, 1));
            if (isFastRecord)
            {
                msgsb.Append("FF");
            }
            else
            {
                msgsb.Append("00");
            }

            string msg = msgsb.ToString();

            msg = AddFCS(msg);
            string end = "0A";


            SPWrite(Utils.HexToByte(head + msg + end));
            if (autoreceive)
            {
                return(true);
            }
            string result = spRead();

            if (!result.StartsWith("68130000"))
            {
                if (trytimes > 0)
                {
                    return(_SendSetConfigInfo(sn, recordtype, alerttype, upTemp, downTemp, alertDelay, alertDelay, dtNow, isFastRecord, --trytimes));
                }
                else
                {
                    throw new Exception("retry n times all faild .");
                }
            }
            return(true);
        }