Beispiel #1
0
 /// <summary>
 /// 取得摘要的值
 /// </summary>
 public override void Summary()
 {
     if (Config[0] == "OK")
     {
         SerialNumber  = Config[1];
         _TripNumber   = SerialNumber;
         LogCycle      = TempsenFormatHelper.ConvertSencondToFormmatedTime(TempsenFormatHelper.GetSecondsFromFormatString(Config[3]));
         LogInterval   = TempsenFormatHelper.GetSecondsFromFormatString(Config[2]);
         TempUnit      = AlarmSet[1];
         LogStartDelay = TempsenFormatHelper.ConvertSencondToFormmatedTime(TempsenFormatHelper.GetSecondsFromFormatString(Config[4]));
         LoggingStart  = Convert.ToDateTime(Config[6]);
         //LoggingEnd = Convert.ToDateTime(Config[6]).AddSeconds(int.Parse(Config[2].Substring(0, Config[2].Length - 1)) * int.Parse(Config[5]));
         DataPoints     = Convert.ToInt32(Config[5]);
         AlarmHighDelay = TempsenFormatHelper.ConvertSencondToFormmatedTime(TempsenFormatHelper.GetSecondsFromFormatString(AlarmSet[4]));
         AlarmLowDelay  = TempsenFormatHelper.ConvertSencondToFormmatedTime(TempsenFormatHelper.GetSecondsFromFormatString(AlarmSet[4]));
         Battery        = OtherInfo[1];
         AlarmMode      = 1;
         if (AlarmSet[2] == "--" && AlarmSet[3] == "--")
         {
             AlarmMode = 0;
         }
         else if (AlarmSet[2] != "--" && AlarmSet[3] == "--")
         {
             AlarmHighLimit = AlarmSet[2];
         }
         else if (AlarmSet[3] != "--" && AlarmSet[2] == "--")
         {
             AlarmLowLimit = AlarmSet[3];
         }
         else
         {
             AlarmHighLimit = AlarmSet[2];
             AlarmLowLimit  = AlarmSet[3];
         }
         if (SerializePointInfo())
         {
             points.FirstPoint = points.StartTime = this.LoggingStart;
             if (tempList != null && tempList.Count > 0)
             {
                 LoggingEnd = tempList[tempList.Count - 1].PointTime;
             }
             TripLength        = TempsenFormatHelper.ConvertSencondToFormmatedTime((LoggingEnd - LoggingStart).TotalSeconds.ToString());
             points.EndTime    = this.LoggingEnd;
             points.TripLength = this.TripLength;
             if (AlarmSet[2] != "--")
             {
                 HighAlarmEvents = tempList.Count(p => p.PointTemp >= Convert.ToDouble(AlarmSet[2]));
                 var v = tempList.Where(p => p.PointTemp >= Convert.ToDouble(AlarmSet[2]));
                 HighAlarmFirstTrigged = v.ToList().Count == 0 ? DateTime.MinValue.ToString() : v.Min(p => p.PointTime).ToString();
             }
             if (AlarmSet[3] != "--")
             {
                 LowAlarmEvents = tempList.Count(p => p.PointTemp <= Convert.ToDouble(AlarmSet[3]));
                 var v = tempList.Where(p => p.PointTemp <= Convert.ToDouble(AlarmSet[3]));
                 LowAlarmFirstTrigged = v.ToList().Count == 0 ? DateTime.MinValue.ToString() : v.Min(p => p.PointTime).ToString();
             }
             HighAlarmTotalTimeAbove = TempsenFormatHelper.ConvertSencondToFormmatedTime((Convert.ToDouble(LogInterval) * (HighAlarmEvents - 1)).ToString());
             LowAlarmTotalTimeBelow  = TempsenFormatHelper.ConvertSencondToFormmatedTime((Convert.ToDouble(LogInterval) * (LowAlarmEvents - 1)).ToString());
             if (tempList != null && tempList.Count > 0)
             {
                 AverageC = Math.Round(tempList.Select(p => p.PointTemp).Average(), 1).ToString();
                 MKT      = Common.CalcMKT(tempList.Select(p => (int)(p.PointTemp * 100)).ToList());
                 var s = (from p in tempList
                          where p.PointTemp == tempList.Select(t => t.PointTemp).Max()
                          select p.PointTemp.ToString() + "°" + (this.TempUnit) + "@" + p.PointTime.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture));
                 HighestC = s.ToList().Count == 0 ? "" : s.ToList().First();
                 s        = (from p in tempList
                             where p.PointTemp == tempList.Select(t => t.PointTemp).Min()
                             select p.PointTemp + "°" + (this.TempUnit) + "@" + p.PointTime.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture));
                 LowestC         = s.ToList().Count == 0 ? "" : s.First();
                 points.HighestC = this.HighestC;
                 points.LowestC  = this.LowestC;
                 points.AVGTemp  = AverageC;
                 points.MKT      = this.MKT;
             }
         }
     }
     return;
 }
