Пример #1
0
        protected override void GenerateDataList()
        {
            int   recordsCount  = this.device.tempList.Count;
            int   totalRowCount = recordsCount + 2;
            Range dataListRange = this.dataList.get_Range("A1", "B" + totalRowCount);

            dataListRange.Font.Name = "Arial";
            dataListRange.Columns[1].ColumnWidth = 18;
            dataListRange.Columns[2].ColumnWidth = 10;

            dataListRange.Cells[1, 1] = " Data List";
            this.setSectionTitleStyleForRange(dataListRange, 1);

            dataListRange.Cells[2, 1] = " Date Time";
            dataListRange.Cells[2, 2] = unit;
            this.setTableHeaderStyleForRange(dataListRange, 2);
            dataListRange.get_Range("A2", "B2").Borders.Color = Color.Black;
            this.SetEdgeBorderForRange(dataListRange.get_Range("A3", string.Format("B{0}", totalRowCount)));

            ProcessAlarmLimits(totalRowCount);

            for (int i = 0; i < this.device.tempList.Count; i++)
            {
                string dateTime = TempsenFormatHelper.GetFormattedDateTime(this.device.tempList[i].PointTime.ToLocalTime());
                dataListRange.Cells[i + 3, 1] = " " + dateTime;
                dataListRange.Cells[i + 3, 2] = TempsenFormatHelper.GetFormattedTemperature(this.device.tempList[i].PointTemp);
                this.setTableCellContentStyleForRange(dataListRange, i + 3, this.device.tempList[i].IsMark);
            }
        }
Пример #2
0
        public IDictionary <string, string[]> GetLoggingSummaryColumsContents(SuperDevice device, DeviceDataFrom deviceDatafrom)
        {
            IDictionary <string, string[]> result = new Dictionary <string, string[]>();

            string[] column1Contents = new string[5];
            string[] column2Contents = new string[5];

            result.Add("column1Contents", column1Contents);
            result.Add("column2Contents", column2Contents);

            column1Contents[0] = string.Format("Highest Temperature: {0}", Common.SetTempTimeFormat(device.HighestC));
            column1Contents[1] = string.Format("Lowest Temperature: {0}", Common.SetTempTimeFormat(device.LowestC));
            column1Contents[2] = string.Format("Average Temperature: {0}{1}", device.AverageC, string.IsNullOrEmpty(device.AverageC) ? string.Empty : "°" + device.TempUnit);
            column1Contents[3] = string.Format("Mean Kinetic Temperature: {0}{1}", device.MKT, string.IsNullOrEmpty(device.MKT) ? string.Empty : "°" + device.TempUnit);
            string finalString      = string.Empty;
            int    maxDisplayLength = 10;
            string loggerReader     = device.LoggerRead;

            if (loggerReader == null)
            {
                loggerReader = string.Empty;
            }
            string[] loggerReadereString = loggerReader.Split(new char[] { '@' });
            if (loggerReadereString.Length >= 2)
            {
                if (Common.Versions == SoftwareVersions.S || string.IsNullOrWhiteSpace(loggerReadereString[0]))
                {
                    finalString = string.Format("Logger Read: @{0}", TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(loggerReadereString[1])));
                }
                else if (Common.Versions == SoftwareVersions.Pro)
                {
                    if (loggerReadereString[0].Length > maxDisplayLength)
                    {
                        finalString = string.Format("Logger Read: By {0}@{1}", loggerReadereString[0].Substring(0, maxDisplayLength) + "...", TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(loggerReadereString[1])));
                    }
                    else
                    {
                        finalString = string.Format("Logger Read: By {0}@{1}", loggerReadereString[0], TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(loggerReadereString[1])));
                    }
                }
            }
            else
            {
                finalString = "Logger Read:";
            }

            column1Contents[4] = finalString;

            column2Contents[0] = string.Format("Start Time/First Point: {0}", device.LoggingStart == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(device.LoggingStart.ToLocalTime()));
            column2Contents[1] = string.Format("Stop Time: {0}", device.LoggingEnd == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(device.LoggingEnd.ToLocalTime()));
            column2Contents[2] = string.Format("Data Points: {0}", device.DataPoints == 0 ? string.Empty : device.DataPoints.ToString());
            column2Contents[3] = string.Format("Trip Length: {0}", device.TripLength);
            column2Contents[4] = string.Empty;
            return(result);
        }
