V1.0.0.7 - 2025/12/22

* Database improved all
This commit is contained in:
2025-12-22 12:46:46 +09:00
parent 79fea6964b
commit 0af235eb3d
14 changed files with 642 additions and 364 deletions

View File

@@ -1,14 +1,15 @@
using System; using DevExpress.XtraEditors;
using LFP_Manager.DataStructure;
using LFP_Manager.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Data; using System.Data;
using System.Text; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using DevExpress.XtraEditors;
using LFP_Manager.Utils;
using LFP_Manager.DataStructure;
namespace LFP_Manager.Controls namespace LFP_Manager.Controls
{ {
@@ -35,6 +36,11 @@ namespace LFP_Manager.Controls
#region PUBLIC UPDATE #region PUBLIC UPDATE
public void UpdateConfig(CommConfig aConfig)
{
this.Config = aConfig;
}
public void EventUpdate(int id, string aEvent) public void EventUpdate(int id, string aEvent)
{ {
if (this.InvokeRequired) if (this.InvokeRequired)
@@ -123,21 +129,38 @@ namespace LFP_Manager.Controls
meDataLog.Text = ""; meDataLog.Text = "";
} }
private void BtnRefresh_Click(object sender, EventArgs e) private async void BtnRefresh_Click(object sender, EventArgs e)
{ {
if (Config != null) if (Config == null) return;
{
try
{
string modelName = csConstData.UART_MODEL[Config.UartModelIndex];
AlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, "");
AlarmHistoryUpdate(AlarmHistory); BtnRefresh.Enabled = false;
} Cursor = Cursors.WaitCursor;
catch (Exception ex)
try
{
// DB 조회는 백그라운드에서
var now = DateTime.Now;
var table = await Task.Run(() => csDbUtils.GetBmsAlarmDataByDataTable(Config, now, ""));
// UI 바인딩
Action bind = () =>
{ {
_ = MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); AlarmHistory = table ?? new DataTable();
} GvAlarmHistory.DataSource = AlarmHistory;
};
if (InvokeRequired)
BeginInvoke(new MethodInvoker(() => bind())); // ← 새 MethodInvoker 생성
else
bind();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
Cursor = Cursors.Default;
BtnRefresh.Enabled = true;
} }
} }
@@ -166,8 +189,7 @@ namespace LFP_Manager.Controls
{ {
try try
{ {
string modelName = csConstData.UART_MODEL[Config.UartModelIndex]; AlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(Config, DateTime.Now, "");
AlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, "");
AlarmHistoryUpdate(AlarmHistory); AlarmHistoryUpdate(AlarmHistory);
} }
@@ -180,8 +202,7 @@ namespace LFP_Manager.Controls
{ {
try try
{ {
string modelName = csConstData.UART_MODEL[Config.UartModelIndex]; AlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(Config, DateTime.Now, "");
AlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, "");
AlarmHistoryUpdate(AlarmHistory); AlarmHistoryUpdate(AlarmHistory);
} }

View File

@@ -29,6 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl(); this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
this.CbLogType = new DevExpress.XtraEditors.ComboBoxEdit();
this.btnSearch = new System.Windows.Forms.Button(); this.btnSearch = new System.Windows.Forms.Button();
this.dtpEnd = new System.Windows.Forms.DateTimePicker(); this.dtpEnd = new System.Windows.Forms.DateTimePicker();
this.dtpStart = new System.Windows.Forms.DateTimePicker(); this.dtpStart = new System.Windows.Forms.DateTimePicker();
@@ -48,11 +49,17 @@
this.slbEndDate = new DevExpress.XtraLayout.SimpleLabelItem(); this.slbEndDate = new DevExpress.XtraLayout.SimpleLabelItem();
this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem(); this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem(); this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem7 = new DevExpress.XtraLayout.LayoutControlItem();
this.simpleLabelItem1 = new DevExpress.XtraLayout.SimpleLabelItem();
this.lcgbSearchResult = new DevExpress.XtraLayout.LayoutControlGroup(); this.lcgbSearchResult = new DevExpress.XtraLayout.LayoutControlGroup();
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
this.DbWaitForm = new DevExpress.XtraSplashScreen.SplashScreenManager(this, typeof(global::LFP_Manager.Forms.fmxWait), true, true, typeof(System.Windows.Forms.UserControl)); this.DbWaitForm = new DevExpress.XtraSplashScreen.SplashScreenManager(this, typeof(global::LFP_Manager.Forms.fmxWait), true, true, typeof(System.Windows.Forms.UserControl));
this.CbMdNo = new DevExpress.XtraEditors.ComboBoxEdit();
this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
this.simpleLabelItem2 = new DevExpress.XtraLayout.SimpleLabelItem();
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
this.layoutControl1.SuspendLayout(); this.layoutControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.CbLogType.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xtcSearchResult)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xtcSearchResult)).BeginInit();
this.xtcSearchResult.SuspendLayout(); this.xtcSearchResult.SuspendLayout();
this.pgGrid.SuspendLayout(); this.pgGrid.SuspendLayout();
@@ -70,12 +77,19 @@
((System.ComponentModel.ISupportInitialize)(this.slbEndDate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.slbEndDate)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lcgbSearchResult)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lcgbSearchResult)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CbMdNo.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem2)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// layoutControl1 // layoutControl1
// //
this.layoutControl1.Controls.Add(this.CbMdNo);
this.layoutControl1.Controls.Add(this.CbLogType);
this.layoutControl1.Controls.Add(this.btnSearch); this.layoutControl1.Controls.Add(this.btnSearch);
this.layoutControl1.Controls.Add(this.dtpEnd); this.layoutControl1.Controls.Add(this.dtpEnd);
this.layoutControl1.Controls.Add(this.dtpStart); this.layoutControl1.Controls.Add(this.dtpStart);
@@ -85,15 +99,27 @@
this.layoutControl1.Name = "layoutControl1"; this.layoutControl1.Name = "layoutControl1";
this.layoutControl1.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(947, 249, 650, 400); this.layoutControl1.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(947, 249, 650, 400);
this.layoutControl1.Root = this.layoutControlGroup1; this.layoutControl1.Root = this.layoutControlGroup1;
this.layoutControl1.Size = new System.Drawing.Size(850, 635); this.layoutControl1.Size = new System.Drawing.Size(890, 635);
this.layoutControl1.TabIndex = 0; this.layoutControl1.TabIndex = 0;
this.layoutControl1.Text = "layoutControl1"; this.layoutControl1.Text = "layoutControl1";
// //
// CbLogType
//
this.CbLogType.Location = new System.Drawing.Point(552, 28);
this.CbLogType.Name = "CbLogType";
this.CbLogType.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 11F);
this.CbLogType.Properties.Appearance.Options.UseFont = true;
this.CbLogType.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.CbLogType.Size = new System.Drawing.Size(69, 24);
this.CbLogType.StyleController = this.layoutControl1;
this.CbLogType.TabIndex = 8;
//
// btnSearch // btnSearch
// //
this.btnSearch.Location = new System.Drawing.Point(592, 28); this.btnSearch.Location = new System.Drawing.Point(730, 28);
this.btnSearch.Name = "btnSearch"; this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(251, 25); this.btnSearch.Size = new System.Drawing.Size(153, 25);
this.btnSearch.TabIndex = 7; this.btnSearch.TabIndex = 7;
this.btnSearch.Text = "SEARCH"; this.btnSearch.Text = "SEARCH";
this.btnSearch.UseVisualStyleBackColor = true; this.btnSearch.UseVisualStyleBackColor = true;
@@ -104,9 +130,9 @@
this.dtpEnd.CustomFormat = "yyyy-MM-dd HH:mm:ss"; this.dtpEnd.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.dtpEnd.Font = new System.Drawing.Font("Tahoma", 11F); this.dtpEnd.Font = new System.Drawing.Font("Tahoma", 11F);
this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpEnd.Location = new System.Drawing.Point(395, 28); this.dtpEnd.Location = new System.Drawing.Point(327, 28);
this.dtpEnd.Name = "dtpEnd"; this.dtpEnd.Name = "dtpEnd";
this.dtpEnd.Size = new System.Drawing.Size(193, 25); this.dtpEnd.Size = new System.Drawing.Size(176, 25);
this.dtpEnd.TabIndex = 6; this.dtpEnd.TabIndex = 6;
// //
// dtpStart // dtpStart
@@ -115,9 +141,9 @@
this.dtpStart.CustomFormat = "yyyy-MM-dd HH:mm:ss"; this.dtpStart.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.dtpStart.Font = new System.Drawing.Font("Tahoma", 11F); this.dtpStart.Font = new System.Drawing.Font("Tahoma", 11F);
this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpStart.Location = new System.Drawing.Point(102, 28); this.dtpStart.Location = new System.Drawing.Point(77, 28);
this.dtpStart.Name = "dtpStart"; this.dtpStart.Name = "dtpStart";
this.dtpStart.Size = new System.Drawing.Size(194, 25); this.dtpStart.Size = new System.Drawing.Size(176, 25);
this.dtpStart.TabIndex = 5; this.dtpStart.TabIndex = 5;
// //
// xtcSearchResult // xtcSearchResult
@@ -125,7 +151,7 @@
this.xtcSearchResult.Location = new System.Drawing.Point(7, 86); this.xtcSearchResult.Location = new System.Drawing.Point(7, 86);
this.xtcSearchResult.Name = "xtcSearchResult"; this.xtcSearchResult.Name = "xtcSearchResult";
this.xtcSearchResult.SelectedTabPage = this.pgGrid; this.xtcSearchResult.SelectedTabPage = this.pgGrid;
this.xtcSearchResult.Size = new System.Drawing.Size(836, 542); this.xtcSearchResult.Size = new System.Drawing.Size(876, 542);
this.xtcSearchResult.TabIndex = 4; this.xtcSearchResult.TabIndex = 4;
this.xtcSearchResult.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] { this.xtcSearchResult.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] {
this.pgGrid}); this.pgGrid});
@@ -134,7 +160,7 @@
// //
this.pgGrid.Controls.Add(this.layoutControl3); this.pgGrid.Controls.Add(this.layoutControl3);
this.pgGrid.Name = "pgGrid"; this.pgGrid.Name = "pgGrid";
this.pgGrid.Size = new System.Drawing.Size(834, 516); this.pgGrid.Size = new System.Drawing.Size(874, 516);
this.pgGrid.Text = "Result Data"; this.pgGrid.Text = "Result Data";
// //
// layoutControl3 // layoutControl3
@@ -146,15 +172,15 @@
this.layoutControl3.Name = "layoutControl3"; this.layoutControl3.Name = "layoutControl3";
this.layoutControl3.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(1120, 298, 650, 400); this.layoutControl3.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(1120, 298, 650, 400);
this.layoutControl3.Root = this.Root; this.layoutControl3.Root = this.Root;
this.layoutControl3.Size = new System.Drawing.Size(834, 516); this.layoutControl3.Size = new System.Drawing.Size(874, 516);
this.layoutControl3.TabIndex = 0; this.layoutControl3.TabIndex = 0;
this.layoutControl3.Text = "layoutControl3"; this.layoutControl3.Text = "layoutControl3";
// //
// btnExportExcel // btnExportExcel
// //
this.btnExportExcel.Location = new System.Drawing.Point(728, 481); this.btnExportExcel.Location = new System.Drawing.Point(763, 481);
this.btnExportExcel.Name = "btnExportExcel"; this.btnExportExcel.Name = "btnExportExcel";
this.btnExportExcel.Size = new System.Drawing.Size(103, 32); this.btnExportExcel.Size = new System.Drawing.Size(108, 32);
this.btnExportExcel.StyleController = this.layoutControl3; this.btnExportExcel.StyleController = this.layoutControl3;
this.btnExportExcel.TabIndex = 5; this.btnExportExcel.TabIndex = 5;
this.btnExportExcel.Text = "Export Excel"; this.btnExportExcel.Text = "Export Excel";
@@ -166,7 +192,7 @@
this.gridSearchResult.Location = new System.Drawing.Point(3, 3); this.gridSearchResult.Location = new System.Drawing.Point(3, 3);
this.gridSearchResult.Name = "gridSearchResult"; this.gridSearchResult.Name = "gridSearchResult";
this.gridSearchResult.RowTemplate.Height = 23; this.gridSearchResult.RowTemplate.Height = 23;
this.gridSearchResult.Size = new System.Drawing.Size(828, 474); this.gridSearchResult.Size = new System.Drawing.Size(868, 474);
this.gridSearchResult.TabIndex = 4; this.gridSearchResult.TabIndex = 4;
this.gridSearchResult.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gridSearchResult_CellFormatting); this.gridSearchResult.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gridSearchResult_CellFormatting);
// //
@@ -180,7 +206,7 @@
this.emptySpaceItem1}); this.emptySpaceItem1});
this.Root.Name = "Root"; this.Root.Name = "Root";
this.Root.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1); this.Root.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1);
this.Root.Size = new System.Drawing.Size(834, 516); this.Root.Size = new System.Drawing.Size(874, 516);
this.Root.TextVisible = false; this.Root.TextVisible = false;
// //
// layoutControlItem5 // layoutControlItem5
@@ -189,7 +215,7 @@
this.layoutControlItem5.Location = new System.Drawing.Point(0, 0); this.layoutControlItem5.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem5.MinSize = new System.Drawing.Size(104, 24); this.layoutControlItem5.MinSize = new System.Drawing.Size(104, 24);
this.layoutControlItem5.Name = "layoutControlItem5"; this.layoutControlItem5.Name = "layoutControlItem5";
this.layoutControlItem5.Size = new System.Drawing.Size(832, 478); this.layoutControlItem5.Size = new System.Drawing.Size(872, 478);
this.layoutControlItem5.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem5.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem5.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem5.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem5.TextVisible = false; this.layoutControlItem5.TextVisible = false;
@@ -197,10 +223,10 @@
// layoutControlItem6 // layoutControlItem6
// //
this.layoutControlItem6.Control = this.btnExportExcel; this.layoutControlItem6.Control = this.btnExportExcel;
this.layoutControlItem6.Location = new System.Drawing.Point(725, 478); this.layoutControlItem6.Location = new System.Drawing.Point(760, 478);
this.layoutControlItem6.MinSize = new System.Drawing.Size(89, 26); this.layoutControlItem6.MinSize = new System.Drawing.Size(89, 26);
this.layoutControlItem6.Name = "layoutControlItem6"; this.layoutControlItem6.Name = "layoutControlItem6";
this.layoutControlItem6.Size = new System.Drawing.Size(107, 36); this.layoutControlItem6.Size = new System.Drawing.Size(112, 36);
this.layoutControlItem6.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem6.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem6.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem6.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem6.TextVisible = false; this.layoutControlItem6.TextVisible = false;
@@ -210,7 +236,7 @@
this.emptySpaceItem1.AllowHotTrack = false; this.emptySpaceItem1.AllowHotTrack = false;
this.emptySpaceItem1.Location = new System.Drawing.Point(0, 478); this.emptySpaceItem1.Location = new System.Drawing.Point(0, 478);
this.emptySpaceItem1.Name = "emptySpaceItem1"; this.emptySpaceItem1.Name = "emptySpaceItem1";
this.emptySpaceItem1.Size = new System.Drawing.Size(725, 36); this.emptySpaceItem1.Size = new System.Drawing.Size(760, 36);
this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0); this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
// //
// layoutControlGroup1 // layoutControlGroup1
@@ -223,7 +249,7 @@
this.lcgbSearchResult}); this.lcgbSearchResult});
this.layoutControlGroup1.Name = "Root"; this.layoutControlGroup1.Name = "Root";
this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1); this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1);
this.layoutControlGroup1.Size = new System.Drawing.Size(850, 635); this.layoutControlGroup1.Size = new System.Drawing.Size(890, 635);
this.layoutControlGroup1.TextVisible = false; this.layoutControlGroup1.TextVisible = false;
// //
// lcgbSelectDatetime // lcgbSelectDatetime
@@ -233,31 +259,35 @@
this.layoutControlItem2, this.layoutControlItem2,
this.slbEndDate, this.slbEndDate,
this.layoutControlItem4, this.layoutControlItem4,
this.layoutControlItem3}); this.layoutControlItem3,
this.layoutControlItem7,
this.simpleLabelItem1,
this.layoutControlItem8,
this.simpleLabelItem2});
this.lcgbSelectDatetime.Location = new System.Drawing.Point(0, 0); this.lcgbSelectDatetime.Location = new System.Drawing.Point(0, 0);
this.lcgbSelectDatetime.Name = "lcgbSelectDatetime"; this.lcgbSelectDatetime.Name = "lcgbSelectDatetime";
this.lcgbSelectDatetime.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1); this.lcgbSelectDatetime.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1);
this.lcgbSelectDatetime.Size = new System.Drawing.Size(848, 58); this.lcgbSelectDatetime.Size = new System.Drawing.Size(888, 58);
this.lcgbSelectDatetime.Text = "Select Datetime"; this.lcgbSelectDatetime.Text = "Select Datetime";
// //
// slbStartDate // slbStartDate
// //
this.slbStartDate.AllowHotTrack = false; this.slbStartDate.AllowHotTrack = false;
this.slbStartDate.Location = new System.Drawing.Point(0, 0); this.slbStartDate.Location = new System.Drawing.Point(0, 0);
this.slbStartDate.MinSize = new System.Drawing.Size(95, 18); this.slbStartDate.MinSize = new System.Drawing.Size(70, 18);
this.slbStartDate.Name = "slbStartDate"; this.slbStartDate.Name = "slbStartDate";
this.slbStartDate.Size = new System.Drawing.Size(95, 29); this.slbStartDate.Size = new System.Drawing.Size(70, 29);
this.slbStartDate.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.slbStartDate.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.slbStartDate.Text = " Start Datetime"; this.slbStartDate.Text = " Start Time";
this.slbStartDate.TextSize = new System.Drawing.Size(85, 14); this.slbStartDate.TextSize = new System.Drawing.Size(62, 14);
// //
// layoutControlItem2 // layoutControlItem2
// //
this.layoutControlItem2.Control = this.dtpStart; this.layoutControlItem2.Control = this.dtpStart;
this.layoutControlItem2.Location = new System.Drawing.Point(95, 0); this.layoutControlItem2.Location = new System.Drawing.Point(70, 0);
this.layoutControlItem2.MinSize = new System.Drawing.Size(24, 24); this.layoutControlItem2.MinSize = new System.Drawing.Size(180, 24);
this.layoutControlItem2.Name = "layoutControlItem2"; this.layoutControlItem2.Name = "layoutControlItem2";
this.layoutControlItem2.Size = new System.Drawing.Size(198, 29); this.layoutControlItem2.Size = new System.Drawing.Size(180, 29);
this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem2.TextVisible = false; this.layoutControlItem2.TextVisible = false;
@@ -265,22 +295,22 @@
// slbEndDate // slbEndDate
// //
this.slbEndDate.AllowHotTrack = false; this.slbEndDate.AllowHotTrack = false;
this.slbEndDate.Location = new System.Drawing.Point(293, 0); this.slbEndDate.Location = new System.Drawing.Point(250, 0);
this.slbEndDate.MinSize = new System.Drawing.Size(95, 18); this.slbEndDate.MinSize = new System.Drawing.Size(70, 18);
this.slbEndDate.Name = "slbEndDate"; this.slbEndDate.Name = "slbEndDate";
this.slbEndDate.Size = new System.Drawing.Size(95, 29); this.slbEndDate.Size = new System.Drawing.Size(70, 29);
this.slbEndDate.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.slbEndDate.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.slbEndDate.Text = " End Datetime"; this.slbEndDate.Text = " End Time";
this.slbEndDate.TextSize = new System.Drawing.Size(85, 14); this.slbEndDate.TextSize = new System.Drawing.Size(62, 14);
// //
// layoutControlItem4 // layoutControlItem4
// //
this.layoutControlItem4.Control = this.btnSearch; this.layoutControlItem4.Control = this.btnSearch;
this.layoutControlItem4.Location = new System.Drawing.Point(585, 0); this.layoutControlItem4.Location = new System.Drawing.Point(723, 0);
this.layoutControlItem4.MaxSize = new System.Drawing.Size(0, 29); this.layoutControlItem4.MaxSize = new System.Drawing.Size(0, 29);
this.layoutControlItem4.MinSize = new System.Drawing.Size(24, 29); this.layoutControlItem4.MinSize = new System.Drawing.Size(24, 29);
this.layoutControlItem4.Name = "layoutControlItem4"; this.layoutControlItem4.Name = "layoutControlItem4";
this.layoutControlItem4.Size = new System.Drawing.Size(255, 29); this.layoutControlItem4.Size = new System.Drawing.Size(157, 29);
this.layoutControlItem4.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem4.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem4.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem4.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem4.TextVisible = false; this.layoutControlItem4.TextVisible = false;
@@ -288,14 +318,38 @@
// layoutControlItem3 // layoutControlItem3
// //
this.layoutControlItem3.Control = this.dtpEnd; this.layoutControlItem3.Control = this.dtpEnd;
this.layoutControlItem3.Location = new System.Drawing.Point(388, 0); this.layoutControlItem3.Location = new System.Drawing.Point(320, 0);
this.layoutControlItem3.MinSize = new System.Drawing.Size(24, 24); this.layoutControlItem3.MinSize = new System.Drawing.Size(180, 24);
this.layoutControlItem3.Name = "layoutControlItem3"; this.layoutControlItem3.Name = "layoutControlItem3";
this.layoutControlItem3.Size = new System.Drawing.Size(197, 29); this.layoutControlItem3.Size = new System.Drawing.Size(180, 29);
this.layoutControlItem3.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem3.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem3.TextVisible = false; this.layoutControlItem3.TextVisible = false;
// //
// layoutControlItem7
//
this.layoutControlItem7.Control = this.CbLogType;
this.layoutControlItem7.Location = new System.Drawing.Point(545, 0);
this.layoutControlItem7.MaxSize = new System.Drawing.Size(73, 0);
this.layoutControlItem7.MinSize = new System.Drawing.Size(73, 24);
this.layoutControlItem7.Name = "layoutControlItem7";
this.layoutControlItem7.Size = new System.Drawing.Size(73, 29);
this.layoutControlItem7.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem7.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem7.TextVisible = false;
//
// simpleLabelItem1
//
this.simpleLabelItem1.AllowHotTrack = false;
this.simpleLabelItem1.Location = new System.Drawing.Point(500, 0);
this.simpleLabelItem1.MaxSize = new System.Drawing.Size(45, 0);
this.simpleLabelItem1.MinSize = new System.Drawing.Size(45, 18);
this.simpleLabelItem1.Name = "simpleLabelItem1";
this.simpleLabelItem1.Size = new System.Drawing.Size(45, 29);
this.simpleLabelItem1.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.simpleLabelItem1.Text = " Type";
this.simpleLabelItem1.TextSize = new System.Drawing.Size(62, 14);
//
// lcgbSearchResult // lcgbSearchResult
// //
this.lcgbSearchResult.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { this.lcgbSearchResult.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
@@ -303,7 +357,7 @@
this.lcgbSearchResult.Location = new System.Drawing.Point(0, 58); this.lcgbSearchResult.Location = new System.Drawing.Point(0, 58);
this.lcgbSearchResult.Name = "lcgbSearchResult"; this.lcgbSearchResult.Name = "lcgbSearchResult";
this.lcgbSearchResult.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1); this.lcgbSearchResult.Padding = new DevExpress.XtraLayout.Utils.Padding(1, 1, 1, 1);
this.lcgbSearchResult.Size = new System.Drawing.Size(848, 575); this.lcgbSearchResult.Size = new System.Drawing.Size(888, 575);
this.lcgbSearchResult.Text = "Search Result"; this.lcgbSearchResult.Text = "Search Result";
// //
// layoutControlItem1 // layoutControlItem1
@@ -312,19 +366,54 @@
this.layoutControlItem1.CustomizationFormText = "layoutControlItem1"; this.layoutControlItem1.CustomizationFormText = "layoutControlItem1";
this.layoutControlItem1.Location = new System.Drawing.Point(0, 0); this.layoutControlItem1.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem1.Name = "layoutControlItem1"; this.layoutControlItem1.Name = "layoutControlItem1";
this.layoutControlItem1.Size = new System.Drawing.Size(840, 546); this.layoutControlItem1.Size = new System.Drawing.Size(880, 546);
this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem1.TextVisible = false; this.layoutControlItem1.TextVisible = false;
// //
// CbMdNo
//
this.CbMdNo.Location = new System.Drawing.Point(670, 28);
this.CbMdNo.Name = "CbMdNo";
this.CbMdNo.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 11F);
this.CbMdNo.Properties.Appearance.Options.UseFont = true;
this.CbMdNo.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.CbMdNo.Size = new System.Drawing.Size(56, 24);
this.CbMdNo.StyleController = this.layoutControl1;
this.CbMdNo.TabIndex = 9;
//
// layoutControlItem8
//
this.layoutControlItem8.Control = this.CbMdNo;
this.layoutControlItem8.Location = new System.Drawing.Point(663, 0);
this.layoutControlItem8.MinSize = new System.Drawing.Size(60, 28);
this.layoutControlItem8.Name = "layoutControlItem8";
this.layoutControlItem8.Size = new System.Drawing.Size(60, 29);
this.layoutControlItem8.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem8.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem8.TextVisible = false;
//
// simpleLabelItem2
//
this.simpleLabelItem2.AllowHotTrack = false;
this.simpleLabelItem2.Location = new System.Drawing.Point(618, 0);
this.simpleLabelItem2.MinSize = new System.Drawing.Size(45, 18);
this.simpleLabelItem2.Name = "simpleLabelItem2";
this.simpleLabelItem2.Size = new System.Drawing.Size(45, 29);
this.simpleLabelItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.simpleLabelItem2.Text = " M No.";
this.simpleLabelItem2.TextSize = new System.Drawing.Size(62, 14);
//
// ucHistroy // ucHistroy
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.layoutControl1); this.Controls.Add(this.layoutControl1);
this.Name = "ucHistroy"; this.Name = "ucHistroy";
this.Size = new System.Drawing.Size(850, 635); this.Size = new System.Drawing.Size(890, 635);
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
this.layoutControl1.ResumeLayout(false); this.layoutControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.CbLogType.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xtcSearchResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xtcSearchResult)).EndInit();
this.xtcSearchResult.ResumeLayout(false); this.xtcSearchResult.ResumeLayout(false);
this.pgGrid.ResumeLayout(false); this.pgGrid.ResumeLayout(false);
@@ -342,8 +431,13 @@
((System.ComponentModel.ISupportInitialize)(this.slbEndDate)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.slbEndDate)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lcgbSearchResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lcgbSearchResult)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CbMdNo.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem2)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -373,5 +467,11 @@
private DevExpress.XtraEditors.SimpleButton btnExportExcel; private DevExpress.XtraEditors.SimpleButton btnExportExcel;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem6; private DevExpress.XtraLayout.LayoutControlItem layoutControlItem6;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1; private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
private DevExpress.XtraEditors.ComboBoxEdit CbLogType;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem7;
private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem1;
private DevExpress.XtraEditors.ComboBoxEdit CbMdNo;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem2;
} }
} }