Beispiel #2
0
        private void CalculateAlarmEvents()
        {
            int    tempIntForTryParse    = 0;
            double tempDoubleForTryParse = 0;

            IList <PointKeyValue> points = this.tempList;

            double highLimit = double.MaxValue;

            if (double.TryParse(this.AlarmHighLimit, out tempDoubleForTryParse))
            {
                highLimit = double.Parse(this.AlarmHighLimit);
            }
            double lowLimit = double.MinValue;

            if (double.TryParse(this.AlarmLowLimit, out tempDoubleForTryParse))
            {
                lowLimit = double.Parse(this.AlarmLowLimit);
            }
            int highAlarmDelay = int.MaxValue;

            highAlarmDelay = int.Parse(TempsenFormatHelper.GetSecondsFromFormatString(this.AlarmHighDelay));
            int lowAlarmDelay = int.MaxValue;

            lowAlarmDelay = int.Parse(TempsenFormatHelper.GetSecondsFromFormatString(this.AlarmLowDelay));
            AlarmType highAlarmType = AlarmType.Single;

            if ("Cumulative Event".Equals(this.HighAlarmType, StringComparison.InvariantCultureIgnoreCase))
            {
                highAlarmType = AlarmType.Cumulative;
            }
            AlarmType lowAlarmType = AlarmType.Single;

            if ("Cumulative Event".Equals(this.LowAlarmType, StringComparison.InvariantCultureIgnoreCase))
            {
                lowAlarmType = AlarmType.Cumulative;
            }
            int logInterval = 0;

            if (int.TryParse(this.LogInterval, out tempIntForTryParse))
            {
                logInterval = int.Parse(this.LogInterval);
            }

            int      overHighLimitEvents     = 0;
            int      belowLowLimitEvents     = 0;
            DateTime highAlarmFirstTriggered = DateTime.MinValue;
            DateTime lowAlarmFirstTriggered  = DateTime.MinValue;
            int      overHighLimitTotalTime  = 0;
            int      belowLowLimitTotalTime  = 0;

            int overHighLimitCumulativePoints = 0;
            int belowLowLimitCumulativePoints = 0;

            DateTime timeOfTheLastPointWithoutMark = DateTime.MinValue;

            foreach (var item in points)
            {
                if (!item.IsMark)
                {
                    if (item.PointTemp >= highLimit)
                    {
                        overHighLimitCumulativePoints++;
                        if (belowLowLimitCumulativePoints > 0)
                        {
                            belowLowLimitEvents++;
                            int actualIntervals = belowLowLimitCumulativePoints - 1;
                            if (actualIntervals == 0)
                            {
                                actualIntervals = 1;
                            }
                            belowLowLimitTotalTime       += logInterval * actualIntervals;
                            belowLowLimitCumulativePoints = 0;
                        }

                        int actualIntervalsToCheckAlarm = overHighLimitCumulativePoints - 1;
                        int actualTotalTimeToCheckAlarm = 0;
                        if (actualIntervalsToCheckAlarm == 0)
                        {
                            actualIntervalsToCheckAlarm = 1;
                        }
                        actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                        if (AlarmType.Cumulative == highAlarmType)
                        {
                            actualTotalTimeToCheckAlarm += overHighLimitTotalTime;
                        }
                        if (highAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= highAlarmDelay)
                        {
                            highAlarmFirstTriggered = item.PointTime;
                        }
                    }
                    else if (item.PointTemp <= lowLimit)
                    {
                        belowLowLimitCumulativePoints++;
                        if (overHighLimitCumulativePoints > 0)
                        {
                            overHighLimitEvents++;
                            int actualIntervals = overHighLimitCumulativePoints - 1;
                            if (actualIntervals == 0)
                            {
                                actualIntervals = 1;
                            }
                            overHighLimitTotalTime       += logInterval * actualIntervals;
                            overHighLimitCumulativePoints = 0;
                        }

                        int actualIntervalsToCheckAlarm = belowLowLimitCumulativePoints - 1;
                        int actualTotalTimeToCheckAlarm = 0;
                        if (actualIntervalsToCheckAlarm == 0)
                        {
                            actualIntervalsToCheckAlarm = 1;
                        }
                        actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                        if (AlarmType.Cumulative == lowAlarmType)
                        {
                            actualTotalTimeToCheckAlarm += belowLowLimitTotalTime;
                        }
                        if (lowAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= lowAlarmDelay)
                        {
                            lowAlarmFirstTriggered = item.PointTime;
                        }
                    }
                    else
                    {
                        if (belowLowLimitCumulativePoints > 0)
                        {
                            belowLowLimitEvents++;
                            int actualIntervals = belowLowLimitCumulativePoints - 1;
                            if (actualIntervals == 0)
                            {
                                actualIntervals = 1;
                            }
                            belowLowLimitTotalTime       += logInterval * actualIntervals;
                            belowLowLimitCumulativePoints = 0;

                            int actualIntervalsToCheckAlarm = belowLowLimitCumulativePoints - 1;
                            int actualTotalTimeToCheckAlarm = 0;
                            if (actualIntervalsToCheckAlarm == 0)
                            {
                                actualIntervalsToCheckAlarm = 1;
                            }
                            actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                            if (AlarmType.Cumulative == lowAlarmType)
                            {
                                actualTotalTimeToCheckAlarm += belowLowLimitTotalTime;
                            }
                            if (lowAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= lowAlarmDelay)
                            {
                                lowAlarmFirstTriggered = item.PointTime;
                            }
                        }
                        if (overHighLimitCumulativePoints > 0)
                        {
                            overHighLimitEvents++;
                            int actualIntervals = overHighLimitCumulativePoints - 1;
                            if (actualIntervals == 0)
                            {
                                actualIntervals = 1;
                            }
                            overHighLimitTotalTime       += logInterval * actualIntervals;
                            overHighLimitCumulativePoints = 0;

                            int actualIntervalsToCheckAlarm = overHighLimitCumulativePoints - 1;
                            int actualTotalTimeToCheckAlarm = 0;
                            if (actualIntervalsToCheckAlarm == 0)
                            {
                                actualIntervalsToCheckAlarm = 1;
                            }
                            actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                            if (AlarmType.Cumulative == highAlarmType)
                            {
                                actualTotalTimeToCheckAlarm += overHighLimitTotalTime;
                            }
                            if (highAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= highAlarmDelay)
                            {
                                highAlarmFirstTriggered = item.PointTime;
                            }
                        }
                    }
                    timeOfTheLastPointWithoutMark = item.PointTime;
                }
            }
            if (belowLowLimitCumulativePoints > 0)
            {
                belowLowLimitEvents++;
                int actualIntervals = belowLowLimitCumulativePoints - 1;
                if (actualIntervals == 0)
                {
                    actualIntervals = 1;
                }
                belowLowLimitTotalTime       += logInterval * actualIntervals;
                belowLowLimitCumulativePoints = 0;

                int actualIntervalsToCheckAlarm = belowLowLimitCumulativePoints - 1;
                int actualTotalTimeToCheckAlarm = 0;
                if (actualIntervalsToCheckAlarm == 0)
                {
                    actualIntervalsToCheckAlarm = 1;
                }
                actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                if (AlarmType.Cumulative == lowAlarmType)
                {
                    actualTotalTimeToCheckAlarm += belowLowLimitTotalTime;
                }
                if (lowAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= lowAlarmDelay)
                {
                    lowAlarmFirstTriggered = timeOfTheLastPointWithoutMark;
                }
            }
            if (overHighLimitCumulativePoints > 0)
            {
                overHighLimitEvents++;
                int actualIntervals = overHighLimitCumulativePoints - 1;
                if (actualIntervals == 0)
                {
                    actualIntervals = 1;
                }
                overHighLimitTotalTime       += logInterval * actualIntervals;
                overHighLimitCumulativePoints = 0;

                int actualIntervalsToCheckAlarm = overHighLimitCumulativePoints - 1;
                int actualTotalTimeToCheckAlarm = 0;
                if (actualIntervalsToCheckAlarm == 0)
                {
                    actualIntervalsToCheckAlarm = 1;
                }
                actualTotalTimeToCheckAlarm += logInterval * actualIntervalsToCheckAlarm;
                if (AlarmType.Cumulative == highAlarmType)
                {
                    actualTotalTimeToCheckAlarm += overHighLimitTotalTime;
                }
                if (highAlarmFirstTriggered == DateTime.MinValue && actualTotalTimeToCheckAlarm >= highAlarmDelay)
                {
                    highAlarmFirstTriggered = timeOfTheLastPointWithoutMark;
                }
            }

            this.HighAlarmEvents         = overHighLimitEvents;
            this.LowAlarmEvents          = belowLowLimitEvents;
            this.HighAlarmFirstTrigged   = highAlarmFirstTriggered.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
            this.LowAlarmFirstTrigged    = lowAlarmFirstTriggered.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
            this.HighAlarmTotalTimeAbove = TempsenFormatHelper.ConvertSencondToFormmatedTime(overHighLimitTotalTime.ToString());
            this.LowAlarmTotalTimeBelow  = TempsenFormatHelper.ConvertSencondToFormmatedTime(belowLowLimitTotalTime.ToString());
            AlarmHighStatus = HighAlarmEvents > 0 ? "Alarm" : "OK";
            AlarmLowStatus  = LowAlarmEvents > 0 ? "Alarm" : "OK";
        }