Пример #3
0
        public IDictionary <string, string[]> GetDeviceConfigurationTripInfoRowsContents(SuperDevice device)
        {
            IDictionary <string, string[]> result = new Dictionary <string, string[]>();

            string[] row1Contents = new string[2];
            string[] row2Contents = new string[2];
            string[] row3Contents = new string[2];

            string[] tripInfoContents = new string[3];

            result.Add("row1Contents", row1Contents);
            result.Add("row2Contents", row2Contents);
            result.Add("row3Contents", row3Contents);
            result.Add("tripInfoContents", tripInfoContents);
            if (device != null)
            {
                row1Contents[0] = string.Format("Device: {0}", device.DeviceName);
                row1Contents[1] = string.Format("Model: {0}", device.Model);
                row2Contents[0] = string.Format("Serial Number: {0}", device.SerialNumber);
                row2Contents[1] = string.Format("Log Interval/Cycle: {0}{2}{1}", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.LogInterval), device.LogCycle, "/");
                row3Contents[0] = string.Format("Start Mode: {0}", device.StartModel);
                if (device.StartModel == "Manual Start")
                {
                    row3Contents[1] = string.Format("Start Delay: {0}", device.LogStartDelay);
                }
                else
                {
                    row3Contents[1] = string.Empty;
                }
                string tripNumberWithoutSuffix = string.Empty;
                if (device.TripNumber != null && device.TripNumber.IndexOf('_') != -1)
                {
                    tripNumberWithoutSuffix = device.TripNumber.Substring(0, device.TripNumber.IndexOf('_'));
                }
                else
                {
                    tripNumberWithoutSuffix = device.TripNumber;
                }

                tripInfoContents[0] = tripNumberWithoutSuffix;
                tripInfoContents[1] = device.DeviceID < 200 ? string.Empty : "Description: ";
                string rawDescription = string.IsNullOrWhiteSpace(device.Description) ? string.Empty : device.Description;
                if (device.DeviceID < 200)
                {
                    tripInfoContents[2] = string.Empty;
                }
                else
                {
                    tripInfoContents[2] = rawDescription;
                }
            }
            return(result);
        }
Пример #4
0
        protected override void GenerateSignatures()
        {
            if (this.isSignatureShown)
            {
                Range signatureTitleRange = this.getSectionRangeFromSummary(1);
                signatureTitleRange[1, 1] = "Electronic Signatures";
                this.setSectionTitleStyleForRange(signatureTitleRange, 1);

                Range signatureHeaderRange = this.getSectionRangeFromSummary(1, false);
                signatureHeaderRange.Borders.Color = Color.Black;
                signatureHeaderRange[1, 1]         = "Index";
                signatureHeaderRange[1, 2]         = "User Name";
                signatureHeaderRange[1, 3]         = "Full Name";
                signatureHeaderRange[1, 4]         = "Meaning";
                signatureHeaderRange[1, 5]         = "Date";
                signatureHeaderRange[1, 6]         = "Time";
                this.setTableHeaderStyleForRange(signatureHeaderRange, 1);

                Range range = this.getSectionRangeFromSummary(this.signatureList.Count, false, true);
                range.Borders.Color = Color.Black;
                for (int i = 0; i < this.signatureList.Count; i++)
                {
                    string index    = (i + 1).ToString();
                    string userName = this.signatureList[i].UserName;
                    string fullName = this.signatureList[i].FullName;
                    string meaning  = this.signatureList[i].MeaningDesc;
                    string date     = TempsenFormatHelper.GetFormattedDate(this.signatureList[i].SignTime.ToLocalTime());
                    string time     = TempsenFormatHelper.GetFormattedTime(this.signatureList[i].SignTime.ToLocalTime());

                    range[i + 1, 1] = index;
                    range[i + 1, 2] = userName;
                    range[i + 1, 3] = fullName;
                    range[i + 1, 4] = meaning;
                    range[i + 1, 5] = date;
                    range[i + 1, 6] = time;
                    this.setTableCellContentStyleForRange(range, i + 1);
                }
            }
            Range testRange = this.getSectionRangeFromSummary(3);
        }
Пример #5
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";
        }