View File

@@ -36,6 +36,19 @@ namespace LFP_Manager.Controls
InitializeComponent(); InitializeComponent();
dtHistory = new DataTable(); dtHistory = new DataTable();
CbLogType.Properties.Items.Add("Cycle");
CbLogType.Properties.Items.Add("Event");
CbLogType.SelectedIndex = 0;
CbMdNo.Properties.Items.Clear();
CbMdNo.Properties.Items.Add("All");
for (int i = 1; i <= csConstData.SystemInfo.MAX_MODULE_SIZE; i++)
{
CbMdNo.Properties.Items.Add(i.ToString());
}
CbMdNo.SelectedIndex = 0;
} }
public void SetCommCofig(CommConfig aConfig) public void SetCommCofig(CommConfig aConfig)
@@ -123,6 +136,19 @@ namespace LFP_Manager.Controls
{ {
quary = String.Format(" where create_date > '{0:yyyy-MM-dd HH:mm:ss}'", start); quary = String.Format(" where create_date > '{0:yyyy-MM-dd HH:mm:ss}'", start);
quary += String.Format(" and create_date < '{0:yyyy-MM-dd HH:mm:ss}'", end); quary += String.Format(" and create_date < '{0:yyyy-MM-dd HH:mm:ss}'", end);
if (CbLogType.Text == "")
quary += "";
else if (CbLogType.SelectedIndex == 0)
quary += " and log_type = '0'";
else
quary += " and log_type = '1'";
if ((CbMdNo.Text == "") || (CbMdNo.Text == "All") || (CbMdNo.SelectedIndex == 0))
quary += "";
else
quary += $" and module_no = '{CbMdNo.SelectedIndex}'";
dDt[0] = csDbUtils.BmsDataSelectToDataTable(Config, start, quary); dDt[0] = csDbUtils.BmsDataSelectToDataTable(Config, start, quary);
if (dDt[0] == null) if (dDt[0] == null)
MessageBox.Show("No data", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("No data", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -143,11 +169,23 @@ namespace LFP_Manager.Controls
if (i == 0) if (i == 0)
{ {
quary = String.Format(" where create_date > '{0:yyyy-MM-dd HH:mm:ss}'", start); quary = String.Format(" where create_date > '{0:yyyy-MM-dd HH:mm:ss}'", start);
if (CbLogType.Text == "")
quary += "";
if (CbLogType.SelectedIndex == 0)
quary += " and log_type = '0'";
else
quary += " and log_type = '1'";
dDt[i] = csDbUtils.BmsDataSelectToDataTable(Config, start, quary); dDt[i] = csDbUtils.BmsDataSelectToDataTable(Config, start, quary);
} }
else if (i == total_days) else if (i == total_days)
{ {
quary = String.Format(" where create_date < '{0:yyyy-MM-dd HH:mm:ss}'", end); quary = String.Format(" where create_date < '{0:yyyy-MM-dd HH:mm:ss}'", end);
if (CbLogType.Text == "")
quary += "";
if (CbLogType.SelectedIndex == 0)
quary += " and log_type = '0'";
else
quary += " and log_type = '1'";
dDt[i] = csDbUtils.BmsDataSelectToDataTable(Config, end, quary); dDt[i] = csDbUtils.BmsDataSelectToDataTable(Config, end, quary);
} }
else else

View File

@@ -31,6 +31,7 @@ namespace LFP_Manager.Controls
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl(); this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
this.lbMdNo = new System.Windows.Forms.Label();
this.gaugeControl6 = new DevExpress.XtraGauges.Win.GaugeControl(); this.gaugeControl6 = new DevExpress.XtraGauges.Win.GaugeControl();
this.gaugeTempMax = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge(); this.gaugeTempMax = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge();
this.digitalBackgroundLayerComponent7 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent(); this.digitalBackgroundLayerComponent7 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent();
@@ -61,15 +62,14 @@ namespace LFP_Manager.Controls
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
this.lcItemModuleDetail = new DevExpress.XtraLayout.LayoutControlItem(); this.lcItemModuleDetail = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem(); this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
this.lbMdFwVer = new DevExpress.XtraLayout.SimpleLabelItem(); this.LbMdSN = new DevExpress.XtraLayout.SimpleLabelItem();
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
this.tmrDisplay = new System.Windows.Forms.Timer(this.components); this.tmrDisplay = new System.Windows.Forms.Timer(this.components);
this.digitalGauge1 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge(); this.digitalGauge1 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge();
this.digitalBackgroundLayerComponent5 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent(); this.digitalBackgroundLayerComponent5 = new DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent();
this.lbModuleNumber = new DevExpress.XtraEditors.LabelControl(); this.lbModuleNumber = new DevExpress.XtraEditors.LabelControl();
this.layoutControlGroup1 = new DevExpress.XtraLayout.LayoutControlGroup(); this.layoutControlGroup1 = new DevExpress.XtraLayout.LayoutControlGroup();
this.lcitemModuleNumber = new DevExpress.XtraLayout.LayoutControlItem(); this.lcitemModuleNumber = new DevExpress.XtraLayout.LayoutControlItem();
this.lbMdNo = new System.Windows.Forms.Label();
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
this.layoutControl1.SuspendLayout(); this.layoutControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gaugeTempMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gaugeTempMax)).BeginInit();
@@ -95,12 +95,12 @@ namespace LFP_Manager.Controls
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lcItemModuleDetail)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lcItemModuleDetail)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lbMdFwVer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.LbMdSN)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.digitalGauge1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.digitalGauge1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.digitalBackgroundLayerComponent5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.digitalBackgroundLayerComponent5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lcitemModuleNumber)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lcitemModuleNumber)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// layoutControl1 // layoutControl1
@@ -123,6 +123,16 @@ namespace LFP_Manager.Controls
this.layoutControl1.TabIndex = 0; this.layoutControl1.TabIndex = 0;
this.layoutControl1.Text = "layoutControl1"; this.layoutControl1.Text = "layoutControl1";
// //
// lbMdNo
//
this.lbMdNo.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
this.lbMdNo.Location = new System.Drawing.Point(29, 6);
this.lbMdNo.Name = "lbMdNo";
this.lbMdNo.Size = new System.Drawing.Size(44, 41);
this.lbMdNo.TabIndex = 12;
this.lbMdNo.Text = "#01";
this.lbMdNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// gaugeControl6 // gaugeControl6
// //
this.gaugeControl6.Gauges.AddRange(new DevExpress.XtraGauges.Base.IGauge[] { this.gaugeControl6.Gauges.AddRange(new DevExpress.XtraGauges.Base.IGauge[] {
@@ -335,7 +345,7 @@ namespace LFP_Manager.Controls
this.layoutControlItem1, this.layoutControlItem1,
this.lcItemModuleDetail, this.lcItemModuleDetail,
this.layoutControlItem3, this.layoutControlItem3,
this.lbMdFwVer, this.LbMdSN,
this.layoutControlItem2}); this.layoutControlItem2});
this.layoutControlGroup2.Location = new System.Drawing.Point(0, 0); this.layoutControlGroup2.Location = new System.Drawing.Point(0, 0);
this.layoutControlGroup2.Name = "layoutControlGroup2"; this.layoutControlGroup2.Name = "layoutControlGroup2";
@@ -471,16 +481,27 @@ namespace LFP_Manager.Controls
this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem3.TextVisible = false; this.layoutControlItem3.TextVisible = false;
// //
// lbMdFwVer // LbMdSN
// //
this.lbMdFwVer.AllowHotTrack = false; this.LbMdSN.AllowHotTrack = false;
this.lbMdFwVer.AppearanceItemCaption.Font = new System.Drawing.Font("Tahoma", 10F); this.LbMdSN.AppearanceItemCaption.Font = new System.Drawing.Font("Tahoma", 10F);
this.lbMdFwVer.AppearanceItemCaption.Options.UseFont = true; this.LbMdSN.AppearanceItemCaption.Options.UseFont = true;
this.lbMdFwVer.Location = new System.Drawing.Point(168, 0); this.LbMdSN.Location = new System.Drawing.Point(168, 0);
this.lbMdFwVer.Name = "lbMdFwVer"; this.LbMdSN.Name = "LbMdSN";
this.lbMdFwVer.Size = new System.Drawing.Size(59, 45); this.LbMdSN.Size = new System.Drawing.Size(59, 45);
this.lbMdFwVer.Text = "----"; this.LbMdSN.Text = "----";
this.lbMdFwVer.TextSize = new System.Drawing.Size(40, 16); this.LbMdSN.TextSize = new System.Drawing.Size(40, 16);
//
// layoutControlItem2
//
this.layoutControlItem2.Control = this.lbMdNo;
this.layoutControlItem2.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem2.MinSize = new System.Drawing.Size(24, 24);
this.layoutControlItem2.Name = "layoutControlItem2";
this.layoutControlItem2.Size = new System.Drawing.Size(48, 45);
this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem2.TextVisible = false;
// //
// tmrDisplay // tmrDisplay
// //
@@ -547,27 +568,6 @@ namespace LFP_Manager.Controls
this.lcitemModuleNumber.TextSize = new System.Drawing.Size(0, 0); this.lcitemModuleNumber.TextSize = new System.Drawing.Size(0, 0);
this.lcitemModuleNumber.TextVisible = false; this.lcitemModuleNumber.TextVisible = false;
// //
// lbMdNo
//
this.lbMdNo.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
this.lbMdNo.Location = new System.Drawing.Point(29, 6);
this.lbMdNo.Name = "lbMdNo";
this.lbMdNo.Size = new System.Drawing.Size(44, 41);
this.lbMdNo.TabIndex = 12;
this.lbMdNo.Text = "#01";
this.lbMdNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// layoutControlItem2
//
this.layoutControlItem2.Control = this.lbMdNo;
this.layoutControlItem2.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem2.MinSize = new System.Drawing.Size(24, 24);
this.layoutControlItem2.Name = "layoutControlItem2";
this.layoutControlItem2.Size = new System.Drawing.Size(48, 45);
this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem2.TextVisible = false;
//
// ucModuleMainB // ucModuleMainB
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@@ -602,12 +602,12 @@ namespace LFP_Manager.Controls
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lcItemModuleDetail)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lcItemModuleDetail)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lbMdFwVer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.LbMdSN)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.digitalGauge1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.digitalGauge1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.digitalBackgroundLayerComponent5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.digitalBackgroundLayerComponent5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lcitemModuleNumber)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lcitemModuleNumber)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -648,7 +648,7 @@ namespace LFP_Manager.Controls
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3; private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3;
private DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge gaugeVoltage; private DevExpress.XtraGauges.Win.Gauges.Digital.DigitalGauge gaugeVoltage;
private DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent digitalBackgroundLayerComponent1; private DevExpress.XtraGauges.Win.Gauges.Digital.DigitalBackgroundLayerComponent digitalBackgroundLayerComponent1;
private DevExpress.XtraLayout.SimpleLabelItem lbMdFwVer; private DevExpress.XtraLayout.SimpleLabelItem LbMdSN;
private DevExpress.XtraEditors.LabelControl lbModuleNumber; private DevExpress.XtraEditors.LabelControl lbModuleNumber;
private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup1; private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup1;
private DevExpress.XtraLayout.LayoutControlItem lcitemModuleNumber; private DevExpress.XtraLayout.LayoutControlItem lcitemModuleNumber;

