Пример #1
0
        public void DoSetSpreadSheet(object sender, EventArgs e)
        {
            if (this.InvokeRequired == true)
            {
                EventHandler func = new EventHandler(DoSetSpreadSheet);
                this.BeginInvoke(func, new object[] { sender, e });
            }
            else
            {
                TestSpreadSheetArgs sheet = e as TestSpreadSheetArgs;

                switch (sheet.Index)
                {
                case EWorkSheet.Current:
                    SetSpreadSheetCurrentValues(sheet);
                    break;

                case EWorkSheet.Title:
                    SetSpreadSheetTitleItems(sheet);
                    break;

                default:
                    SetSpreadSheetIntegralValues(sheet);
                    break;
                }
            }
        }
Пример #2
0
        private void SetSpreadSheetIntegralValues(TestSpreadSheetArgs sheet)
        {
            int index = (int)sheet.Index - 1;

            reportSheet.BeginUpdate();
            sheet.Report.Lock();

            try
            {
                foreach (KeyValuePair <string, ReportSheet> valueSheet in sheet.Report.ValueSheets)
                {
                    if (valueSheet.Key == "Raw Data")
                    {
                        break;
                    }
                    if (valueSheet.Value.Use == false)
                    {
                        continue;
                    }

                    sheetTags.Sheets[valueSheet.Key]["{min-0}"].Value = "Average";

                    string cellTag, tag1, tag2, state = "";
                    foreach (KeyValuePair <string, ReportRow> row in valueSheet.Value.Rows)
                    {
                        cellTag = row.Value.Cells[index].Tag;
                        tag2    = "{" + cellTag + "}";

                        if (float.IsNaN(row.Value.Cells[index].Raw) == true)
                        {
                            sheetTags.Sheets[valueSheet.Key][tag2].Value = "";
                        }
                        else
                        {
                            if (row.Value.Row == null)
                            {
                                sheetTags.Sheets[valueSheet.Key][tag2].Value = "";
                            }
                            else
                            {
                                if (row.Key.EndsWith("Nozzle") == true)
                                {
                                    state = GetNozzleState((byte)row.Value.Row.Value);
                                    sheetTags.Sheets[valueSheet.Key][tag2].Value = state;
                                }
                                else
                                {
                                    sheetTags.Sheets[valueSheet.Key][tag2].NumberFormat = row.Value.Cells[index].Format;
                                    sheetTags.Sheets[valueSheet.Key][tag2].Value        = row.Value.Row.Unit.Convert(row.Value.Cells[index].Raw);
                                }
                            }
                        }

                        if (sheet.SettingAverage == true)
                        {
                            tag1 = "{" + cellTag.Substring(0, cellTag.Length - 1) + "0}";

                            if (float.IsNaN(row.Value.Average) == true)
                            {
                                sheetTags.Sheets[valueSheet.Key][tag1].Value = "";
                            }
                            else
                            {
                                if (row.Value.Row == null)
                                {
                                    sheetTags.Sheets[valueSheet.Key][tag1].Value = "";
                                }
                                else
                                {
                                    if (row.Key.EndsWith("Nozzle") == true)
                                    {
                                        sheetTags.Sheets[valueSheet.Key][tag1].Value = state;
                                    }
                                    else
                                    {
                                        if (string.IsNullOrWhiteSpace(row.Value.Cells[0].Format) == false)
                                        {
                                            sheetTags.Sheets[valueSheet.Key][tag1].NumberFormat = row.Value.Cells[0].Format;
                                        }

                                        sheetTags.Sheets[valueSheet.Key][tag1].Value = row.Value.Row.Unit.Convert(row.Value.Average);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                sheet.Report.Unlock();
                reportSheet.EndUpdate();
            }
        }
Пример #3
0
        private void SetSpreadSheetTitleItems(TestSpreadSheetArgs sheet)
        {
            ValueRow       row;
            ConditionNote  note  = sheet.Report.Note;
            ConditionRated rated = sheet.Report.Rated;

            reportSheet.BeginUpdate();
            sheet.Report.Lock();

            try
            {
                foreach (KeyValuePair <string, Dictionary <string, Cell> > tags in sheetTags.Sheets)
                {
                    if (tags.Key == "Raw Data")
                    {
                        sheetTags.SetWorkSheetVisible(tags.Key, false);
                        continue;
                    }

                    bool sheetUse = sheet.Report.ValueSheets[tags.Key].Use;
                    sheetTags.SetWorkSheetVisible(tags.Key, sheetUse);

                    if (sheetUse == false)
                    {
                        continue;
                    }

                    tags.Value["{300}"].Value = note.Company;
                    tags.Value["{302}"].Value = note.Name;
                    tags.Value["{304}"].Value = note.No;
                    tags.Value["{306}"].Value = note.Observer;
                    tags.Value["{308}"].Value = note.Maker;
                    tags.Value["{310}"].Value = note.Model1;
                    tags.Value["{312}"].Value = note.Serial1;
                    tags.Value["{314}"].Value = note.Model2;
                    tags.Value["{316}"].Value = note.Serial2;

                    string str = note.Model3 + " / " + note.Serial3;

                    if (str.Trim() == "/")
                    {
                        tags.Value["{318}"].Value = "";
                    }
                    else
                    {
                        tags.Value["{318}"].Value = str;
                    }

                    tags.Value["{320}"].Value = $"{sheet.Report.ValueSheets[tags.Key].IndoorDB:f2} / {sheet.Report.ValueSheets[tags.Key].IndoorWB:f2} ℃";

                    if (sheet.Report.ValueSheets[tags.Key].IndoorUse == EIndoorUse.NotUsed)
                    {
                        tags.Value["{322}"].Value = sheet.Report.ValueSheets[tags.Key].IndoorUse.ToDescription();
                    }
                    else
                    {
                        tags.Value["{322}"].Value = $"{sheet.Report.ValueSheets[tags.Key].IndoorUse.ToDescription()}, {sheet.Report.ValueSheets[tags.Key].IndoorMode.ToDescription()}";
                    }

                    row = context.Value.Calcurated["Total.Capacity"];
                    tags.Value["{301}"].Value = $"{rated.Capacity.ToString(row.Format)} {row.Unit.ToDescription}";
                    row = context.Value.Calcurated["Total.Power"];
                    tags.Value["{303}"].Value = $"{rated.PowerInput.ToString(row.Format)} {row.Unit.ToDescription}";
                    row = context.Value.Calcurated["Total.EER_COP"];
                    tags.Value["{305}"].Value = $"{rated.EER_COP.ToString(row.Format)} {row.Unit.ToDescription}";
                    tags.Value["{307}"].Value = $"{rated.Voltage}V / {rated.Current}A / {rated.Frequency}Hz / {EnumHelper.GetNames<EWT330Wiring>()[(int)rated.Wiring]}";
                    tags.Value["{309}"].Value = note.ExpDevice;
                    tags.Value["{311}"].Value = note.Refrigerant;
                    tags.Value["{313}"].Value = note.RefCharge;
                    tags.Value["{315}"].Value = sheet.Report.RegTime.ToString(Resource.csDateTimeFormat);
                    tags.Value["{321}"].Value = $"{sheet.Report.ValueSheets[tags.Key].OutdoorDB:f2} / {sheet.Report.ValueSheets[tags.Key].OutdoorWB:f2} ℃";;

                    if (sheet.Report.ValueSheets[tags.Key].OutdoorDP == EEtcUse.Use)
                    {
                        tags.Value["{323}"].Value = $"{sheet.Report.ValueSheets[tags.Key].OutdoorUse.ToDescription()}, DP Used";
                    }
                    else
                    {
                        tags.Value["{323}"].Value = $"{sheet.Report.ValueSheets[tags.Key].OutdoorUse.ToDescription()}";
                    }

                    tags.Value["{299}"].Value = note.Memo;

                    if (tags.Key.EndsWith("TC") == false)
                    {
                        tags.Value["{365}"].Value = " " + sheet.Report.ValueSheets[tags.Key].NozzleName;
                    }

                    string cellTag;

                    for (int i = 0; i < 7; i++)
                    {
                        cellTag = "{" + $"min-{i + 1}" + "}";
                        tags.Value[cellTag].Value = (i < sheet.Report.Method.IntegralCount) ? $"{(i + 1) * sheet.Report.Method.IntegralTime} min" : "";
                    }

                    foreach (KeyValuePair <string, ReportRow> sheetRow in sheet.Report.ValueSheets[tags.Key].Rows)
                    {
                        cellTag = "{" + sheetRow.Value.Tag + "}";

                        if (sheetRow.Key.EndsWith("Nozzle") == false)
                        {
                            if (sheetRow.Value.Row == null)
                            {
                                tags.Value[cellTag].Value = "";
                            }
                            else
                            {
                                tags.Value[cellTag].Value = sheetRow.Value.Row.Unit.ToDescription;
                            }
                        }

                        if (tags.Key.EndsWith("TC") == true)
                        {
                            if (sheetRow.Value.Row == null)
                            {
                                tags.Value[cellTag].Value = "";
                            }
                            else
                            {
                                cellTag = "{" + sheetRow.Value.Tag + "-N}";
                                tags.Value[cellTag].Value = sheetRow.Value.Alias;
                            }
                        }
                    }
                }
            }
            finally
            {
                sheet.Report.Unlock();
                reportSheet.EndUpdate();
            }
        }
Пример #4
0
        private void SetSpreadSheetCurrentValues(TestSpreadSheetArgs sheet)
        {
            reportSheet.BeginUpdate();
            sheet.Report.Lock();

            try
            {
                foreach (KeyValuePair <string, ReportSheet> valueSheet in sheet.Report.ValueSheets)
                {
                    if (valueSheet.Key == "Raw Data")
                    {
                        break;
                    }
                    if (valueSheet.Value.Use == false)
                    {
                        continue;
                    }

                    sheetTags.Sheets[valueSheet.Key]["{min-0}"].Value = "Current";

                    bool   isAllNaN = true;
                    string cellTag, tag1;
                    foreach (KeyValuePair <string, ReportRow> row in valueSheet.Value.Rows)
                    {
                        cellTag = row.Value.Cells[0].Tag;
                        tag1    = "{" + cellTag.Substring(0, cellTag.Length - 1) + "0}";

                        if (float.IsNaN(row.Value.Cells[0].Raw) == true)
                        {
                            sheetTags.Sheets[valueSheet.Key][tag1].Value = "";
                        }
                        else
                        {
                            if (row.Value.Row == null)
                            {
                                sheetTags.Sheets[valueSheet.Key][tag1].Value = "";
                            }
                            else
                            {
                                if (row.Key.EndsWith("Nozzle") == true)
                                {
                                    sheetTags.Sheets[valueSheet.Key][tag1].Value = GetNozzleState((byte)row.Value.Row.Value);
                                }
                                else
                                {
                                    isAllNaN = false;
                                    sheetTags.Sheets[valueSheet.Key][tag1].NumberFormat = row.Value.Cells[0].Format;
                                    sheetTags.Sheets[valueSheet.Key][tag1].Value        = row.Value.Row.Unit.Convert(row.Value.Cells[0].Raw);
                                }
                            }
                        }
                    }

                    if (isAllNaN == true)
                    {
                        sheetTags.Sheets[valueSheet.Key]["{min-0}"].Value = "Average";
                    }
                }
            }
            finally
            {
                sheet.Report.Unlock();
                reportSheet.EndUpdate();
            }
        }