Пример #6
0
        public IDictionary <string, string[]> GetAlarmRowContents(SuperDevice device)
        {
            IDictionary <string, string[]> result = new Dictionary <string, string[]>();

            string[] highRowContents = new string[6];
            string[] lowRowContents  = new string[6];
            string[] a1RowContents   = new string[6];
            string[] a2RowContents   = new string[6];
            string[] a3RowContents   = new string[6];
            string[] a4RowContents   = new string[6];
            string[] a5RowContents   = new string[6];
            string[] a6RowContents   = new string[6];

            result.Add("highRowContents", highRowContents);
            result.Add("lowRowContents", lowRowContents);
            result.Add("a1RowContents", a1RowContents);
            result.Add("a2RowContents", a2RowContents);
            result.Add("a3RowContents", a3RowContents);
            result.Add("a4RowContents", a4RowContents);
            result.Add("a5RowContents", a5RowContents);
            result.Add("a6RowContents", a6RowContents);

            if (device.AlarmMode == 1)
            {
                if (!string.IsNullOrEmpty(device.AlarmLowLimit))
                {
                    lowRowContents[0] = string.Format("Low limit: {0}°{1}", device.AlarmLowLimit, device.TempUnit);
                    lowRowContents[1] = string.Format("{0}({1})", device.AlarmLowDelay, device.LowAlarmType);
                    lowRowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.LowAlarmTotalTimeBelow);
                    lowRowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.LowAlarmEvents.ToString());
                    if (device.LowAlarmEvents > 0)
                    {
                        lowRowContents[4] = string.Format("{0}", Convert.ToDateTime(device.LowAlarmFirstTrigged) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.LowAlarmFirstTrigged).ToLocalTime()));
                    }
                    else
                    {
                        lowRowContents[4] = string.Empty;
                    }
                    lowRowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmLowStatus);
                }
                else
                {
                    lowRowContents[0] = "Low limit: ";
                }
                if (!string.IsNullOrEmpty(device.AlarmHighLimit))
                {
                    highRowContents[0] = string.Format("High limit: {0}°{1}", device.AlarmHighLimit, device.TempUnit);
                    highRowContents[1] = string.Format("{0}({1})", device.AlarmHighDelay, device.HighAlarmType);
                    highRowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.HighAlarmTotalTimeAbove);
                    highRowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.HighAlarmEvents.ToString());
                    if (device.HighAlarmEvents > 0)
                    {
                        highRowContents[4] = string.Format("{0}", Convert.ToDateTime(device.HighAlarmFirstTrigged) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.HighAlarmFirstTrigged).ToLocalTime()));
                    }
                    else
                    {
                        highRowContents[4] = string.Empty;
                    }

                    highRowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmHighStatus);
                }
                else
                {
                    highRowContents[0] = "High limit: ";
                }
            }
            else if (device.AlarmMode == 2)
            {
                if (!string.IsNullOrEmpty(device.A1))
                {
                    a1RowContents[0] = string.Format("A1: over {0}°{1}", device.A1, device.TempUnit);
                    a1RowContents[1] = string.Format("{0}({1})", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.AlarmDelayA1.ToString()), device.AlarmTypeA1);
                    a1RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeA1);
                    a1RowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmNumA1.ToString());
                    if (device.AlarmNumA1 > 0)
                    {
                        a1RowContents[4] = string.Format("{0}", Convert.ToDateTime(device.AlarmA1First) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.AlarmA1First).ToLocalTime()));
                    }
                    else
                    {
                        a1RowContents[4] = string.Empty;
                    }
                    a1RowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmA1Status);
                }
                else
                {
                    a1RowContents[0] = "A1: ";
                }
                //a5
                if (!string.IsNullOrEmpty(device.A2))
                {
                    a2RowContents[0] = string.Format("A2: over {0}°{1}", device.A2, device.TempUnit);
                    a2RowContents[1] = string.Format("{0}({1})", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.AlarmDelayA2.ToString()), device.AlarmTypeA2);
                    a2RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeA2);
                    a2RowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmNumA2.ToString());
                    if (device.AlarmNumA2 > 0)
                    {
                        a2RowContents[4] = string.Format("{0}", Convert.ToDateTime(device.AlarmA2First) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.AlarmA2First).ToLocalTime()));
                    }
                    else
                    {
                        a2RowContents[4] = string.Empty;
                    }
                    a2RowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmA2Status);
                }
                else
                {
                    a2RowContents[0] = "A2: ";
                }
                //a4
                if (!string.IsNullOrEmpty(device.A3))
                {
                    a3RowContents[0] = string.Format("A3: over {0}°{1}", device.A3, device.TempUnit);
                    a3RowContents[1] = string.Format("{0}({1})", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.AlarmDelayA3.ToString()), device.AlarmTypeA3);
                    a3RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeA3);
                    a3RowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmNumA3.ToString());
                    if (device.AlarmNumA3 > 0)
                    {
                        a3RowContents[4] = string.Format("{0}", Convert.ToDateTime(device.AlarmA3First) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.AlarmA3First).ToLocalTime()));
                    }
                    else
                    {
                        a3RowContents[4] = string.Empty;
                    }
                    a3RowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmA3Status);
                }
                else
                {
                    a3RowContents[0] = "A3: ";
                }
                //a3
                a4RowContents[0] = string.Format("A4: {0} to {1}°{2}", device.A4, device.A3, device.TempUnit);
                a4RowContents[1] = string.Format("{0}", "Unlimited");
                a4RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeIdeal);
                //a2
                if (!string.IsNullOrEmpty(device.A4))
                {
                    a5RowContents[0] = string.Format("A5: under {0}°{1}", device.A4, device.TempUnit);
                    a5RowContents[1] = string.Format("{0}({1})", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.AlarmDelayA4.ToString()), device.AlarmTypeA4);
                    a5RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeA4);
                    a5RowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmNumA4.ToString());
                    if (device.AlarmNumA4 > 0)
                    {
                        a5RowContents[4] = string.Format("{0}", Convert.ToDateTime(device.AlarmA4First) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.AlarmA4First).ToLocalTime()));
                    }
                    else
                    {
                        a5RowContents[4] = string.Empty;
                    }
                    a5RowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmA4Status);
                }
                else
                {
                    a5RowContents[0] = "A5: ";
                }
                //a1
                if (!string.IsNullOrEmpty(device.A5))
                {
                    a6RowContents[0] = string.Format("A6: under {0}°{1}", device.A5, device.TempUnit);
                    a6RowContents[1] = string.Format("{0}({1})", TempsenFormatHelper.ConvertSencondToFormmatedTime(device.AlarmDelayA5.ToString()), device.AlarmTypeA5);
                    a6RowContents[2] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmTotalTimeA5);
                    a6RowContents[3] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmNumA5.ToString());
                    if (device.AlarmNumA5 > 0)
                    {
                        a6RowContents[4] = string.Format("{0}", Convert.ToDateTime(device.AlarmA5First) == DateTime.MinValue ? string.Empty : TempsenFormatHelper.GetFormattedDateTime(Convert.ToDateTime(device.AlarmA5First).ToLocalTime()));
                    }
                    else
                    {
                        a6RowContents[4] = string.Empty;
                    }
                    a6RowContents[5] = string.Format("{0}", device.tempList.Count == 0 ? string.Empty : device.AlarmA5Status);
                }
                else
                {
                    a6RowContents[0] = "A6: ";
                }
            }
            return(result);
        }