View File

@@ -60,6 +60,7 @@ namespace LFP_Manager.Controls
private void tmrDisplay_Tick(object sender, EventArgs e) private void tmrDisplay_Tick(object sender, EventArgs e)
{ {
DisplayValue(); DisplayValue();
DisplayMainStatus();
DisplayStatusAndAlarm(); DisplayStatusAndAlarm();
} }
@@ -84,12 +85,15 @@ namespace LFP_Manager.Controls
{ {
lbMdNo.BackColor = Color.Orange; lbMdNo.BackColor = Color.Orange;
} }
} }
private void DisplayValue() private void DisplayValue()
{ {
lbMdFwVer.Text = ModuleData.Information.SwProductRev; string sn = ModuleData.Information.HwSerialNumber;
if (sn.Length > 9)
sn = sn.Substring(sn.Length - 9, 9);
LbMdSN.Text = sn;
gaugeVoltage.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.voltage / 10); gaugeVoltage.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.voltage / 10);
gaugeCurrent.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.current / 10); gaugeCurrent.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.current / 10);
gaugeSOC.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.SOC / 10); gaugeSOC.Text = String.Format("{0:0.0}", (double)ModuleData.ValueData.SOC / 10);
@@ -100,91 +104,75 @@ namespace LFP_Manager.Controls
private void DisplayStatusAndAlarm() private void DisplayStatusAndAlarm()
{ {
if (ModuleData.CommFail == false) if (ModuleData.ShelfCommFail == false)
{ {
if (ModuleData.ShelfCommFail == false) switch (ModuleData.StatusData.status)
{ {
lbMdNo.BackColor = Color.Green; case 0x0000: // Stand by
slbOpStatus.Text = "STANDBY";
switch (ModuleData.StatusData.status) slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
{ break;
case 0x0000: // Stand by case 0x0001: // Charging
slbOpStatus.Text = "STANDBY"; slbOpStatus.Text = "CHARGING";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Blue;
break; break;
case 0x0001: // Charging case 0x0002: // Discharging
slbOpStatus.Text = "CHARGING"; slbOpStatus.Text = "DISCHARGING";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Blue; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Magenta;
break; break;
case 0x0002: // Discharging case 0x0003: // Float Charging
slbOpStatus.Text = "DISCHARGING"; slbOpStatus.Text = "FLOATING";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Magenta; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break; break;
case 0x0003: // Float Charging case 0x0004: // Warming Up
slbOpStatus.Text = "FLOATING"; slbOpStatus.Text = "WARMING UP";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break; break;
case 0x0004: // Warming Up default:
slbOpStatus.Text = "WARMING UP"; slbOpStatus.Text = "UNKNOWN";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break; break;
default:
slbOpStatus.Text = "UNKNOWN";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break;
}
// Alarm Display
switch (ModuleData.StatusData.batteryStatus)
{
case 0: // NORMAL
slbAlarm.Text = "NORMAL";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Green;
break;
case 1: // WARNING
slbAlarm.Text = "WARNING";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Orange;
break;
case 2: // FAULT
slbAlarm.Text = "FAULT";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
case 3: // WARMING UP
slbAlarm.Text = "WARMING UP";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break;
case 4: // FAULT (Anti-Theft Comm.)
slbAlarm.Text = "FAULT1";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
case 5: // FAULT (Anti-Theft Gyro-Scope)
slbAlarm.Text = "FAULT2";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
default:
slbAlarm.Text = string.Format("UNKNOWN ({0})", ModuleData.StatusData.batteryStatus);
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
}
} }
else // Alarm Display
switch (ModuleData.StatusData.batteryStatus)
{ {
slbOpStatus.Text = "COMM FAIL"; case 0: // NORMAL
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red; slbAlarm.Text = "NORMAL";
slbAlarm.Text = "COMM FAIL"; slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Green;
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red; break;
lbMdNo.BackColor = System.Drawing.Color.Orange; case 1: // WARNING
slbAlarm.Text = "WARNING";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Orange;
break;
case 2: // FAULT
slbAlarm.Text = "FAULT";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
case 3: // WARMING UP
slbAlarm.Text = "WARMING UP";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Black;
break;
case 4: // FAULT (Anti-Theft Comm.)
slbAlarm.Text = "FAULT1";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
case 5: // FAULT (Anti-Theft Gyro-Scope)
slbAlarm.Text = "FAULT2";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
default:
slbAlarm.Text = string.Format("UNKNOWN ({0})", ModuleData.StatusData.batteryStatus);
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
break;
} }
} }
else else
{ {
slbOpStatus.Text = "OFF LINE"; slbOpStatus.Text = "COMM FAIL";
slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red; slbOpStatus.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
slbAlarm.Text = "OFF LINE"; slbAlarm.Text = "COMM FAIL";
slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red; slbAlarm.AppearanceItemCaption.ForeColor = System.Drawing.Color.Red;
lbMdNo.BackColor = System.Drawing.Color.Orange;
} }
// Charge Relay Status Display
} }
#endregion #endregion