Beispiel #3
0
        private bool ConnectInit(int code)
        {
            bool result = false;

            if (ObjectManage.DeviceNew == null || ObjectManage.DeviceNew.Data == null)
            {
                ObjectManage.DeviceNew = new DevicePDF();
                result = ObjectManage.DeviceNew.connectDevice();
            }
            try
            {
                if (ObjectManage.DeviceNew != null)
                {
                    if (Convert.ToInt32(ObjectManage.DeviceNew.Data.DevModel.Substring(0, 3)) != code / 10)
                    {
                        Common.IsConnectCompleted = true;
                        return(false);
                    }
                    switch (ObjectManage.DeviceNew.Data.DevModel)
                    {
                    case "0100":
                        ProductName = DeviceName = "ITAG-PDF";
                        Model       = "TAGP";
                        DeviceID    = 100;
                        Memory      = 3600;
                        break;

                    case "0101":
                        ProductName = DeviceName = "ITAG3";
                        Model       = "TAGT";
                        DeviceID    = 101;
                        Memory      = 3600;
                        break;

                    case "0102":
                        ProductName = DeviceName = Model = "ITAG3 Pro";
                        Model       = "TAGH";
                        DeviceID    = 102;
                        Memory      = 3600;
                        break;

                    case "0200":
                        ProductName = DeviceName = Model = "Tempod";
                        Model       = "TP15";
                        DeviceID    = 200;
                        Memory      = 3600;
                        break;

                    case "0201":
                        ProductName = DeviceName = Model = "Tempod";
                        Model       = "TP15S";
                        DeviceID    = 201;
                        Memory      = 3600;
                        break;

                    case "0202":
                        ProductName = DeviceName = Model = "Tempod";
                        Model       = "TP25";
                        DeviceID    = 202;
                        Memory      = 7200;
                        break;

                    case "0203":
                        ProductName = DeviceName = Model = "Tempod";
                        Model       = "TP25S";
                        DeviceID    = 203;
                        Memory      = 7200;
                        break;

                    case "0300":
                        ProductName = DeviceName = Model = "Elog TE";
                        Model       = "EL-TE";
                        DeviceID    = 300;
                        Memory      = 7200;
                        break;

                    case "0301":
                        ProductName = DeviceName = Model = "Elog TI";
                        Model       = "EL-TI";
                        DeviceID    = 301;
                        Memory      = 7200;
                        break;

                    default:
                        ProductName = DeviceName = Model = "TAGS";
                        DeviceID    = 100;
                        Memory      = 3600;
                        break;
                    }
                    this.Battery   = ObjectManage.DeviceNew.Data.Battery >= 255 ? "100" : ObjectManage.DeviceNew.Data.Battery.ToString();
                    this.RunStatus = ObjectManage.DeviceNew.Data.RunStatus;
                    switch (ObjectManage.DeviceNew.Data.RunStatus)
                    {
                    case 0:
                        this.CurrentStatus = "Unconfigured";
                        break;

                    case 1:
                        this.CurrentStatus = "Standby";
                        break;

                    case 2:
                        this.CurrentStatus = "Recording";
                        break;

                    default:
                        this.CurrentStatus = "Stopped";
                        break;
                    }
                    this.SerialNumber = ObjectManage.DeviceNew.Data.DevNo.Trim();
                    if (ObjectManage.DeviceNew.Data.RunStatus != 0)
                    {
                        #region summary
                        this.TripNumber  = ObjectManage.DeviceNew.Data.TripNo.Trim() == "" ? SerialNumber : ObjectManage.DeviceNew.Data.TripNo.Trim();
                        this.LogCycle    = string.Format("{0}", TempsenFormatHelper.ConvertSencondToFormmatedTime((ObjectManage.DeviceNew.Data.LogCycle * 3600).ToString()));
                        this.LogInterval = ObjectManage.DeviceNew.Data.LogInterval.ToString();
                        if (ObjectManage.DeviceNew.Data.RunStatus != 1 && ObjectManage.DeviceNew.Data.TempListWithTime.Count > 0)
                        {
                            this.LoggingStart = ObjectManage.DeviceNew.Data.LogStartTime;
                            this.LoggingEnd   = ObjectManage.DeviceNew.Data.LogEndTime;
                            this.TripLength   = TempsenFormatHelper.ConvertSencondToFormmatedTime((LoggingEnd - LoggingStart).TotalSeconds.ToString());
                        }
                        this.Description = ObjectManage.DeviceNew.Data.Description;
                        this.TempUnit    = ObjectManage.DeviceNew.Data.TemperatureUnit == 1 ? "C" : "F";
                        this.StartModel  = ObjectManage.DeviceNew.Data.StartMode == "F8" ? "Manual Start" : "Auto Start";
                        if (ObjectManage.DeviceNew.Data.StartMode == "F8")
                        {
                            this.LogStartDelay = TempsenFormatHelper.ConvertSencondToFormmatedTime((ObjectManage.DeviceNew.Data.StartDelay * 60).ToString());
                        }
                        else
                        {
                            this.StartConditionTime = ObjectManage.DeviceNew.Data.StartConditionTime;
                        }
                        this.AlarmMode = ObjectManage.DeviceNew.Data.AlarmMode;
                        DataPoints     = ObjectManage.DeviceNew.Data.LogCount;
                        if (ObjectManage.DeviceNew.Data.TempListWithTime.Count > 0 && SerializePointInfo(ObjectManage.DeviceNew))
                        {
                            _points.FirstPoint = _points.StartTime = this.LoggingStart;
                            _points.EndTime    = this.LoggingEnd;
                            _points.TripLength = this.TripLength;
                            if (tempList != null && tempList.Count > 0)
                            {
                                AverageC = ObjectManage.DeviceNew.Data.AvgTemp;
                                switch (ObjectManage.DeviceNew.Data.DevModel)
                                {
                                case "0101":
                                case "0200":
                                case "0201":
                                    AverageC = Math.Round(tempList.Select(p => p.PointTemp).Average(), 1).ToString();
                                    MKT      = Common.CalcMKT(tempList.Select(p => (int)(p.PointTemp * 100)).ToList());
                                    break;

                                default:
                                    MKT = ObjectManage.DeviceNew.Data.MKT;
                                    break;
                                }
                                //test mkt
                                //Debug.WriteLine(Common.CalcMKT(tempList.Select(p => (int)p.PointTemp * 100).ToList()), "MKT");
                                HighestC         = ObjectManage.DeviceNew.Data.MaxTemp + "°" + (this.TempUnit) + "@" + ObjectManage.DeviceNew.Data.MaxTempTime.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                LowestC          = ObjectManage.DeviceNew.Data.MinTemp + "°" + (this.TempUnit) + "@" + ObjectManage.DeviceNew.Data.MinTempTime.ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                _points.HighestC = this.HighestC;
                                _points.LowestC  = this.LowestC;
                                _points.AVGTemp  = AverageC;
                                _points.MKT      = this.MKT;
                            }
                        }
                        if (ObjectManage.DeviceNew.Data.AlarmMode == 1)
                        {
                            if ((ObjectManage.DeviceNew.Data.AlarmType2 & 0x80) > 0)
                            {
                                AlarmHighLimit = ObjectManage.DeviceNew.Data.AlarmLimits2;
                                AlarmHighDelay = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AlarmDelay2.ToString());
                                HighAlarmType  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType2 & 0x01) > 0 ? "Cumulative" : "Single";
                                if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                                {
                                    AlarmHighStatus         = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[2] > 0 ? "Alarm" : "OK";
                                    HighAlarmTotalTimeAbove = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[2].ToString());
                                    if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[2] > 0)
                                    {
                                        HighAlarmFirstTrigged = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[2].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                    }
                                    HighAlarmEvents = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[2];
                                }
                            }
                            if ((ObjectManage.DeviceNew.Data.AlarmType3 & 0x80) > 0)
                            {
                                AlarmLowLimit = ObjectManage.DeviceNew.Data.AlarmLimits3;
                                AlarmLowDelay = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AlarmDelay3.ToString());
                                LowAlarmType  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType3 & 0x01) > 0 ? "Cumulative" : "Single";
                                if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                                {
                                    AlarmLowStatus         = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[3] > 0 ? "Alarm" : "OK";
                                    LowAlarmTotalTimeBelow = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[3].ToString());
                                    if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[3] > 0)
                                    {
                                        LowAlarmFirstTrigged = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[3].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                    }
                                    LowAlarmEvents = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[3];
                                }
                            }
                        }
                        else if (ObjectManage.DeviceNew.Data.AlarmMode == 2)
                        {
                            if ((ObjectManage.DeviceNew.Data.AlarmType0 & 0x80) > 0)
                            {
                                AlarmDelayA1 = ObjectManage.DeviceNew.Data.AlarmDelay0;
                                A1           = ObjectManage.DeviceNew.Data.AlarmLimits0;
                                AlarmTypeA1  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType0 & 0x01) > 0 ? "Cumulative" : "Single";
                                if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                                {
                                    if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[0] > 0)
                                    {
                                        AlarmA1First = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[0].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                    }
                                    AlarmNumA1       = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[0];
                                    AlarmA1Status    = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[0] == 0 ? "OK" : "Alarm";
                                    AlarmTotalTimeA1 = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[0].ToString());
                                }
                            }
                            if ((ObjectManage.DeviceNew.Data.AlarmType1 & 0x80) > 0)
                            {
                                AlarmDelayA2 = ObjectManage.DeviceNew.Data.AlarmDelay1;
                                A2           = ObjectManage.DeviceNew.Data.AlarmLimits1;
                                AlarmTypeA2  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType1 & 0x01) > 0 ? "Cumulative" : "Single";
                                if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                                {
                                    if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[1] > 0)
                                    {
                                        AlarmA2First = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[1].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                    }
                                    AlarmA2Status    = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[1] == 0 ? "OK" : "Alarm";
                                    AlarmTotalTimeA2 = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[1].ToString());
                                }
                            }
                            if ((ObjectManage.DeviceNew.Data.AlarmType4 & 0x80) > 0)
                            {
                                AlarmDelayA5 = ObjectManage.DeviceNew.Data.AlarmDelay4;
                                A5           = ObjectManage.DeviceNew.Data.AlarmLimits4;
                                AlarmTypeA5  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType4 & 0x01) > 0 ? "Cumulative" : "Single";
                                if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                                {
                                    if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[4] > 0)
                                    {
                                        AlarmA5First = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[4].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                    }
                                    AlarmNumA5       = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[4];
                                    AlarmTotalTimeA5 = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[4].ToString());
                                }
                            }
                            AlarmDelayA3 = ObjectManage.DeviceNew.Data.AlarmDelay2;
                            AlarmDelayA4 = ObjectManage.DeviceNew.Data.AlarmDelay3;
                            A3           = ObjectManage.DeviceNew.Data.AlarmLimits2;
                            A4           = ObjectManage.DeviceNew.Data.AlarmLimits3;
                            AlarmTypeA3  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType2 & 0x01) > 0 ? "Cumulative" : "Single";
                            AlarmTypeA4  = Convert.ToInt32(ObjectManage.DeviceNew.Data.AlarmType3 & 0x01) > 0 ? "Cumulative" : "Single";
                            if (ObjectManage.DeviceNew.Data.RunStatus != 1)
                            {
                                AlarmA3Status = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[2] == 0 ? "OK" : "Alarm";
                                AlarmA4Status = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[3] == 0 ? "OK" : "Alarm";
                                AlarmA5Status = ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[4] == 0 ? "OK" : "Alarm";
                                if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[2] > 0)
                                {
                                    AlarmA3First = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[2].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                }
                                if (ObjectManage.DeviceNew.Data.AllZoneAlartStatusArray[3] > 0)
                                {
                                    AlarmA4First = ObjectManage.DeviceNew.Data.FirstAlarmTimeArray[3].ToString(Common.GetDefaultDateTimeFormat(), CultureInfo.InvariantCulture);
                                }

                                AlarmNumA2          = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[1];
                                AlarmNumA3          = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[2];
                                AlarmNumA4          = ObjectManage.DeviceNew.Data.AllZoneOverTempTimesStatArray[3];
                                AlarmTotalTimeA3    = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[2].ToString());
                                AlarmTotalTimeA4    = TempsenFormatHelper.ConvertSencondToFormmatedTime(ObjectManage.DeviceNew.Data.AllZoneOverTempTimeStatArray[3].ToString());
                                AlarmTotalTimeIdeal = TempsenFormatHelper.ConvertSencondToFormmatedTime(CalcMultiAlarmTotalTime("Ideal").ToString());
                            }
                        }
                        else
                        {
                            //<ToDo>
                        }
                        //Common.IsConnectCompleted = true;
                        //result= ObjectManage.DeviceNew.disconnectDevice();
                        result = true;
                        //return true;
                        #endregion
                    }
                    else
                    {
                        result = true;
                    }
                }
                Common.IsConnectCompleted = true;
                return(result);
            }
            catch
            {
                Common.IsConnectCompleted = true;
                return(false);
            }
        }