Пример #7
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;
 }
Пример #8
0
        protected override void GenerateDataList()
        {
            if (!this.isSignatureShown)
            {
                this.document.NewPage();
            }
            PdfPTable dataListTable = null;

            PdfPCell[] dataListCells = null;
            int        columnIndex   = 0;

            float[]   listCellLayout   = new float[] { 0.37f, 0.43f, 0.20f };
            PdfPTable cellContentTable = null;
            int       cellDataCount    = 100;
            int       columnPerPage    = 4;
            int       dataPerPage      = cellDataCount * columnPerPage;

            cellContentTable = PdfElementGenerator.createTable(listCellLayout, false, true);
            for (int i = 0; i < Math.Min((cellDataCount - this.rowsInfectedBySignature) * columnPerPage, this.device.tempList.Count); i++)
            {
                if (i != 0 && i % (cellDataCount - this.rowsInfectedBySignature) == 0)
                {
                    if (cellContentTable != null)
                    {
                        dataListCells[columnIndex] = new PdfPCell(cellContentTable);
                    }
                    cellContentTable = PdfElementGenerator.createTable(listCellLayout, false, true);
                    columnIndex      = (i / (cellDataCount - this.rowsInfectedBySignature)) % columnPerPage;
                }
                if (i % dataPerPage == 0)
                {
                    dataListTable = PdfElementGenerator.createTable(new float[] { 0.25f, 0.25f, 0.25f, 0.25f }, true);
                    PdfPCell[] headerRowCells = dataListTable.Rows[0].GetCells();
                    for (int j = 0; j < headerRowCells.Length; j++)
                    {
                        PdfPTable  headerTable = PdfElementGenerator.createTable(listCellLayout, false, true);
                        PdfPCell[] headerCells = headerTable.Rows[0].GetCells();
                        headerCells[0].Phrase = PdfElementGenerator.createTableHeaderPhrase("Date");
                        headerCells[1].Phrase = PdfElementGenerator.createTableHeaderPhrase("Time");
                        headerCells[2].Phrase = PdfElementGenerator.createTableHeaderPhrase(unit);
                        foreach (var item in headerCells)
                        {
                            item.HorizontalAlignment = Element.ALIGN_CENTER;
                            //item.PaddingTop = 1f;
                        }
                        headerRowCells[j]            = new PdfPCell(headerTable);
                        headerRowCells[j].PaddingTop = 2f;
                    }
                    dataListCells = PdfElementGenerator.AddEmptyRowToTable(dataListTable, true, true);
                }
                PdfPCell[] rowCells = PdfElementGenerator.AddEmptyRowToTable(cellContentTable, false, false);
                rowCells[0].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedDate(this.device.tempList[i].PointTime.ToLocalTime()), this.device.tempList[i].IsMark);
                rowCells[1].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedTime(this.device.tempList[i].PointTime.ToLocalTime()), this.device.tempList[i].IsMark);
                rowCells[2].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedTemperature(this.device.tempList[i].PointTemp), this.device.tempList[i].IsMark);
                foreach (var item in rowCells)
                {
                    item.HorizontalAlignment = Element.ALIGN_CENTER;
                    item.PaddingLeft         = 0;
                    item.PaddingRight        = 0;
                    item.PaddingTop          = 0.0f;
                    item.PaddingBottom       = 0.8f;
                }
                if (i == Math.Min((cellDataCount - this.rowsInfectedBySignature) * columnPerPage, this.device.tempList.Count) - 1)
                {
                    dataListCells[columnIndex] = new PdfPCell(cellContentTable);
                    for (int j = columnPerPage - 1; j > columnIndex; j--)
                    {
                        dataListTable.Rows[0].GetCells()[j].Phrase = PdfElementGenerator.createTableHeaderPhrase(string.Empty);
                    }
                    this.document.Add(PdfElementGenerator.createSectionFrameTable(dataListTable, false));
                    cellContentTable = null;
                    dataListTable    = null;
                    columnIndex      = 0;
                    break;
                }
            }
            for (int i = (cellDataCount - this.rowsInfectedBySignature) * columnPerPage; i < device.tempList.Count; i++)
            {
                int k = i - ((cellDataCount - this.rowsInfectedBySignature) * columnPerPage);
                if (k == 0)
                {
                    cellContentTable = PdfElementGenerator.createTable(listCellLayout, false, true);
                }
                if (k != 0 && k % cellDataCount == 0)
                {
                    if (cellContentTable != null)
                    {
                        dataListCells[columnIndex] = new PdfPCell(cellContentTable);
                    }
                    cellContentTable = PdfElementGenerator.createTable(listCellLayout, false, true);
                    columnIndex      = (k / cellDataCount) % columnPerPage;
                }
                if (k % dataPerPage == 0)
                {
                    if (dataListTable != null)
                    {
                        this.document.Add(PdfElementGenerator.createSectionFrameTable(dataListTable, false));
                    }
                    dataListTable = PdfElementGenerator.createTable(new float[] { 0.25f, 0.25f, 0.25f, 0.25f }, true);
                    PdfPCell[] headerRowCells = dataListTable.Rows[0].GetCells();
                    for (int j = 0; j < headerRowCells.Length; j++)
                    {
                        PdfPTable  headerTable = PdfElementGenerator.createTable(listCellLayout, false, true);
                        PdfPCell[] headerCells = headerTable.Rows[0].GetCells();
                        headerCells[0].Phrase = PdfElementGenerator.createTableHeaderPhrase("Date");
                        headerCells[1].Phrase = PdfElementGenerator.createTableHeaderPhrase("Time");
                        headerCells[2].Phrase = PdfElementGenerator.createTableHeaderPhrase(unit);
                        foreach (var item in headerCells)
                        {
                            item.HorizontalAlignment = Element.ALIGN_CENTER;
                        }
                        headerRowCells[j]            = new PdfPCell(headerTable);
                        headerRowCells[j].PaddingTop = 2f;
                    }
                    dataListCells = PdfElementGenerator.AddEmptyRowToTable(dataListTable, true, true);
                }
                PdfPCell[] rowCells = PdfElementGenerator.AddEmptyRowToTable(cellContentTable, false, false);
                rowCells[0].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedDate(this.device.tempList[i].PointTime.ToLocalTime()), this.device.tempList[i].IsMark);
                rowCells[1].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedTime(this.device.tempList[i].PointTime.ToLocalTime()), this.device.tempList[i].IsMark);
                rowCells[2].Phrase = PdfElementGenerator.createDataListContentPhrase(TempsenFormatHelper.GetFormattedTemperature(this.device.tempList[i].PointTemp), this.device.tempList[i].IsMark);
                foreach (var item in rowCells)
                {
                    item.HorizontalAlignment = Element.ALIGN_CENTER;
                    item.PaddingLeft         = 0;
                    item.PaddingRight        = 0;
                    item.PaddingTop          = 0.0f;
                    item.PaddingBottom       = 0.8f;
                }
                if (i == device.tempList.Count - 1)
                {
                    dataListCells[columnIndex] = new PdfPCell(cellContentTable);
                    for (int j = columnPerPage - 1; j > columnIndex; j--)
                    {
                        dataListTable.Rows[0].GetCells()[j].Phrase = PdfElementGenerator.createTableHeaderPhrase(string.Empty);
                    }
                    this.document.Add(PdfElementGenerator.createSectionFrameTable(dataListTable, false));
                    break;
                }
            }
        }