View File

@@ -41,7 +41,7 @@
this.simpleLabelItem8 = new DevExpress.XtraLayout.SimpleLabelItem(); this.simpleLabelItem8 = new DevExpress.XtraLayout.SimpleLabelItem();
this.simpleLabelItem9 = new DevExpress.XtraLayout.SimpleLabelItem(); this.simpleLabelItem9 = new DevExpress.XtraLayout.SimpleLabelItem();
this.simpleLabelItem10 = new DevExpress.XtraLayout.SimpleLabelItem(); this.simpleLabelItem10 = new DevExpress.XtraLayout.SimpleLabelItem();
this.lbFwVer = new DevExpress.XtraLayout.SimpleLabelItem(); this.LbSN = new DevExpress.XtraLayout.SimpleLabelItem();
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit();
@@ -55,7 +55,7 @@
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem8)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem9)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem9)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem10)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem10)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lbFwVer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.LbSN)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// layoutControl1 // layoutControl1
@@ -96,7 +96,7 @@
this.simpleLabelItem8, this.simpleLabelItem8,
this.simpleLabelItem9, this.simpleLabelItem9,
this.simpleLabelItem10, this.simpleLabelItem10,
this.lbFwVer}); this.LbSN});
this.layoutControlGroup1.Location = new System.Drawing.Point(0, 0); this.layoutControlGroup1.Location = new System.Drawing.Point(0, 0);
this.layoutControlGroup1.Name = "layoutControlGroup1"; this.layoutControlGroup1.Name = "layoutControlGroup1";
this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0); this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
@@ -237,16 +237,16 @@
this.simpleLabelItem10.Text = "Cell V Gap [V]"; this.simpleLabelItem10.Text = "Cell V Gap [V]";
this.simpleLabelItem10.TextSize = new System.Drawing.Size(82, 14); this.simpleLabelItem10.TextSize = new System.Drawing.Size(82, 14);
// //
// lbFwVer // LbSN
// //
this.lbFwVer.AllowHotTrack = false; this.LbSN.AllowHotTrack = false;
this.lbFwVer.AppearanceItemCaption.Options.UseTextOptions = true; this.LbSN.AppearanceItemCaption.Options.UseTextOptions = true;
this.lbFwVer.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; this.LbSN.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
this.lbFwVer.Location = new System.Drawing.Point(150, 0); this.LbSN.Location = new System.Drawing.Point(150, 0);
this.lbFwVer.Name = "lbFwVer"; this.LbSN.Name = "LbSN";
this.lbFwVer.Size = new System.Drawing.Size(86, 23); this.LbSN.Size = new System.Drawing.Size(86, 23);
this.lbFwVer.Text = "FW Ver"; this.LbSN.Text = "S/N";
this.lbFwVer.TextSize = new System.Drawing.Size(82, 14); this.LbSN.TextSize = new System.Drawing.Size(82, 14);
// //
// ucModuleMainHeader // ucModuleMainHeader
// //
@@ -270,7 +270,7 @@
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem8)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem9)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem9)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem10)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.simpleLabelItem10)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lbFwVer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.LbSN)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -290,6 +290,6 @@
private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem8; private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem8;
private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem9; private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem9;
private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem10; private DevExpress.XtraLayout.SimpleLabelItem simpleLabelItem10;
private DevExpress.XtraLayout.SimpleLabelItem lbFwVer; private DevExpress.XtraLayout.SimpleLabelItem LbSN;
} }
} }

