실시간트렌드뷰 Pub_RemoteCommandEvent 화면UI 오류에 대한 예외처리 추가

This commit is contained in:
shark219-hub
2024-12-13 18:42:24 +09:00
parent 9d580a0f98
commit 50d5ea91fc
11 changed files with 341 additions and 314 deletions

View File

@@ -87,7 +87,7 @@ namespace vmsnet
this.cmb_tanks.FormattingEnabled = true;
this.cmb_tanks.Location = new System.Drawing.Point(72, 3);
this.cmb_tanks.Name = "cmb_tanks";
this.cmb_tanks.Size = new System.Drawing.Size(1052, 40);
this.cmb_tanks.Size = new System.Drawing.Size(1052, 37);
this.cmb_tanks.TabIndex = 16;
this.cmb_tanks.SelectedIndexChanged += new System.EventHandler(this.cmb_group_SelectedIndexChanged);
//
@@ -124,7 +124,7 @@ namespace vmsnet
this.TableLayoutPanel1.RowCount = 2;
this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 39F));
this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.TableLayoutPanel1.Size = new System.Drawing.Size(1247, 860);
this.TableLayoutPanel1.Size = new System.Drawing.Size(1247, 862);
this.TableLayoutPanel1.TabIndex = 9;
//
// Panel2
@@ -132,7 +132,7 @@ namespace vmsnet
this.Panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.Panel2.Location = new System.Drawing.Point(3, 42);
this.Panel2.Name = "Panel2";
this.Panel2.Size = new System.Drawing.Size(1241, 815);
this.Panel2.Size = new System.Drawing.Size(1241, 817);
this.Panel2.TabIndex = 8;
//
// bsCHList
@@ -167,16 +167,16 @@ namespace vmsnet
this.cmb_time,
this.prb1,
this.btConfig});
this.ToolStrip2.Location = new System.Drawing.Point(0, 860);
this.ToolStrip2.Location = new System.Drawing.Point(0, 862);
this.ToolStrip2.Name = "ToolStrip2";
this.ToolStrip2.Size = new System.Drawing.Size(1247, 33);
this.ToolStrip2.Size = new System.Drawing.Size(1247, 31);
this.ToolStrip2.TabIndex = 10;
this.ToolStrip2.Text = "ToolStrip2";
//
// ToolStripLabel1
//
this.ToolStripLabel1.Name = "ToolStripLabel1";
this.ToolStripLabel1.Size = new System.Drawing.Size(84, 28);
this.ToolStripLabel1.Size = new System.Drawing.Size(69, 28);
this.ToolStripLabel1.Text = "전압범위";
//
// cmb_volt
@@ -194,13 +194,13 @@ namespace vmsnet
"17v",
"20v"});
this.cmb_volt.Name = "cmb_volt";
this.cmb_volt.Size = new System.Drawing.Size(75, 33);
this.cmb_volt.Size = new System.Drawing.Size(75, 31);
this.cmb_volt.SelectedIndexChanged += new System.EventHandler(this.cmb_volt_SelectedIndexChanged);
//
// ToolStripLabel2
//
this.ToolStripLabel2.Name = "ToolStripLabel2";
this.ToolStripLabel2.Size = new System.Drawing.Size(84, 28);
this.ToolStripLabel2.Size = new System.Drawing.Size(69, 28);
this.ToolStripLabel2.Text = "시간범위";
//
// cmb_time
@@ -214,7 +214,7 @@ namespace vmsnet
"30분",
"60분"});
this.cmb_time.Name = "cmb_time";
this.cmb_time.Size = new System.Drawing.Size(75, 33);
this.cmb_time.Size = new System.Drawing.Size(75, 31);
this.cmb_time.SelectedIndexChanged += new System.EventHandler(this.cmb_time_SelectedIndexChanged_1);
//
// prb1
@@ -230,7 +230,7 @@ namespace vmsnet
this.btConfig.Image = global::vmsnet.Properties.Resources.graphsetting;
this.btConfig.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btConfig.Name = "btConfig";
this.btConfig.Size = new System.Drawing.Size(34, 28);
this.btConfig.Size = new System.Drawing.Size(29, 28);
this.btConfig.Text = "config";
this.btConfig.Click += new System.EventHandler(this.btConfig_Click);
//

View File