Пример #9
0
        protected override void GenerateDataList()
        {
            IList <PointKeyValue> dataList         = this.device.tempList;
            TableLayoutPanel      dataListTable    = null;
            int            columnIndex             = 0;
            int            cellContentSectionWidth = (DefaultSectionWidth - 4) / 3;
            int            cellDataCount           = 100;
            int            columnPerPage           = 4;
            int            dataPerPage             = cellDataCount * columnPerPage;
            SectionControl cellContentSection      = null;
            SectionControl tableHearderSection     = null;

            dataListTable     = this.CreateDataListTableLayoutPanel(true);
            dataListTable.Top = this.currentSectionTop + sectionMargin * 2;
            for (int i = 0; i < Math.Min((cellDataCount - this.rowsInfectedBySignature) * columnPerPage, this.device.tempList.Count); i++)
            {
                if (i % (cellDataCount - this.rowsInfectedBySignature) == 0)
                {
                    if (cellContentSection != null)
                    {
                        dataListTable.SetCellPosition(tableHearderSection, new TableLayoutPanelCellPosition(columnIndex, 0));
                        dataListTable.SetCellPosition(cellContentSection, new TableLayoutPanelCellPosition(columnIndex, 1));
                        tableHearderSection.InitializeLayout(dataListTableColumnWidthsLayout);
                        cellContentSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    }
                    tableHearderSection = new SectionControl(false);
                    cellContentSection  = new SectionControl(false);
                    cellContentSection.IsDataListContentSection = true;
                    dataListTable.Controls.Add(cellContentSection);
                    dataListTable.Controls.Add(tableHearderSection);
                    tableHearderSection.Width = cellContentSectionWidth;
                    cellContentSection.Width  = cellContentSectionWidth;
                    cellContentSection.IsContentWithSmallFont  = true;
                    tableHearderSection.IsContentWithSmallFont = true;
                    tableHearderSection.HorizonalTextAlignment = ContentAlignment.MiddleCenter;
                    cellContentSection.HorizonalTextAlignment  = ContentAlignment.MiddleCenter;
                    cellContentSection.IsBorderShown           = false;
                    tableHearderSection.IsBorderShown          = false;
                    tableHearderSection.DefaultRowHeight       = 16;
                    cellContentSection.DefaultRowHeight        = 11.2f;

                    tableHearderSection.SetHeader(new string[] { "Date", "Time", unit });
                    columnIndex = (i / (cellDataCount - this.rowsInfectedBySignature)) % columnPerPage;
                }
                cellContentSection.AddRow(new string[] { TempsenFormatHelper.GetFormattedDate(dataList[i].PointTime.ToLocalTime()),
                                                         TempsenFormatHelper.GetFormattedTime(dataList[i].PointTime.ToLocalTime()),
                                                         TempsenFormatHelper.GetFormattedTemperature(dataList[i].PointTemp),
                                                         dataList[i].IsMark.ToString() });

                if (i == Math.Min((cellDataCount - this.rowsInfectedBySignature) * columnPerPage, this.device.tempList.Count) - 1)
                {
                    dataListTable.SetCellPosition(tableHearderSection, new TableLayoutPanelCellPosition(columnIndex, 0));
                    dataListTable.SetCellPosition(cellContentSection, new TableLayoutPanelCellPosition(columnIndex, 1));
                    tableHearderSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    cellContentSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    this.AddSection(dataListTable);
                    this.GenerateReportFooter();
                    cellContentSection = null;
                    dataListTable      = null;
                }
            }

            for (int i = (cellDataCount - this.rowsInfectedBySignature) * columnPerPage; i < device.tempList.Count; i++)
            {
                int j = i - ((cellDataCount - this.rowsInfectedBySignature) * columnPerPage);
                if (j % dataPerPage == 0)
                {
                    if (dataListTable != null)
                    {
                        this.AddSection(dataListTable);
                    }
                    dataListTable = this.CreateDataListTableLayoutPanel();
                }
                if (j % cellDataCount == 0)
                {
                    if (cellContentSection != null)
                    {
                        dataListTable.SetCellPosition(tableHearderSection, new TableLayoutPanelCellPosition(columnIndex, 0));
                        dataListTable.SetCellPosition(cellContentSection, new TableLayoutPanelCellPosition(columnIndex, 1));
                        tableHearderSection.InitializeLayout(dataListTableColumnWidthsLayout);
                        cellContentSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    }
                    tableHearderSection = new SectionControl(false);
                    cellContentSection  = new SectionControl(false);
                    cellContentSection.IsDataListContentSection = true;
                    dataListTable.Controls.Add(cellContentSection);
                    dataListTable.Controls.Add(tableHearderSection);
                    tableHearderSection.Width = cellContentSectionWidth;
                    cellContentSection.Width  = cellContentSectionWidth;
                    cellContentSection.IsContentWithSmallFont  = true;
                    tableHearderSection.IsContentWithSmallFont = true;
                    tableHearderSection.HorizonalTextAlignment = ContentAlignment.MiddleCenter;
                    cellContentSection.HorizonalTextAlignment  = ContentAlignment.MiddleCenter;
                    cellContentSection.IsBorderShown           = false;
                    tableHearderSection.IsBorderShown          = false;
                    tableHearderSection.DefaultRowHeight       = 16;
                    cellContentSection.DefaultRowHeight        = 11.2f;

                    tableHearderSection.SetHeader(new string[] { "Date", "Time", unit });
                    columnIndex = (j / cellDataCount) % 4;
                }
                cellContentSection.AddRow(new string[] { TempsenFormatHelper.GetFormattedDate(dataList[i].PointTime.ToLocalTime()),
                                                         TempsenFormatHelper.GetFormattedTime(dataList[i].PointTime.ToLocalTime()),
                                                         TempsenFormatHelper.GetFormattedTemperature(dataList[i].PointTemp),
                                                         dataList[i].IsMark.ToString() });

                if (i == device.tempList.Count - 1)
                {
                    dataListTable.SetCellPosition(tableHearderSection, new TableLayoutPanelCellPosition(columnIndex, 0));
                    dataListTable.SetCellPosition(cellContentSection, new TableLayoutPanelCellPosition(columnIndex, 1));
                    tableHearderSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    cellContentSection.InitializeLayout(dataListTableColumnWidthsLayout);
                    this.AddSection(dataListTable);
                    this.GenerateReportFooter();
                }
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
 public virtual bool WriteConfiguration(ConfigurationProfile cfg)
 {
     //DevicePDF device = new DevicePDF();
     try
     {
         //device = this.Pdf;
         if (ObjectManage.DeviceNew != null)
         {
             ObjectManage.DeviceNew.Data.TripNo      = cfg.Tn;
             ObjectManage.DeviceNew.Data.Description = cfg.Desc;
             //ObjectManage.DeviceNew.Data.AlarmType = cfg.
             ObjectManage.DeviceNew.Data.TemperatureUnit = cfg.TempUnit == "C" ? 1 : 2;
             ObjectManage.DeviceNew.Data.LogInterval     = Convert.ToInt32(cfg.LogIntervalH) * 3600 + Convert.ToInt32(cfg.LogIntervalM) * 60 + Convert.ToInt32(cfg.LogIntervalS);
             string cycle = TempsenFormatHelper.GetSecondsFromFormatString(cfg.LogCycle);
             ObjectManage.DeviceNew.Data.LogCycle = Convert.ToInt32(cycle) / 3600;//log cycle
             //if (cycle.Count > 1)
             //    ObjectManage.DeviceNew.Data.LogCycle += cycle[1];
             if (cfg.StartMode == "Manual Start")
             {
                 ObjectManage.DeviceNew.Data.StartDelay = (Convert.ToInt32(cfg.StartDelayD) * 1440 + Convert.ToInt32(cfg.StartDelayH) * 60 + Convert.ToInt32(cfg.StartDelayM));
                 ObjectManage.DeviceNew.Data.StartMode  = "F8";
             }
             else
             {
                 ObjectManage.DeviceNew.Data.StartConditionTime = Convert.ToDateTime(cfg.StartDate).ToUniversalTime();//UTC时间写入
                 //ObjectManage.DeviceNew.Data.StartConditionTime = Convert.ToDateTime(cfg.StartDate);
                 ObjectManage.DeviceNew.Data.StartMode = "8F";
             }
             if (cfg.IsSingleAlarm)
             {
                 ObjectManage.DeviceNew.Data.AlarmMode = 1;
                 if (cfg.IsHighLimit)
                 {
                     ObjectManage.DeviceNew.Data.AlarmLimits2 = cfg.HighTemp;
                     ObjectManage.DeviceNew.Data.AlarmType2   = cfg.HighAlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193);
                     ObjectManage.DeviceNew.Data.AlarmDelay2  = cfg.HighDay * 24 * 3600 + cfg.HighH * 3600 + cfg.HighM * 60;
                 }
                 else
                 {
                     ObjectManage.DeviceNew.Data.AlarmType2 = Convert.ToByte(0);
                 }
                 if (cfg.IsLowLimit)
                 {
                     ObjectManage.DeviceNew.Data.AlarmLimits3 = cfg.LowTemp;
                     ObjectManage.DeviceNew.Data.AlarmType3   = cfg.LowAlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129);
                     ObjectManage.DeviceNew.Data.AlarmDelay3  = cfg.LowDay * 24 * 3600 + cfg.LowH * 3600 + cfg.LowM * 60;
                 }
                 else
                 {
                     ObjectManage.DeviceNew.Data.AlarmType3 = Convert.ToByte(0);
                 }
                 ObjectManage.DeviceNew.Data.AlarmType0 = Convert.ToByte(0);
                 ObjectManage.DeviceNew.Data.AlarmType1 = Convert.ToByte(0);
                 ObjectManage.DeviceNew.Data.AlarmType4 = Convert.ToByte(0);
             }
             else if (cfg.IsMultiAlarm)
             {
                 ObjectManage.DeviceNew.Data.AlarmMode = 2;
                 if (cfg.IsA6)
                 {
                     ObjectManage.DeviceNew.Data.AlarmLimits0 = cfg.A6Temp;
                     ObjectManage.DeviceNew.Data.AlarmType0   = cfg.A6AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193);
                     ObjectManage.DeviceNew.Data.AlarmDelay0  = cfg.A6Day * 24 * 3600 + cfg.A6H * 3600 + cfg.A6M * 60;
                 }
                 else
                 {
                     ObjectManage.DeviceNew.Data.AlarmType0 = Convert.ToByte(0);
                 }
                 if (cfg.IsA5)
                 {
                     ObjectManage.DeviceNew.Data.AlarmLimits1 = cfg.A5Temp;
                     ObjectManage.DeviceNew.Data.AlarmType1   = cfg.A5AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193);
                     ObjectManage.DeviceNew.Data.AlarmDelay1  = cfg.A5Day * 24 * 3600 + cfg.A5H * 3600 + cfg.A5M * 60;
                 }
                 else
                 {
                     ObjectManage.DeviceNew.Data.AlarmType1 = Convert.ToByte(0);
                 }
                 ObjectManage.DeviceNew.Data.AlarmLimits2 = cfg.A4Temp;
                 ObjectManage.DeviceNew.Data.AlarmLimits3 = cfg.A3Temp;
                 if (cfg.IsA1)
                 {
                     ObjectManage.DeviceNew.Data.AlarmLimits4 = cfg.A1Temp;
                     ObjectManage.DeviceNew.Data.AlarmType4   = cfg.A1AlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129);
                     ObjectManage.DeviceNew.Data.AlarmDelay4  = cfg.A1Day * 24 * 3600 + cfg.A1H * 3600 + cfg.A1M * 60;
                 }
                 else
                 {
                     ObjectManage.DeviceNew.Data.AlarmType4 = Convert.ToByte(0);
                 }
                 ObjectManage.DeviceNew.Data.AlarmType2  = cfg.A4AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193);
                 ObjectManage.DeviceNew.Data.AlarmType3  = cfg.A2AlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129);
                 ObjectManage.DeviceNew.Data.AlarmDelay2 = cfg.A4Day * 24 * 3600 + cfg.A4H * 3600 + cfg.A4M * 60;
                 ObjectManage.DeviceNew.Data.AlarmDelay3 = cfg.A2Day * 24 * 3600 + cfg.A2H * 3600 + cfg.A2M * 60;
             }
             else
             {
                 ObjectManage.DeviceNew.Data.AlarmMode = 0;
             }
             return(ObjectManage.DeviceNew.DoWrite());
         }
         return(false);
     }
     catch
     {
         //ObjectManage.DeviceNew.disconnectDevice();
         return(false);
     }
 }