View File

@@ -13,6 +13,7 @@ drop table if exists TModuleValue;
create table TModuleValue create table TModuleValue
( (
create_date timestamp not null , create_date timestamp not null ,
log_type integer not null ,
module_no smallint not null , module_no smallint not null ,
model_name varchar(32) null , model_name varchar(32) null ,
module_sn varchar(32) null , module_sn varchar(32) null ,
@@ -56,3 +57,32 @@ create table TModuleValue
); );
create index ModuleValue_data_idx1 on TModuleValue (create_date); create index ModuleValue_data_idx1 on TModuleValue (create_date);
/*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Table Name : TAlarmHistory
* Description : Battery System Alarm History Table
* createAt : 2022.10.25
* createBy : JK.Woo
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
drop table if exists TAlarmHistory;
create table TAlarmHistory
(
id integer primary key autoincrement, -- ¡Ú Ãæµ¹ ¹æÁö¸¦ À§ÇÑ surrogate key
create_date timestamp not null,
alarm_code integer null,
alarm_status integer null,
alarm_cname varchar(32) null,
alarm_sname varchar(32) null,
module_no integer null,
ct_no integer null,
alarm_param_1 numeric null,
alarm_param_2 numeric null,
alarm_param_3 numeric null,
alarm_param_4 numeric null,
remark varchar(32) null
);
create unique index IF NOT EXISTS uq_TAlarmHistory_ck on TAlarmHistory (create_date, alarm_code, alarm_status);
create index IF NOT EXISTS idx_TAlarmHistory_date on TAlarmHistory (create_date);
create index IF NOT EXISTS idx_TAlarmHistory_mod on TAlarmHistory (module_no, create_date);

View File

@@ -214,11 +214,7 @@ namespace LFP_Manager
private void btnCreateNewDb_Click(object sender, EventArgs e) private void btnCreateNewDb_Click(object sender, EventArgs e)
{ {
string ModelName; csDbUtils.DbCreateLOG(Config);
ModelName = csConstData.UART_MODEL[Config.UartModelIndex];
csDbUtils.LogDbCreateNew(ModelName);
} }
private void btnCheckMeasData_Click(object sender, EventArgs e) private void btnCheckMeasData_Click(object sender, EventArgs e)

View File

@@ -124,28 +124,28 @@
<data name="fmxHistory.IconOptions.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="fmxHistory.IconOptions.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
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
YII= YAAAAABJRU5ErkJggg==
</value> </value>
</data> </data>
</root> </root>

View File

@@ -177,6 +177,7 @@ namespace LFP_Manager.Forms
} }
uTarget.UpdateStatus(Active); uTarget.UpdateStatus(Active);
uDataLog.UpdateActiveStatus(Active, Config, ref DeviceData); uDataLog.UpdateActiveStatus(Active, Config, ref DeviceData);
uEventLog.UpdateConfig(Config);
DisplayCommStatus(); DisplayCommStatus();
} }

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.6")] [assembly: AssemblyVersion("1.0.0.7")]
[assembly: AssemblyFileVersion("1.0.0.6")] [assembly: AssemblyFileVersion("1.0.0.7")]

View File

@@ -76,9 +76,8 @@ namespace LFP_Manager.Threads
// DB 경로 준비 (예외는 루프에서 잡히지만 시작 시도 전 준비) // DB 경로 준비 (예외는 루프에서 잡히지만 시작 시도 전 준비)
try try
{ {
csDbUtils.DbCreateLOG(Config);
string modelname = csConstData.UART_MODEL[Config.UartModelIndex]; string modelname = csConstData.UART_MODEL[Config.UartModelIndex];
csDbUtils.LogDbCreate(modelname);
DbCreate(modelname, DateTime.Now);
// 최초 활성 진입 // 최초 활성 진입
if (Active) if (Active)
@@ -155,12 +154,11 @@ namespace LFP_Manager.Threads
int periodSec = Math.Max(1, Config.DbLogPeriod); // 0 방지 int periodSec = Math.Max(1, Config.DbLogPeriod); // 0 방지
string modelName = csConstData.UART_MODEL[Config.UartModelIndex]; string modelName = csConstData.UART_MODEL[Config.UartModelIndex];
// 마지막 기록 시각 (UTC 권장; 로컬도 무방하지만 일관성 위해 UTC 사용) int lastLoggedSecond = -1; // 마지막으로 저장한 "초"
DateTime lastLogUtc = DateTime.UtcNow;
try try
{ {
CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, ""); CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(Config, DateTime.Now, "");
RaiseOnUpdateAlarmHistory(CurrAlarmHistory); // UI 마샬링 버전 RaiseOnUpdateAlarmHistory(CurrAlarmHistory); // UI 마샬링 버전
} }
catch (Exception ex) catch (Exception ex)
@@ -175,9 +173,11 @@ namespace LFP_Manager.Threads
DateTime nowLocal = DateTime.Now; DateTime nowLocal = DateTime.Now;
DateTime nowUtc = DateTime.UtcNow; DateTime nowUtc = DateTime.UtcNow;
int sec = nowUtc.Second;
// “초 변경” + “주기 정합” 검사 // “초 변경” + “주기 정합” 검사
// ★ 경과 시간 기반 주기 체크 (초 단위 주기 모두 정확) // ★ 경과 시간 기반 주기 체크 (초 단위 주기 모두 정확)
if ((nowUtc - lastLogUtc).TotalSeconds >= periodSec) if ((sec % periodSec) == 0 && sec != lastLoggedSecond)
{ {
// Database Log Process // Database Log Process
try try
@@ -202,21 +202,20 @@ namespace LFP_Manager.Threads
finally finally
{ {
// ★ 마지막 로그 시각 갱신 (드리프트 최소화를 원하면 lastLogUtc += TimeSpan.FromSeconds(periodSec)) // ★ 마지막 로그 시각 갱신 (드리프트 최소화를 원하면 lastLogUtc += TimeSpan.FromSeconds(periodSec))
lastLogUtc = nowUtc; lastLoggedSecond = sec;
} }
} }
try try
{ {
// Alarm History Log // Alarm History Log
modelName = csConstData.UART_MODEL[Config.UartModelIndex]; csDbUtils.DbCreateLOG(Config);
csDbUtils.LogDbCreate(modelName);
for (int i = 0; i < mQty; i++) for (int i = 0; i < mQty; i++)
{ {
if (CheckStatusAndAlarm(i, modelName, Config, DeviceData.ModuleData[i], OldDevData.ModuleData[i])) if (CheckStatusAndAlarm(i, modelName, Config, DeviceData.ModuleData[i], OldDevData.ModuleData[i]))
{ {
CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, ""); CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(Config, DateTime.Now, "");
RaiseOnUpdateAlarmHistory(CurrAlarmHistory); RaiseOnUpdateAlarmHistory(CurrAlarmHistory);
} }
} }
@@ -618,7 +617,7 @@ namespace LFP_Manager.Threads
if (eventFlag) if (eventFlag)
{ {
csDbUtils.BmsLogDataInsert(modelName, ref nModule, now, 1); csDbUtils.BmsLogDataInsert(modelName, ref nModule, now, 1, 1);
} }
return eventFlag; return eventFlag;
} }
@@ -995,7 +994,7 @@ namespace LFP_Manager.Threads
if (anyAlarm) if (anyAlarm)
{ {
CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(modelName, DateTime.Now, ""); CurrAlarmHistory = csDbUtils.GetBmsAlarmDataByDataTable(Config, DateTime.Now, "");
RaiseOnUpdateAlarmHistory(CurrAlarmHistory); RaiseOnUpdateAlarmHistory(CurrAlarmHistory);
} }

View File

@@ -1,4 +1,5 @@
using LFP_Manager.DataStructure; using DevExpress.Utils.Drawing;
using LFP_Manager.DataStructure;
using System; using System;
using System.Data; using System.Data;
using System.Data.SQLite; using System.Data.SQLite;
@@ -17,9 +18,9 @@ namespace LFP_Manager.Utils
public static string DbSchemaTableFileName = @"\sql\DB_SCHEMA_TABLE.sql"; public static string DbSchemaTableFileName = @"\sql\DB_SCHEMA_TABLE.sql";
public static string ModuleTableName = @"TModule"; public static string ModuleTableName = @"TModule";
public static string LogDbFilePath = @"\db"; public static string LogDbFilePath = @"db";
public static string LogDbFileNameFormat = @"\{0}\{1}_{2}_LOG.DB"; public static string LogDbFileNameFormat = @"{0}\{1}_{2}_LOG.DB";
public static string LogDbSchemaTableFileName = @"\sql\LOG_DB_SCHEMA_TABLE.sql"; public static string LogDbSchemaTableFileName = @"sql\LOG_DB_SCHEMA_TABLE.sql";
public static DateTime Delay(int ms) public static DateTime Delay(int ms)
{ {
@@ -29,8 +30,7 @@ namespace LFP_Manager.Utils
while (afterMoment >= thisMoment) while (afterMoment >= thisMoment)
{ {
System.Windows.Forms.Application.DoEvents(); Application.DoEvents();
thisMoment = DateTime.Now; thisMoment = DateTime.Now;
} }
@@ -53,6 +53,21 @@ namespace LFP_Manager.Utils
command.Dispose(); command.Dispose();
} }
#region COMMON DB HELPERS
private static DataTable ExecSelect(string dbPath, string sql)
{
var dt = new DataTable();
using (var conn = new SQLiteConnection(@"Data Source=" + dbPath))
using (var adp = new SQLiteDataAdapter(sql, conn))
{
conn.Open();
adp.AcceptChangesDuringFill = false;
adp.Fill(dt);
}
return dt;
}
#endregion
#region CREATE DATABASE #region CREATE DATABASE
public static void DbCreate(string mSN, string bName) public static void DbCreate(string mSN, string bName)
@@ -163,57 +178,41 @@ namespace LFP_Manager.Utils
return; return;
} }
public static void LogDbCreateNew(string aModel) #endregion
#region DB CREATE FUNCTION (LOG)
public static void DbCreateLOG(CommConfig aConfig)
{ {
string result = ""; string modelName = csConstData.UART_MODEL[aConfig.UartModelIndex];
string ModelName = aModel;
//public static string LogDbFileNameFormat = @"\{0}\{1}_{2}_LOG.DB";
string dbFilename = String.Format(LogDbFileNameFormat
, String.Format("{0:yyMM}", DateTime.Now)
, String.Format("{0:yyMMdd}", DateTime.Now)
, ModelName
);
string dbFilePath = Path.GetDirectoryName(Application.ExecutablePath) + LogDbFilePath + dbFilename;
if (Directory.Exists(System.IO.Path.GetDirectoryName(dbFilePath)) == false) string folder = string.Format("{0:yyMM}", DateTime.Now);
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(dbFilePath)); string file = string.Format("{0}_{1}_LOG.DB", string.Format("{0:yyMMdd}", DateTime.Now), modelName);
string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
string dbFilePath = csUtils.CombineApp(exeDir, LogDbFilePath, folder, file);
string dir = Path.GetDirectoryName(dbFilePath);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
if (File.Exists(dbFilePath)) return;
// Create database
SQLiteConnection.CreateFile(dbFilePath); SQLiteConnection.CreateFile(dbFilePath);
// Open database string schemaFile = csUtils.CombineApp(LogDbSchemaTableFileName);
string strConn = @"Data Source=" + dbFilePath; string query = File.ReadAllText(schemaFile);
using (var connection = new SQLiteConnection(strConn))
using (var connection = new SQLiteConnection(@"Data Source=" + dbFilePath))
{ {
connection.Open(); connection.Open();
try using (var command = connection.CreateCommand())
{ {
// Create table command.CommandText = query;
using (SQLiteCommand command = connection.CreateCommand()) using (var reader = command.ExecuteReader()) { /* schema create */ }
{
string schemaFile = Path.GetDirectoryName(Application.ExecutablePath) + LogDbSchemaTableFileName;
string query = File.ReadAllText(schemaFile);
command.CommandText = query;
SQLiteDataReader reader = null;
reader = command.ExecuteReader();
}
}
catch (Exception e)
{
result = e.Message;
}
finally
{
connection.Close();
if (result != "") throw new Exception(result);
} }
} }
return;
} }
#endregion #endregion
#region MAKE LOT NUMBER #region MAKE LOT NUMBER
public static string MakeLotNumber(string mSN) public static string MakeLotNumber(string mSN)
{ {
@@ -474,126 +473,195 @@ namespace LFP_Manager.Utils
#region BMS DATA INSERT AND UPDATE #region BMS DATA INSERT AND UPDATE
public static void BmsLogDataInsert(string ModelName, ref CsDeviceData.DeviceModuleData mData, DateTime dateTime, int cvUnit) public static string GetDbFilePath(string modelName, DateTime dateTime)
{
string folder = string.Format("{0:yyMM}", dateTime); // 2512
string file = string.Format("{0}_{1}_LOG.DB", string.Format("{0:yyMMdd}", dateTime), modelName); // 251221_LFPM-48100SB_LOG.DB
string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
string dbPath = csUtils.CombineApp(exeDir, LogDbFilePath, folder, file); // db\2512\251221_LFPM-48100SB_LOG.DB
return dbPath;
}
public static void BmsLogDataInsert(string ModelName, ref CsDeviceData.DeviceModuleData mData, DateTime dateTime, int cvUnit, int log_type = 0)
{ {
string result = ""; string result = "";
//string ModelName = csConstData.CAN_MODEL[aConfig.CanModelIndex]; string dbFilePath = GetDbFilePath(ModelName, dateTime);
//public static string LogDbFileNameFormat = @"\{0}\{1}_{2}_LOG.DB";
string dbFilename = String.Format(LogDbFileNameFormat
, String.Format("{0:yyMM}", DateTime.Now)
, String.Format("{0:yyMMdd}", DateTime.Now)
, ModelName
);
string dbFilePath = Path.GetDirectoryName(Application.ExecutablePath) + LogDbFilePath + dbFilename;
if (Directory.Exists(Path.GetDirectoryName(dbFilePath)) == false) if (Directory.Exists(Path.GetDirectoryName(dbFilePath)) == false)
throw new Exception("No Log DB file path"); throw new Exception("No Log DB file path");
if (File.Exists(dbFilePath) == false) if (File.Exists(dbFilePath) == false)
throw new Exception(String.Format("No Log DB file - BmsLogDataInsert ({0})", dbFilename)); throw new Exception(String.Format("No Log DB file - BmsLogDataInsert ({0})", dbFilePath));
// Open database // Open database
string strConn = @"Data Source=" + dbFilePath; string strConn = @"Data Source=" + dbFilePath;
using (var connection = new SQLiteConnection(strConn)) using (var connection = new SQLiteConnection(strConn))
{ {
SQLiteTransaction tran = null;
try try
{ {
connection.Open(); connection.Open();
BeginTran(connection);
// 기존 BeginTran/CommitTran을 유지하고 싶으면 tran 대신 그걸 쓰셔도 됩니다.
// 다만 C# 7.3에서는 아래 표준 방식이 제일 안전합니다.
tran = connection.BeginTransaction();
// Insert data // Insert data
using (SQLiteCommand command = connection.CreateCommand()) using (SQLiteCommand command = connection.CreateCommand())
{ {
command.Transaction = tran;
// 스키마 기준: cell 15, temp 4 고정
const int CELL_MAX = 15;
const int TEMP_MAX = 4;
//sSQL = "insert into TrendTable ( TrendStamp, TagName, TagValue) Values ( " + IntToStr(stamp) + "," + name + "," + value + ");"; //sSQL = "insert into TrendTable ( TrendStamp, TagName, TagValue) Values ( " + IntToStr(stamp) + "," + name + "," + value + ");";
command.CommandText = String.Format("INSERT INTO TModuleValue ("); command.CommandText = "INSERT INTO TModuleValue ("
command.CommandText += "create_date" // 0 + "create_date"
+ ", module_no" // 1 + ", log_type"
+ ", model_name" // 2 + ", module_no"
+ ", module_sn" // 3 + ", model_name"
+ ", fw_ver" // 4 + ", module_sn"
+ ", comm_fail" // 5 + ", fw_ver"
+ ", op_status" // 6 + ", comm_fail"
+ ", alarm_status" // 7 + ", op_status"
+ ", warning" // 8 + ", alarm_status"
+ ", fault" // 9 + ", warning"
+ ", module_voltage" // 10 + ", fault"
+ ", module_current" // 11 + ", module_voltage"
+ ", module_soc" // 12 + ", module_current"
+ ", module_soh" // 13 + ", module_soc"
+ ", module_cyclecount" // 14 + ", module_soh"
; + ", module_cyclecount"
for (int i = 0; i < mData.cellQty; i++) + ", cv_diff";
{
command.CommandText += String.Format(", cell_voltage_{0:00}", i + 1); // 14 ~ 28; 15 cells for (int i = 0; i < CELL_MAX; i++)
} command.CommandText += $", cell_voltage_{i + 1:00}";
for (int i = 0; i < mData.tempQty; i++)
{ command.CommandText += ", tp_diff";
command.CommandText += String.Format(", temperature_{0:00}", i + 1); // 29 ~ 32; 6 temps
} for (int i = 0; i < TEMP_MAX; i++)
command.CommandText += $", temperature_{i + 1:00}";
command.CommandText += "" command.CommandText += ""
+ ", ext1_temp" // 35 + ", ext1_temp"
+ ", ext2_temp" // 35 + ", ext2_temp"
+ ", chg_option" // 35 + ", chg_option"
+ ")" + ") VALUES (";
+ " Values (";
int total = 15 + mData.cellQty + mData.tempQty + 3; int total = 16 + 1 + CELL_MAX + 1 + TEMP_MAX + 3;
// 16(기본 0~15) + cv_diff(1) + cell15 + tp_diff(1) + temp4 + ext1/ext2/chg(3)
for (int i = 0; i < (total - 1); i++) command.CommandText += "?,"; for (int i = 0; i < total - 1; i++) command.CommandText += "?,";
command.CommandText += "?);"; command.CommandText += "?);";
SQLiteParameter[] p = new SQLiteParameter[total];
for (int i = 0; i < total; i++) for (int i = 0; i < total; i++)
{ command.Parameters.Add(new SQLiteParameter());
if (i == 0)
p[i] = new SQLiteParameter(DbType.DateTime);
else
p[i] = new SQLiteParameter();
command.Parameters.Add(p[i]);
}
int j = 0; int j = 0;
p[j++].Value = dateTime; // 0 create_date
p[j++].Value = mData.mNo; // 1 Module No
p[j++].Value = mData.Information.ModelName; // 2 model_name
p[j++].Value = mData.Information.HwSerialNumber; // 3 module_sn
p[j++].Value = mData.Information.SwProductRev; // 4 fw_ver
p[j++].Value = mData.ShelfCommFail; // 5 comm_fail command.Parameters[j++].Value = dateTime; // create_date
p[j++].Value = mData.StatusData.status; // 6 op_status command.Parameters[j++].Value = log_type; // log_type
p[j++].Value = mData.StatusData.batteryStatus; // 7 alarm_status command.Parameters[j++].Value = mData.mNo; // module_no
p[j++].Value = mData.StatusData.warning; // 8 warning command.Parameters[j++].Value = (object)mData.Information.ModelName ?? DBNull.Value;
p[j++].Value = mData.StatusData.protect; // 9 fault command.Parameters[j++].Value = (object)mData.Information.HwSerialNumber ?? DBNull.Value;
p[j++].Value = ((float)mData.ValueData.voltage / 10).ToString(); // 10 module_voltage command.Parameters[j++].Value = (object)mData.Information.SwProductRev ?? DBNull.Value;
p[j++].Value = ((float)mData.ValueData.current / 10).ToString(); // 11 module_current
p[j++].Value = ((float)mData.ValueData.SOC / 10).ToString(); // 12 module_soc
p[j++].Value = ((float)mData.ValueData.SOH / 10).ToString(); // 13 module_soh
p[j++].Value = ((float)mData.ValueData.cycleCount / 1).ToString(); // 14 module_soh
for (int i = 0; i < mData.cellQty; i++) command.Parameters[j++].Value = mData.ShelfCommFail; // comm_fail (bool -> 0/1도 가능)
command.Parameters[j++].Value = mData.StatusData.status; // op_status
command.Parameters[j++].Value = mData.StatusData.batteryStatus; // alarm_status
command.Parameters[j++].Value = mData.StatusData.warning; // warning
command.Parameters[j++].Value = mData.StatusData.protect; // fault
command.Parameters[j++].Value = mData.ValueData.voltage / 10.0; // module_voltage
command.Parameters[j++].Value = mData.ValueData.current / 10.0; // module_current
command.Parameters[j++].Value = mData.ValueData.SOC / 10.0; // module_soc
command.Parameters[j++].Value = mData.ValueData.SOH / 10.0; // module_soh
command.Parameters[j++].Value = mData.ValueData.cycleCount; // module_cyclecount
// cv_diff = 셀 전압 max-min (V)
object cvDiffValue = DBNull.Value;
if (mData.ValueData.CellVoltage != null && mData.cellQty > 0)
{ {
p[j++].Value = ((float)mData.ValueData.CellVoltage[i] / cvUnit).ToString(); // 15 cell_voltage_01 int n = Math.Min(mData.cellQty, CELL_MAX);
} double minV = double.MaxValue;
for (int i = 0; i < mData.tempQty; i++) double maxV = double.MinValue;
{
p[j++].Value = ((float)mData.ValueData.CellTemperature[i] / 10).ToString(); // 30 temperature_01
}
p[j++].Value = ((float)mData.ValueData.MosTemperature / 10).ToString(); // 34 temperature_ext1 - FET Temp
p[j++].Value = ((float)mData.ValueData.AmbTemperature / 10).ToString(); // 35 temperature_ext2 - Lmt Temp
p[j++].Value = mData.CalibrationData.Current.ChargeOption.ToString(); // 36 chg_option for (int i = 0; i < n; i++)
{
double v = mData.ValueData.CellVoltage[i] / (double)cvUnit;
if (v < minV) minV = v;
if (v > maxV) maxV = v;
}
if (minV != double.MaxValue)
cvDiffValue = (maxV - minV);
}
command.Parameters[j++].Value = cvDiffValue; // cv_diff
// cell_voltage_01..15 (없으면 NULL)
for (int i = 0; i < CELL_MAX; i++)
{
if (mData.ValueData.CellVoltage != null && i < mData.cellQty)
command.Parameters[j++].Value = mData.ValueData.CellVoltage[i] / (double)cvUnit;
else
command.Parameters[j++].Value = DBNull.Value;
}
// tp_diff = 온도 max-min (°C)
object tpDiffValue = DBNull.Value;
if (mData.ValueData.CellTemperature != null && mData.tempQty > 0)
{
int n = Math.Min(mData.tempQty, TEMP_MAX);
double minT = double.MaxValue;
double maxT = double.MinValue;
for (int i = 0; i < n; i++)
{
double t = mData.ValueData.CellTemperature[i] / 10.0;
if (t < minT) minT = t;
if (t > maxT) maxT = t;
}
if (minT != double.MaxValue)
tpDiffValue = (maxT - minT);
}
command.Parameters[j++].Value = tpDiffValue; // tp_diff
// temperature_01..04 (없으면 NULL)
for (int i = 0; i < TEMP_MAX; i++)
{
if (mData.ValueData.CellTemperature != null && i < mData.tempQty)
command.Parameters[j++].Value = mData.ValueData.CellTemperature[i] / 10.0;
else
command.Parameters[j++].Value = DBNull.Value;
}
command.Parameters[j++].Value = mData.ValueData.MosTemperature / 10.0; // ext1_temp
command.Parameters[j++].Value = mData.ValueData.AmbTemperature / 10.0; // ext2_temp
command.Parameters[j++].Value = (short)mData.CalibrationData.Current.ChargeOption; // chg_option
if (j != total)
throw new Exception(string.Format("Parameter mismatch: j={0}, total={1}", j, total));
command.ExecuteNonQuery(); command.ExecuteNonQuery();
CommitTran(connection);
} }
tran.Commit();
} }
catch (Exception e) catch (Exception e)
{ {
try
{
if (tran != null) tran.Rollback();
}
catch { /* rollback 실패는 무시 or 로그 */ }
result = e.Message; result = e.Message;
} }
finally finally
{ {
if (tran != null) tran.Dispose();
if (connection.State == ConnectionState.Open) if (connection.State == ConnectionState.Open)
connection.Close(); connection.Close();
if (result != "") throw new Exception(result); if (result != "") throw new Exception(result);
@@ -1010,7 +1078,26 @@ namespace LFP_Manager.Utils
#endregion #endregion
#region ALARM HISTROTY DB FUNCTION #region ALARM HISTROTY DB FUNCTION
public static DataTable GetBmsAlarmDataByDataTable(string modelName, DateTime aDateTime, string qry) public static DataTable GetBmsAlarmDataByDataTable(CommConfig aConfig, DateTime aDateTime, string qry)
{
string modelName = csConstData.UART_MODEL[aConfig.UartModelIndex]; // LFPM-48100SB
string folder = string.Format("{0:yyMM}", aDateTime); // 2512
string file = string.Format("{0}_{1}_LOG.DB", string.Format("{0:yyMMdd}", aDateTime), modelName); // 251221_LFPM-48100SB_LOG.DB
string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
string dbPath = csUtils.CombineApp(exeDir, LogDbFilePath, folder, file); // db\2512\251221_LFPM-48100SB_LOG.DB
if (!File.Exists(dbPath)) return null;
string sql = string.IsNullOrWhiteSpace(qry)
? "SELECT * FROM TAlarmHistory ORDER BY create_date DESC"
: "SELECT * FROM TAlarmHistory " + qry;
var dt = ExecSelect(dbPath, sql);
dt.TableName = "TAlarmHistory";
return dt;
}
public static DataTable GetBmsAlarmDataByDataTable1(string modelName, DateTime aDateTime, string qry)
{ {
// 결과 테이블(항상 non-null 반환) // 결과 테이블(항상 non-null 반환)
var dtResult = new DataTable("TAlarmHistory"); var dtResult = new DataTable("TAlarmHistory");
@@ -1020,7 +1107,7 @@ namespace LFP_Manager.Utils
LogDbFileNameFormat, LogDbFileNameFormat,
aDateTime.ToString("yyMM"), aDateTime.ToString("yyMM"),
aDateTime.ToString("yyMMdd"), aDateTime.ToString("yyMMdd"),
modelName); modelName); // \2512\{1}_{2}_LOG.DB";
// 실행파일 경로 + 로그 DB 상대경로 + 파일명 안전 결합 // 실행파일 경로 + 로그 DB 상대경로 + 파일명 안전 결합
string exeDir = Path.GetDirectoryName(Application.ExecutablePath); string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
@@ -1316,13 +1403,9 @@ namespace LFP_Manager.Utils
{ {
string result = ""; string result = "";
DataTable dtResult = null; DataTable dtResult = null;
string ModelName = csConstData.UART_MODEL[aConfig.UartModelIndex]; string ModelName = csConstData.UART_MODEL[aConfig.UartModelIndex];
string dbFilename = String.Format(LogDbFileNameFormat string dbFilePath = GetDbFilePath(ModelName, aDate);
, String.Format("{0:yyMM}", aDate)
, String.Format("{0:yyMMdd}", aDate)
, ModelName
);
string dbFilePath = Path.GetDirectoryName(Application.ExecutablePath) + LogDbFilePath + dbFilename;
if (Directory.Exists(System.IO.Path.GetDirectoryName(dbFilePath)) == false) if (Directory.Exists(System.IO.Path.GetDirectoryName(dbFilePath)) == false)
return dtResult; return dtResult;

View File

@@ -78,6 +78,28 @@ namespace LFP_Manager.Utils
} }
#endregion #endregion
#region PATH HELPERS
public static string AppDir()
{
var p = Path.GetDirectoryName(Application.ExecutablePath);
return string.IsNullOrEmpty(p) ? AppContext.BaseDirectory : p;
}
public static string CombineApp(params string[] segs)
{
if (segs == null || segs.Length == 0)
return string.Empty;
return Path.Combine(segs);
}
public static string Utf8Z(byte[] bytes)
{
var s = Encoding.UTF8.GetString(bytes ?? new byte[0]);
return s.Trim('\0');
}
#endregion
public static int GetModuleQty(CommConfig aConfig) public static int GetModuleQty(CommConfig aConfig)
{ {
int mQty = 0; int mQty = 0;