@@ -147,73 +147,99 @@ namespace vmsnet
private void Pub_RemoteCommandEvent(object sender, RemoteCommand e)
{
if (e.Command == rCommand.ValueUpdate)
try
{
//스트리머,데이터,선택된 채널 정보가 있어야 업데이트 가능하다
if (e.Data != null && this.Streamer1 != null && this.selectchlist.Any())
if (e.Command == rCommand.ValueUpdate)
{
var data = e.Data as List<NotifyData>;
//선택된 채널의 정보만 사용
var recvdatas = data.Where(t => selectchlist.Contains(t.chno)).Select(t => t);
if (recvdatas.Any() == false) return; //대상채널데이터가 없다.
//받은데이터를 화면에 추가한다.
foreach (var newdata in recvdatas)
//스트리머,데이터,선택된 채널 정보가 있어야 업데이트 가능하다
if (e.Data != null && this.Streamer1 != null && this.selectchlist.Any())
{
var ch = newdata.chno - 1;
var val = newdata.value;
var time = newdata.time;
var data = e.Data as List<NotifyData>;
//자료가없거나 스트리머가 없는 경우
if (ch >= this.Streamer1.Length || this.Streamer1[ch] == null) continue;
//선택된 채널의 정보만 사용
var recvdatas = data.Where(t => selectchlist.Contains(t.chno)).Select(t => t);
if (recvdatas.Any() == false) return; //대상채널데이터가 없다.
float value = 0;
if (PUB.CONFIG.datadiv != 0 && PUB.CONFIG.datadiv != 1)
value = (newdata.value) / PUB.CONFIG.datadiv;
else
value = (newdata.value);
//채널정보를 통해서 소수점위치와 옾셋값을 가져온다
if (newdata.decpos > 0) value = (float)(value / Math.Pow(10, newdata.decpos));
//최종옵셋
value += newdata.offset;
//데이터 추가
if (this.Streamer1[ch].IsVisible)
//받은데이터를 화면에 추가한다.
foreach (var newdata in recvdatas)
{
var v_time = DateTime.Parse(time);
this.dataTime[ch].Add(v_time.ToOADate());
this.dataVolt[ch].Add(value);
var ch = newdata.chno - 1;
var val = newdata.value;
var time = newdata.time;
var mintime = DateTime.FromOADate(dataTime[ch].First());
var maxtime = DateTime.FromOADate(dataTime[ch].Last());
var ts = (maxtime - mintime);
if (ts.TotalMinutes >= this.timelimit)
//자료가없거나 스트리머가 없는 경우
if (ch >= this.Streamer1.Length || this.Streamer1[ch] == null) continue;
float value = 0;
if (PUB.CONFIG.datadiv != 0 && PUB.CONFIG.datadiv != 1)
value = (newdata.value) / PUB.CONFIG.datadiv;
else
value = (newdata.value);
//채널정보를 통해서 소수점위치와 옾셋값을 가져온다
if (newdata.decpos > 0) value = (float)(value / Math.Pow(10, newdata.decpos));
//최종옵셋
value += newdata.offset;
//데이터 추가
if (this.Streamer1[ch].IsVisible)
{
//10개지운다
if (dataTime[ch].Count > 10)
var v_time = DateTime.Parse(time);
this.dataTime[ch].Add(v_time.ToOADate());
this.dataVolt[ch].Add(value);
var mintime = DateTime.FromOADate(dataTime[ch].First());
var maxtime = DateTime.FromOADate(dataTime[ch].Last());
var ts = (maxtime - mintime);
if (ts.TotalMinutes >= this.timelimit)
{
dataTime[ch].RemoveRange(0, 10);
dataVolt[ch].RemoveRange(0, 10);
//10개지운다
if (dataTime[ch].Count > 10)
{
dataTime[ch].RemoveRange(0, 10);
dataVolt[ch].RemoveRange(0, 10);
}
}
}
}
this.BeginInvoke(new Action(() =>
{
if (voltlimit != 0) formsPlot1.Plot.Axes.AutoScaleX();
this.formsPlot1.Refresh();
}));
}
this.BeginInvoke(new Action(() =>
{
if (voltlimit != 0) formsPlot1.Plot.Axes.AutoScaleX();
this.formsPlot1.Refresh();
}));
}
}
catch (NullReferenceException ex1)
{
// 예외 메시지, 파일명, 행 번호를 로그에 기록
var stackTrace = new System.Diagnostics.StackTrace(ex1, true);
var frame = stackTrace.GetFrame(0);
string fileName = frame.GetFileName();
int lineNumber = frame.GetFileLineNumber();
// UI 디스플레이 중, 예외발생 문제
PUB.log.AddE($"NullReferenceException Message={ex1.Message}, 파일명={fileName}, 행번호={lineNumber}");
return;
}
catch (Exception ex2)
{
// 예외 메시지, 파일명, 행 번호를 로그에 기록
var stackTrace = new System.Diagnostics.StackTrace(ex2, true);
var frame = stackTrace.GetFrame(0);
string fileName = frame.GetFileName();
int lineNumber = frame.GetFileLineNumber();
// Else Error !!!
PUB.log.AddE($"Exception Message={ex2.Message}, 파일명={fileName}, 행번호={lineNumber}");
return;
}
}
#region "scott plot mouse event"