This commit is contained in:
backuppc
2026-01-14 15:29:38 +09:00
parent 5801137d63
commit d5516f9708
17 changed files with 605 additions and 402 deletions

View File

@@ -126,7 +126,7 @@ namespace AGVNavigationCore.PathFinding.Planning
/// <summary> /// <summary>
/// 단순 경로 찾기 (복잡한 제약조건/방향전환 로직 없이 A* 결과만 반환) /// 단순 경로 찾기 (복잡한 제약조건/방향전환 로직 없이 A* 결과만 반환)
/// </summary> /// </summary>
public AGVPathResult FindBasicPath(MapNode startNode, MapNode targetNode, MapNode prevNode, AgvDirection prevDirection) public AGVPathResult FindBasicPath(MapNode startNode, MapNode targetNode, MapNode _prevNode, AgvDirection prevDirection)
{ {
// 1. 입력 검증 // 1. 입력 검증
if (startNode == null || targetNode == null) if (startNode == null || targetNode == null)
@@ -134,13 +134,13 @@ namespace AGVNavigationCore.PathFinding.Planning
// 2. A* 경로 탐색 // 2. A* 경로 탐색
var pathResult = _basicPathfinder.FindPathAStar(startNode, targetNode); var pathResult = _basicPathfinder.FindPathAStar(startNode, targetNode);
pathResult.PrevNode = prevNode; pathResult.PrevNode = _prevNode;
pathResult.PrevDirection = prevDirection; pathResult.PrevDirection = prevDirection;
if (!pathResult.Success) if (!pathResult.Success)
return AGVPathResult.CreateFailure(pathResult.ErrorMessage ?? "경로 없음", 0, 0); return AGVPathResult.CreateFailure(pathResult.ErrorMessage ?? "경로 없음", 0, 0);
// 3. 상세 데이터 생성 (단순화: 방향 전환 없이 현재 방향 유지) // 3. 상세 데이터 생성 (갈림길 마그넷 방향 계산 포함)
if (pathResult.Path != null && pathResult.Path.Count > 0) if (pathResult.Path != null && pathResult.Path.Count > 0)
{ {
var detailedPath = new List<NodeMotorInfo>(); var detailedPath = new List<NodeMotorInfo>();
@@ -149,8 +149,47 @@ namespace AGVNavigationCore.PathFinding.Planning
var node = pathResult.Path[i]; var node = pathResult.Path[i];
string nextNodeId = (i + 1 < pathResult.Path.Count) ? pathResult.Path[i + 1].Id : null; string nextNodeId = (i + 1 < pathResult.Path.Count) ? pathResult.Path[i + 1].Id : null;
// 단순화: 입력된 현재 방향을 그대로 사용 // 마그넷 방향 계산 (갈림길인 경우)
var nodeInfo = new NodeMotorInfo(i + 1, node.Id, node.RfidId, prevDirection, nextNodeId, MagnetDirection.Straight); MagnetDirection magnetDirection = MagnetDirection.Straight;
if (node.ConnectedNodes != null && node.ConnectedNodes.Count >= 3 && i > 0 && nextNodeId != null)
{
// 갈림길인 경우: 진입 방향과 진출 방향의 각도 계산
var prevNode = pathResult.Path[i - 1];
var nextNode = pathResult.Path[i + 1];
// 진입 각도 계산 (이전 노드 → 현재 노드)
double entryAngle = Math.Atan2(
node.Position.Y - prevNode.Position.Y,
node.Position.X - prevNode.Position.X
) * 180.0 / Math.PI;
// 진출 각도 계산 (현재 노드 → 다음 노드)
double exitAngle = Math.Atan2(
nextNode.Position.Y - node.Position.Y,
nextNode.Position.X - node.Position.X
) * 180.0 / Math.PI;
// 각도 차이 계산 (-180~180 범위로 정규화)
double angleDiff = exitAngle - entryAngle;
while (angleDiff > 180) angleDiff -= 360;
while (angleDiff < -180) angleDiff += 360;
// 10도 이상 차이나면 좌/우회전 처리
if (Math.Abs(angleDiff) >= 10)
{
if (angleDiff > 0)
{
magnetDirection = MagnetDirection.Right;
}
else
{
magnetDirection = MagnetDirection.Left;
}
}
}
var nodeInfo = new NodeMotorInfo(i + 1, node.Id, node.RfidId, prevDirection, nextNodeId, magnetDirection);
// 속도 설정 // 속도 설정
var mapNode = _mapNodes.FirstOrDefault(n => n.Id == node.Id); var mapNode = _mapNodes.FirstOrDefault(n => n.Id == node.Id);
@@ -164,75 +203,7 @@ namespace AGVNavigationCore.PathFinding.Planning
return pathResult; return pathResult;
} }
/// <summary>
/// 이 작업후에 MakeMagnetDirection 를 추가로 실행 하세요
/// </summary>
/// <param name="path1"></param>
/// <param name="currentDirection"></param>
public void MakeDetailData(AGVPathResult path1, AgvDirection currentDirection)
{
if (path1.Success && path1.Path != null && path1.Path.Count > 0)
{
var detailedPath1 = new List<NodeMotorInfo>();
for (int i = 0; i < path1.Path.Count; i++)
{
var node = path1.Path[i];
string nodeId = node.Id;
var RfidId = node.RfidId;
string nextNodeId = (i + 1 < path1.Path.Count) ? path1.Path[i + 1].Id : null;
// 노드 정보 생성 (현재 방향 유지)
var nodeInfo = new NodeMotorInfo(i + 1,
nodeId, RfidId,
currentDirection,
nextNodeId,
MagnetDirection.Straight
);
// [Speed Control] MapNode의 속도 설정 적용
var mapNode = _mapNodes.FirstOrDefault(n => n.Id == nodeId);
if (mapNode != null)
{
nodeInfo.Speed = mapNode.SpeedLimit;
}
detailedPath1.Add(nodeInfo);
}
// path1에 상세 경로 정보 설정
path1.DetailedPath = detailedPath1;
}
}
/// <summary>
/// Path에 등록된 방향을 확인하여 마그넷정보를 업데이트 합니다
/// </summary>
/// <param name="path1"></param>
private void MakeMagnetDirection(AGVPathResult path1)
{
if (path1.Success && path1.DetailedPath != null && path1.DetailedPath.Count > 0)
{
for (int i = 0; i < path1.DetailedPath.Count; i++)
{
var detailPath = path1.DetailedPath[i];
string nodeId = path1.Path[i].Id;
string nextNodeId = (i + 1 < path1.Path.Count) ? path1.Path[i + 1].Id : null;
// 마그넷 방향 계산 (3개 이상 연결된 교차로에서만 좌/우 가중치 적용)
if (i > 0 && nextNodeId != null)
{
string prevNodeId = path1.Path[i - 1].Id;
if (path1.DetailedPath[i - 1].MotorDirection != detailPath.MotorDirection)
detailPath.MagnetDirection = MagnetDirection.Straight;
else
detailPath.MagnetDirection = _junctionAnalyzer.GetRequiredMagnetDirection(prevNodeId, nodeId, nextNodeId, detailPath.MotorDirection);
}
else detailPath.MagnetDirection = MagnetDirection.Straight;
}
}
}
} }

View File

@@ -120,6 +120,7 @@ namespace AGVSimulator.Forms
this._liftDirectionLabel = new System.Windows.Forms.Label(); this._liftDirectionLabel = new System.Windows.Forms.Label();
this._motorDirectionLabel = new System.Windows.Forms.Label(); this._motorDirectionLabel = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.btSelectMapEditor = new System.Windows.Forms.ToolStripMenuItem();
this._menuStrip.SuspendLayout(); this._menuStrip.SuspendLayout();
this._toolStrip.SuspendLayout(); this._toolStrip.SuspendLayout();
this._statusStrip.SuspendLayout(); this._statusStrip.SuspendLayout();
@@ -154,6 +155,7 @@ namespace AGVSimulator.Forms
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
this.launchMapEditorToolStripMenuItem, this.launchMapEditorToolStripMenuItem,
this.btSelectMapEditor,
this.toolStripSeparator4, this.toolStripSeparator4,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
@@ -547,7 +549,7 @@ namespace AGVSimulator.Forms
// //
// btPath2 // btPath2
// //
this.btPath2.Location = new System.Drawing.Point(12, 201); this.btPath2.Location = new System.Drawing.Point(12, 177);
this.btPath2.Name = "btPath2"; this.btPath2.Name = "btPath2";
this.btPath2.Size = new System.Drawing.Size(106, 25); this.btPath2.Size = new System.Drawing.Size(106, 25);
this.btPath2.TabIndex = 10; this.btPath2.TabIndex = 10;
@@ -588,6 +590,7 @@ namespace AGVSimulator.Forms
// _targetNodeCombo // _targetNodeCombo
// //
this._targetNodeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this._targetNodeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this._targetNodeCombo.Font = new System.Drawing.Font("돋움체", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this._targetNodeCombo.Location = new System.Drawing.Point(10, 97); this._targetNodeCombo.Location = new System.Drawing.Point(10, 97);
this._targetNodeCombo.Name = "_targetNodeCombo"; this._targetNodeCombo.Name = "_targetNodeCombo";
this._targetNodeCombo.Size = new System.Drawing.Size(210, 20); this._targetNodeCombo.Size = new System.Drawing.Size(210, 20);
@@ -605,6 +608,7 @@ namespace AGVSimulator.Forms
// _startNodeCombo // _startNodeCombo
// //
this._startNodeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this._startNodeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this._startNodeCombo.Font = new System.Drawing.Font("돋움체", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this._startNodeCombo.Location = new System.Drawing.Point(10, 45); this._startNodeCombo.Location = new System.Drawing.Point(10, 45);
this._startNodeCombo.Name = "_startNodeCombo"; this._startNodeCombo.Name = "_startNodeCombo";
this._startNodeCombo.Size = new System.Drawing.Size(210, 20); this._startNodeCombo.Size = new System.Drawing.Size(210, 20);
@@ -812,6 +816,13 @@ namespace AGVSimulator.Forms
this.timer1.Interval = 500; this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// //
// btSelectMapEditor
//
this.btSelectMapEditor.Name = "btSelectMapEditor";
this.btSelectMapEditor.Size = new System.Drawing.Size(221, 22);
this.btSelectMapEditor.Text = "Mapeditor 선택";
this.btSelectMapEditor.Click += new System.EventHandler(this.btSelectMapEditor_Click);
//
// SimulatorForm // SimulatorForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -925,5 +936,6 @@ namespace AGVSimulator.Forms
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.PropertyGrid propertyNode; private System.Windows.Forms.PropertyGrid propertyNode;
private System.Windows.Forms.Button btPath2; private System.Windows.Forms.Button btPath2;
private System.Windows.Forms.ToolStripMenuItem btSelectMapEditor;
} }
} }

View File

@@ -833,8 +833,8 @@ namespace AGVSimulator.Forms
{ {
for (int i = 0; i < _startNodeCombo.Items.Count; i++) for (int i = 0; i < _startNodeCombo.Items.Count; i++)
{ {
var item = _startNodeCombo.Items[i].ToString(); var item = _startNodeCombo.Items[i] as ComboBoxItem<MapNode>;//.ToString();
if (item.Contains($"[{nodeId}]")) if (item.Value.Id.Equals(nodeId))
{ {
_startNodeCombo.SelectedIndex = i; _startNodeCombo.SelectedIndex = i;
Program.WriteLine($"[SYSTEM] 시작 노드를 '{nodeId}'로 자동 선택했습니다."); Program.WriteLine($"[SYSTEM] 시작 노드를 '{nodeId}'로 자동 선택했습니다.");
@@ -958,10 +958,10 @@ namespace AGVSimulator.Forms
{ {
foreach (var node in _simulatorCanvas.Nodes) foreach (var node in _simulatorCanvas.Nodes)
{ {
if (node.IsActive && node.HasRfid()) if (node.IsActive)
{ {
// {rfid} - [{node}] {name} 형식으로 ComboBoxItem 생성 // {rfid} - [{node}] {name} 형식으로 ComboBoxItem 생성
var displayText = $"{node.RfidId} - [{node.Id}]"; var displayText = $"{node.StationType.ToString().PadRight(7)} | {node.ID2}";
var item = new ComboBoxItem<MapNode>(node, displayText); var item = new ComboBoxItem<MapNode>(node, displayText);
_startNodeCombo.Items.Add(item); _startNodeCombo.Items.Add(item);
@@ -1007,8 +1007,8 @@ namespace AGVSimulator.Forms
_stopSimulationButton.Enabled = _simulationState.IsRunning; _stopSimulationButton.Enabled = _simulationState.IsRunning;
_removeAgvButton.Enabled = _agvListCombo.SelectedItem != null; _removeAgvButton.Enabled = _agvListCombo.SelectedItem != null;
// btPath1.Enabled = _startNodeCombo.SelectedItem != null && // btPath1.Enabled = _startNodeCombo.SelectedItem != null &&
// _targetNodeCombo.SelectedItem != null; // _targetNodeCombo.SelectedItem != null;
// RFID 위치 설정 관련 // RFID 위치 설정 관련
var hasSelectedAGV = _agvListCombo.SelectedItem != null; var hasSelectedAGV = _agvListCombo.SelectedItem != null;
@@ -2571,8 +2571,8 @@ namespace AGVSimulator.Forms
if (!pathToGateway.Success) return (false, $"Gateway({gatewayNode.ID2})까지 경로 실패: {pathToGateway.ErrorMessage}"); if (!pathToGateway.Success) return (false, $"Gateway({gatewayNode.ID2})까지 경로 실패: {pathToGateway.ErrorMessage}");
//마지막경로는 게이트웨이이므로 제거하낟. //마지막경로는 게이트웨이이므로 제거하낟.(260113)
if(pathToGateway.Path.Count > 1) if (pathToGateway.Path.Count > 1 && pathToGateway.Path.Last().Id == gatewayNode.Id)
{ {
pathToGateway.Path.RemoveAt(pathToGateway.Path.Count - 1); pathToGateway.Path.RemoveAt(pathToGateway.Path.Count - 1);
pathToGateway.DetailedPath.RemoveAt(pathToGateway.DetailedPath.Count - 1); pathToGateway.DetailedPath.RemoveAt(pathToGateway.DetailedPath.Count - 1);
@@ -2584,7 +2584,7 @@ namespace AGVSimulator.Forms
MapNode GateprevNode = pathToGateway.Path.Last(); MapNode GateprevNode = pathToGateway.Path.Last();
NodeMotorInfo GatePrevDetail = pathToGateway.DetailedPath.Last(); NodeMotorInfo GatePrevDetail = pathToGateway.DetailedPath.Last();
var arrivalOrientation = GatePrevDetail.MotorDirection; var arrivalOrientation = GatePrevDetail.MotorDirection;
//아래코드오류발생함 //아래코드오류발생함
@@ -2643,21 +2643,33 @@ namespace AGVSimulator.Forms
var isMonitorLeft = false; var isMonitorLeft = false;
bool requiredDir = false; bool requiredDir = false;
if (deltaX > 0) //게이트웨이가 우측에 있다
{
//이떄 모터방향이 후진이라면 모니터는 왼쪽이고, 반대는 오른쪽이다
isMonitorLeft = PrevDirection == AgvDirection.Backward;
}
else
{
isMonitorLeft = PrevDirection == AgvDirection.Forward;
}
//로더는 상/하 개념으로 처리해야한다.X축이아닌 Y축을 봐야한다.
if (targetNode.StationType == StationType.Loader || targetNode.StationType == StationType.Charger2)
{
deltaX = GTNode.Position.Y - PrevNode.Position.Y;
if (deltaX < 0) isMonitorLeft = PrevDirection == AgvDirection.Backward;
else isMonitorLeft = PrevDirection == AgvDirection.Forward;
}
switch (targetNode.StationType) switch (targetNode.StationType)
{ {
case StationType.Loader:
case StationType.Charger2:
case StationType.Charger1: case StationType.Charger1:
case StationType.UnLoader: case StationType.UnLoader:
case StationType.Clearner: case StationType.Clearner:
case StationType.Buffer: case StationType.Buffer:
if (deltaX > 0) //게이트웨이가 우측에 있다
{
//이떄 모터방향이 후진이라면 모니터는 왼쪽이고, 반대는 오른쪽이다
isMonitorLeft = PrevDirection == AgvDirection.Backward;
}
else
{
isMonitorLeft = PrevDirection == AgvDirection.Forward;
}
//버퍼는 모니터가 왼쪽에 있으면 안된다. //버퍼는 모니터가 왼쪽에 있으면 안된다.
//충전기1만 전진 도킹을 한다. //충전기1만 전진 도킹을 한다.
@@ -2932,6 +2944,29 @@ namespace AGVSimulator.Forms
_simulatorCanvas.FitToNodes(); _simulatorCanvas.FitToNodes();
} }
private void btSelectMapEditor_Click(object sender, EventArgs e)
{
using (var openDialog = new OpenFileDialog())
{
openDialog.Filter = "실행 파일 (*.exe)|*.exe|모든 파일 (*.*)|*.*";
openDialog.Title = "MapEditor 실행 파일 선택";
if (!string.IsNullOrEmpty(_config.MapEditorExecutablePath) && File.Exists(_config.MapEditorExecutablePath))
{
openDialog.InitialDirectory = Path.GetDirectoryName(_config.MapEditorExecutablePath);
openDialog.FileName = Path.GetFileName(_config.MapEditorExecutablePath);
}
if (openDialog.ShowDialog() == DialogResult.OK)
{
_config.MapEditorExecutablePath = openDialog.FileName;
_config.Save();
_statusLabel.Text = $"MapEditor 경로 설정: {Path.GetFileName(openDialog.FileName)}";
MessageBox.Show($"MapEditor 실행 파일이 설정되었습니다:\n{openDialog.FileName}",
"경로 설정 완료", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
} }
} }

View File

@@ -112,22 +112,8 @@ public static partial class EEMStatus
var mcid = Project.PUB.setting.MCID; var mcid = Project.PUB.setting.MCID;
var timestr = PUB.BMS.Current_DataTime.ToString("yyyy-MM-dd HH:mm:ss"); var timestr = PUB.BMS.Current_DataTime.ToString("yyyy-MM-dd HH:mm:ss");
// BMS 데이터 (실제 값으로 교체 필요) var data = PUB.BMS.BMSInformation;
var info_volt = PUB.BMS.Current_Volt;// "null"; // bms.Voltage
var info_current = PUB.BMS.Current_Amp;// "null"; // bms.Current
var info_capa = PUB.BMS.Current_MaxAmp;// "null"; // bms.Capacity
var info_level = PUB.BMS.Current_Level;// "null"; // bms.Level
var info_temp1 = PUB.BMS.Current_temp1;// "null"; // bms.Temp1
var info_temp2 = PUB.BMS.Current_temp2;// "null"; // bms.Temp2
var cell_volt1 = PUB.BMS.CellVoltage[0];// "null"; // bms.CellVolt1
var cell_volt2 = PUB.BMS.CellVoltage[1]; // bms.CellVolt2
var cell_volt3 = PUB.BMS.CellVoltage[2]; // bms.CellVolt3
var cell_volt4 = PUB.BMS.CellVoltage[3]; // bms.CellVolt4
var cell_volt5 = PUB.BMS.CellVoltage[4]; // bms.CellVolt5
var cell_volt6 = PUB.BMS.CellVoltage[5]; // bms.CellVolt6
var cell_volt7 = PUB.BMS.CellVoltage[6]; // bms.CellVolt7
var cell_volt8 = PUB.BMS.CellVoltage[7]; // bms.CellVolt8
// Status 폴더에 SQL 파일 생성 // Status 폴더에 SQL 파일 생성
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Status"); var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Status");
if (System.IO.Directory.Exists(path) == false) if (System.IO.Directory.Exists(path) == false)
@@ -135,10 +121,8 @@ public static partial class EEMStatus
var file = System.IO.Path.Combine(path, $"{DateTime.Now.ToString("HHmmssfff")}_BMS_INF.sql"); var file = System.IO.Path.Combine(path, $"{DateTime.Now.ToString("HHmmssfff")}_BMS_INF.sql");
var sql = "insert into AGV_Shuttle_BMS(MCID,wdate,info_volt,info_current,info_capa,info_level,info_temp1,info_temp2) " + var sql = "insert into AGV_Shuttle_BMS(MCID,wdate,info_volt,info_current,info_capa,info_level,info_temp1,info_temp2,soc,cycle,protection,balance) " +
"values('{0}','{1}',{2},{3},{4},{5},{6},{7})"; $"values('{mcid}','{timestr}',{data.packVoltage},{data.current},{data.fullCapacity},{data.RawLevel},{data.ntcTemp[0]},{data.ntcTemp[1]},{data.rsoc},{data.cycleCount},{data.raw_protection},{data.fullBalance})";
sql = string.Format(sql, mcid, timestr, info_volt, info_current, info_capa, info_level, info_temp1, info_temp2);
System.IO.File.WriteAllText(file, sql, System.Text.Encoding.Default); System.IO.File.WriteAllText(file, sql, System.Text.Encoding.Default);
LastBMSIFTime = DateTime.Now; LastBMSIFTime = DateTime.Now;
@@ -167,20 +151,15 @@ public static partial class EEMStatus
var timestr = PUB.BMS.Current_CellTime.ToString("yyyy-MM-dd HH:mm:ss"); var timestr = PUB.BMS.Current_CellTime.ToString("yyyy-MM-dd HH:mm:ss");
// BMS 데이터 (실제 값으로 교체 필요) // BMS 데이터 (실제 값으로 교체 필요)
var info_volt = PUB.BMS.Current_Volt;// "null"; // bms.Voltage var volt = PUB.BMS.BMSCellVoltage;
var info_current = PUB.BMS.Current_Amp;// "null"; // bms.Current var cell_volt1 = volt.Voltage[0];// "null"; // bms.CellVolt1
var info_capa = PUB.BMS.Current_MaxAmp;// "null"; // bms.Capacity var cell_volt2 = volt.Voltage[1]; // bms.CellVolt2
var info_level = PUB.BMS.Current_Level;// "null"; // bms.Level var cell_volt3 = volt.Voltage[2]; // bms.CellVolt3
var info_temp1 = PUB.BMS.Current_temp1;// "null"; // bms.Temp1 var cell_volt4 = volt.Voltage[3]; // bms.CellVolt4
var info_temp2 = PUB.BMS.Current_temp2;// "null"; // bms.Temp2 var cell_volt5 = volt.Voltage[4]; // bms.CellVolt5
var cell_volt1 = PUB.BMS.CellVoltage[0];// "null"; // bms.CellVolt1 var cell_volt6 = volt.Voltage[5]; // bms.CellVolt6
var cell_volt2 = PUB.BMS.CellVoltage[1]; // bms.CellVolt2 var cell_volt7 = volt.Voltage[6]; // bms.CellVolt7
var cell_volt3 = PUB.BMS.CellVoltage[2]; // bms.CellVolt3 var cell_volt8 = volt.Voltage[7]; // bms.CellVolt8
var cell_volt4 = PUB.BMS.CellVoltage[3]; // bms.CellVolt4
var cell_volt5 = PUB.BMS.CellVoltage[4]; // bms.CellVolt5
var cell_volt6 = PUB.BMS.CellVoltage[5]; // bms.CellVolt6
var cell_volt7 = PUB.BMS.CellVoltage[6]; // bms.CellVolt7
var cell_volt8 = PUB.BMS.CellVoltage[7]; // bms.CellVolt8
// Status 폴더에 SQL 파일 생성 // Status 폴더에 SQL 파일 생성
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Status"); var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Status");

View File

@@ -273,8 +273,8 @@ namespace Project
else else
{ {
//단순 수치값을 크게 표시히낟. //단순 수치값을 크게 표시히낟.
var Volt = dev_bms?.Current_Volt ?? 25.35f; var Volt = dev_bms?.BMSInformation.packVoltage ?? 25.35f;
var Lev = dev_bms?.Current_Level ?? 80.1f; var Lev = dev_bms?.BMSInformation.rsoc ?? 80f;
var textColor = Color.Lime; var textColor = Color.Lime;
if (Lev < 30) textColor = Color.Red; if (Lev < 30) textColor = Color.Red;
@@ -439,7 +439,7 @@ namespace Project
var bmslevel = 28f; var bmslevel = 28f;
if (dev_bms != null) bmslevel = dev_bms.Current_Level; if (dev_bms != null) bmslevel = dev_bms.BMSInformation.rsoc;
var CornerRadius = 10; var CornerRadius = 10;
var XPosition = rectR.Left + (rectR.Width - batw) / 2f; var XPosition = rectR.Left + (rectR.Width - batw) / 2f;
var YPosition = rectR.Top + (rectR.Height - bath) / 2f + (rectR.Height * 0.05f); var YPosition = rectR.Top + (rectR.Height - bath) / 2f + (rectR.Height * 0.05f);

View File

@@ -9,12 +9,152 @@ using System.CodeDom;
namespace arDev namespace arDev
{ {
public class BMSCellInformation
{
public float[] Voltage = new float[8];
public float Average
{
get
{
if (Voltage.Any() == false) return 0f;
return Voltage.Average();
}
}
public float Delta
{
get
{
if (Voltage.Any() == false) return 0f;
return Math.Abs(Voltage.Max() - Voltage.Min());
}
}
}
public class BMSBasicInformation
{
public float packVoltage { get; set; }
public float current { get; set; }
public float remainingCapacity { get; set; }
public float fullCapacity { get; set; }
public UInt16 cycleCount { get; set; }
public DateTime productionDate { get; set; }
public UInt32 fullBalance { get; set; }
public BMSProtectionStatus protectionStatus { get; set; }
public byte version { get; set; }
public byte rsoc { get; set; }
public BMSMosfetStatus mosfetStatus { get; set; }
public byte ntcCount { get; set; }
public float[] ntcTemp { get; set; }
public ushort raw_protection { get; set; }
public float watt
{
get
{
return (this.current * packVoltage);
}
}
/// <summary>
/// Remain / Full * 100
/// </summary>
public float RawLevel
{
get
{
if (fullCapacity < 1) return 0f;
return (remainingCapacity / fullCapacity) * 100f;
}
}
public BMSBasicInformation()
{
protectionStatus = new BMSProtectionStatus();
mosfetStatus = new BMSMosfetStatus();
productionDate = new DateTime();
ntcTemp = new float[] { 0f,0f};
}
public void Clear()
{
packVoltage = 0;
current = 0;
remainingCapacity = 0;
fullBalance = 0;
fullCapacity = 0;
cycleCount = 0;
productionDate = new DateTime();
protectionStatus = new BMSProtectionStatus();
}
public override string ToString()
{
return $"packVoltage:{packVoltage}\n" +
$"current:{current}\n" +
$"remainingCapacity:{remainingCapacity}\n" +
$"fullCapacity:{fullCapacity}\n" +
$"cycleCount:{cycleCount}\n" +
$"productionDate:{productionDate}\n" +
$"fullBalance:{fullBalance}\n" +
$"protectionStatus:{protectionStatus}\n" +
$"version:{version}\n" +
$"rsoc:{rsoc}\n" +
$"mosfetStatus:{mosfetStatus}\n" +
$"ntcCount:{ntcCount}\n" +
$"ntcTemp:{ntcTemp}\n" +
$"watt:{watt}\n" +
$"RawLevel:{RawLevel}";
}
}
public class BMSProtectionStatus
{
public bool covp { get; set; }// Cell Over Voltage Protection
public bool cuvp { get; set; } // Cell Under Voltage Protection
public bool povp { get; set; } // Pack Over Voltage Protection
public bool puvp { get; set; } // Pack Under Voltage Protection
public bool chgot { get; set; }// Charge Over Temp
public bool chgut { get; set; } // Charge Under Temp
public bool dsgot { get; set; } // Discharge Over Temp
public bool dsgut { get; set; } // Discharge Under Temp
public bool chgoc { get; set; } // Charge Over Current
public bool dsgoc { get; set; } // Discharge Over Current
public bool sc { get; set; } // Short Circuit
public bool afe { get; set; } // AFE Error
public override string ToString()
{
return "BMSProtectionStatus\n" +
$"covp={covp}\n" +// { get; set; }// Cell Over Voltage Protection
$"cuvp={cuvp}\n" +// { get; set; } // Cell Under Voltage Protection
$"povp={povp}\n" +// { get; set; } // Pack Over Voltage Protection
$"puvp={puvp}\n" +// { get; set; } // Pack Under Voltage Protection
$"chgot={chgot}\n" +// { get; set; }// Charge Over Temp
$"chgut={chgut}\n" +// { get; set; } // Charge Under Temp
$"dsgot={dsgot}\n" +// { get; set; } // Discharge Over Temp
$"dsgut={dsgut}\n" +// { get; set; } // Discharge Under Temp
$"chgoc={chgoc}\n" +// { get; set; } // Charge Over Current
$"dsgoc={dsgoc}\n" +// { get; set; } // Discharge Over Current
$"sc={sc}\n" +// { get; set; } // Short Circuit
$"afe={afe}";// +// { get; set; } // AFE Error
}
}
public class BMSMosfetStatus
{
public bool charge { get; set; }
public bool discharge { get; set; }
public override string ToString()
{
return $"charge:{charge}\n" +
$"discharge:{discharge}";
}
}
public class BMS : BMSSerialComm public class BMS : BMSSerialComm
{ {
public BMS() public BMS()
{ {
} }
/// <summary> /// <summary>
@@ -77,14 +217,14 @@ namespace arDev
} }
} }
// [22 - 12 - 27 14:32:49] open: True // [22 - 12 - 27 14:32:49] open: True
//[22 - 12 - 27 14:32:49] Send: DD A5 03 00 FF FD 77 0D //[22 - 12 - 27 14:32:49] Send: DD A5 03 00 FF FD 77 0D
//[22 - 12 - 27 14:32:50] Send: DD A5 03 00 FF FD 77 0D //[22 - 12 - 27 14:32:50] Send: DD A5 03 00 FF FD 77 0D
//[22 - 12 - 27 14:32:50] Recv: 26.61v,81.4 % //[22 - 12 - 27 14:32:50] Recv: 26.61v,81.4 %
//[22 - 12 - 27 14:32:50] Recv: DD 03 00 1B 0A 65 00 00 21 63 29 04 00 00 2C 92 00 00 00 00 00 00 28 51 03 08 02 0B 69 0B 66 FC 9C 77 //[22 - 12 - 27 14:32:50] Recv: DD 03 00 1B 0A 65 00 00 21 63 29 04 00 00 2C 92 00 00 00 00 00 00 28 51 03 08 02 0B 69 0B 66 FC 9C 77
//[22 - 12 - 27 14:32:50] Send: DD A5 03 00 FF FD 77 0D //[22 - 12 - 27 14:32:50] Send: DD A5 03 00 FF FD 77 0D
//[22 - 12 - 27 14:32:51] Recv: 26.61v,81.4 % //[22 - 12 - 27 14:32:51] Recv: 26.61v,81.4 %
//[22 - 12 - 27 14:32:51] Recv: DD 03 00 1B 0A 65 00 00 21 63 29 04 00 00 2C 92 00 00 00 00 00 00 28 51 03 08 02 0B 69 0B 66 FC 9C 77 //[22 - 12 - 27 14:32:51] Recv: DD 03 00 1B 0A 65 00 00 21 63 29 04 00 00 2C 92 00 00 00 00 00 00 28 51 03 08 02 0B 69 0B 66 FC 9C 77
//var queylen = QueryIndex == 0 ? 34 : 23; //var queylen = QueryIndex == 0 ? 34 : 23;
@@ -165,24 +305,24 @@ namespace arDev
var recvchecksum = BitConverter.ToUInt16(LastReceiveBuffer.Skip(20).Take(2).Reverse().ToArray(), 0); var recvchecksum = BitConverter.ToUInt16(LastReceiveBuffer.Skip(20).Take(2).Reverse().ToArray(), 0);
if (recvchecksum == BatteryCell_Checksum) if (recvchecksum == BatteryCell_Checksum)
{ {
var v1 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(4).Take(2).Reverse().ToArray(), 0) / 1000.0; var v1 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(4).Take(2).Reverse().ToArray(), 0) / 1000f;
var v2 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(6).Take(2).Reverse().ToArray(), 0) / 1000.0; var v2 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(6).Take(2).Reverse().ToArray(), 0) / 1000f;
var v3 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(8).Take(2).Reverse().ToArray(), 0) / 1000.0; var v3 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(8).Take(2).Reverse().ToArray(), 0) / 1000f;
var v4 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(10).Take(2).Reverse().ToArray(), 0) / 1000.0; var v4 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(10).Take(2).Reverse().ToArray(), 0) / 1000f;
var v5 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(12).Take(2).Reverse().ToArray(), 0) / 1000.0; var v5 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(12).Take(2).Reverse().ToArray(), 0) / 1000f;
var v6 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(14).Take(2).Reverse().ToArray(), 0) / 1000.0; var v6 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(14).Take(2).Reverse().ToArray(), 0) / 1000f;
var v7 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(16).Take(2).Reverse().ToArray(), 0) / 1000.0; var v7 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(16).Take(2).Reverse().ToArray(), 0) / 1000f;
var v8 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(18).Take(2).Reverse().ToArray(), 0) / 1000.0; var v8 = BitConverter.ToUInt16(LastReceiveBuffer.Skip(18).Take(2).Reverse().ToArray(), 0) / 1000f;
var idx = 0; var idx = 0;
CellVoltage[idx++] = v1; BMSCellVoltage.Voltage[idx++] = v1;
CellVoltage[idx++] = v2; BMSCellVoltage.Voltage[idx++] = v2;
CellVoltage[idx++] = v3; BMSCellVoltage.Voltage[idx++] = v3;
CellVoltage[idx++] = v4; BMSCellVoltage.Voltage[idx++] = v4;
CellVoltage[idx++] = v5; BMSCellVoltage.Voltage[idx++] = v5;
CellVoltage[idx++] = v6; BMSCellVoltage.Voltage[idx++] = v6;
CellVoltage[idx++] = v7; BMSCellVoltage.Voltage[idx++] = v7;
CellVoltage[idx++] = v8; BMSCellVoltage.Voltage[idx++] = v8;
Recv1 = true; Recv1 = true;
@@ -199,61 +339,116 @@ namespace arDev
} }
} }
else return false; else return false;
} }
bool ParseBMSInfo() bool ParseBMSInfo()
{ {
var newinfo = new BMSBasicInformation();
//전압확인 //전압확인
UInt16 batH = (UInt16)LastReceiveBuffer[4]; var offset = 4;
UInt16 batL = (UInt16)LastReceiveBuffer[5]; UInt16 batH = (UInt16)LastReceiveBuffer[offset + 0];
UInt16 batL = (UInt16)LastReceiveBuffer[offset + 1];
batH = (UInt16)(batH << 8); batH = (UInt16)(batH << 8);
batH = (UInt16)(batH | batL); batH = (UInt16)(batH | batL);
Current_Volt = (float)(batH / 100.0); newinfo.packVoltage = (float)(batH / 100.0);
//충방전전류 //충방전전류
Int16 batHi = (Int16)LastReceiveBuffer[6]; Int16 batHi = (Int16)LastReceiveBuffer[offset + 2];
Int16 batLi = (Int16)LastReceiveBuffer[7]; Int16 batLi = (Int16)LastReceiveBuffer[offset + 3];
batHi = (Int16)(batHi << 8); batHi = (Int16)(batHi << 8);
batHi = (Int16)(batHi | batLi); batHi = (Int16)(batHi | batLi);
Charge_Amp = (float)(batHi / 100.0); newinfo.current = (float)(batHi / 100.0);
//잔량확인 //잔량확인
batH = (UInt16)LastReceiveBuffer[8]; batH = (UInt16)LastReceiveBuffer[offset + 4];
batL = (UInt16)LastReceiveBuffer[9]; batL = (UInt16)LastReceiveBuffer[offset + 5];
batH = (UInt16)(batH << 8); batH = (UInt16)(batH << 8);
batH = (UInt16)(batH | batL); batH = (UInt16)(batH | batL);
var newamp = (int)batH; newinfo.remainingCapacity = (float)(batH / 100.0);
var Changed = newamp != Current_Amp;
Current_Amp = newamp;
//총량확인 //총량확인
batH = (UInt16)LastReceiveBuffer[10]; batH = (UInt16)LastReceiveBuffer[offset + 6];
batL = (UInt16)LastReceiveBuffer[11]; batL = (UInt16)LastReceiveBuffer[offset + 7];
batH = (UInt16)(batH << 8); batH = (UInt16)(batH << 8);
batH = (UInt16)(batH | batL); batH = (UInt16)(batH | batL);
Current_MaxAmp = (int)batH; newinfo.fullCapacity = (float)(batH / 100.0);
//남은 % 계산 //cycle
float levraw = (float)(Current_Amp / (Current_MaxAmp * 1.0)); batH = (UInt16)LastReceiveBuffer[offset + 8];
Current_Level = (float)(levraw * 100.0);// (float)(map(remain, 0, total, 0, 100)); batL = (UInt16)LastReceiveBuffer[offset + 9];
Current_LevelA = LastReceiveBuffer[23]; //<- 23번자료는 byte이므로 소수점이잇는 데이터로 직접 계산한다 batH = (UInt16)(batH << 8);
batH = (UInt16)(batH | batL);
newinfo.cycleCount = batH;
//productiondate
batH = (UInt16)LastReceiveBuffer[offset + 10];
batL = (UInt16)LastReceiveBuffer[offset + 11];
batH = (UInt16)(batH << 8);
batH = (UInt16)(batH | batL);
var info_productiondateint = batH;
var date_year = (info_productiondateint >> 9) + 2000;
var date_month = (info_productiondateint >> 5) & 0x0F;
var date_day = info_productiondateint & 0x1F;
newinfo.productionDate = new DateTime(date_year, date_month, date_day);
//balnace status
batH = (UInt16)LastReceiveBuffer[offset + 12];
batL = (UInt16)LastReceiveBuffer[offset + 13];
batH = (UInt16)(batH << 8);
var balanceStatus = (UInt16)(batH | batL);
//balnace status(HIGH)
batH = (UInt16)LastReceiveBuffer[offset + 14];
batL = (UInt16)LastReceiveBuffer[offset + 15];
batH = (UInt16)(batH << 8);
var balanceStatusHigh = (UInt16)(batH | batL);
newinfo.fullBalance = (UInt32)(balanceStatus | (balanceStatusHigh << 16));
//protectionStatusRaw
batH = (UInt16)LastReceiveBuffer[offset + 16];
batL = (UInt16)LastReceiveBuffer[offset + 17];
batH = (UInt16)(batH << 8);
newinfo.raw_protection = batH;// view.getUint16(16, false);
var protectionStatusRaw = newinfo.raw_protection;
newinfo.protectionStatus.covp = (protectionStatusRaw & 1) > 0;
newinfo.protectionStatus.cuvp = ((protectionStatusRaw >> 1) & 1) > 0;
newinfo.protectionStatus.povp = ((protectionStatusRaw >> 2) & 1) > 0;
newinfo.protectionStatus.puvp = ((protectionStatusRaw >> 3) & 1) > 0;
newinfo.protectionStatus.chgot = ((protectionStatusRaw >> 4) & 1) > 0;
newinfo.protectionStatus.chgut = ((protectionStatusRaw >> 5) & 1) > 0;
newinfo.protectionStatus.dsgot = ((protectionStatusRaw >> 6) & 1) > 0;
newinfo.protectionStatus.dsgut = ((protectionStatusRaw >> 7) & 1) > 0;
newinfo.protectionStatus.chgoc = ((protectionStatusRaw >> 8) & 1) > 0;
newinfo.protectionStatus.dsgoc = ((protectionStatusRaw >> 9) & 1) > 0;
newinfo.protectionStatus.sc = ((protectionStatusRaw >> 10) & 1) > 0;
newinfo.protectionStatus.afe = ((protectionStatusRaw >> 11) & 1) > 0;
//version
newinfo.version = LastReceiveBuffer[offset + 18];
newinfo.rsoc = LastReceiveBuffer[offset + 19];
var mosfetRaw = LastReceiveBuffer[offset + 20];
newinfo.mosfetStatus.charge = (mosfetRaw & 1) == 1;
newinfo.mosfetStatus.discharge = ((mosfetRaw >> 1) & 1) == 1;
//250620 jwlee 추가 //250620 jwlee 추가
int temp1 = (LastReceiveBuffer[27] << 8) | LastReceiveBuffer[28]; newinfo.ntcCount = LastReceiveBuffer[offset + 22]; //센서갯수
int temp2 = (LastReceiveBuffer[29] << 8) | LastReceiveBuffer[30]; int temp1 = (LastReceiveBuffer[offset + 23] << 8) | LastReceiveBuffer[24];
int temp2 = (LastReceiveBuffer[offset + 25] << 8) | LastReceiveBuffer[36];
var Current_temp1 = (temp1 - 2731) / 10f;
var Current_temp2 = (temp2 - 2731) / 10f;
newinfo.ntcTemp = new float[] { (temp1 - 2731) / 10f, (temp2 - 2731) / 10f };
Current_temp1 = (temp1 - 2731) / 10f; CheckManualCharge(newinfo);
Current_temp2 = (temp2 - 2731) / 10f;
CheckManualCharge();
Recv0 = true; Recv0 = true;
try try
{ {
BMSDataReceive?.Invoke(this, new BMSInformationEventArgs(Current_Volt, Current_Amp, Current_MaxAmp, Current_Level, Changed)); this.BMSInformation = newinfo;
BMSDataReceive?.Invoke(this, new BMSInformationEventArgs(BMSInformation));
Current_DataTime = DateTime.Now; Current_DataTime = DateTime.Now;
return true; return true;
} }
@@ -263,16 +458,21 @@ namespace arDev
return false; return false;
} }
} }
public BMSBasicInformation BMSInformation = new BMSBasicInformation();
public BMSCellInformation BMSCellVoltage = new BMSCellInformation();
/// <summary> /// <summary>
/// 현재 충전중인지? /// 현재 충전중인지?
/// </summary> /// </summary>
public bool IsCharging { get; private set; } public bool IsCharging { get; private set; }
DateTime ChargeStart = DateTime.Now; DateTime ChargeStart = DateTime.Now;
DateTime ChargeEnd = DateTime.Now; DateTime ChargeEnd = DateTime.Now;
void CheckManualCharge() void CheckManualCharge(BMSBasicInformation info)
{ {
//충방전전력이 1보다 크면 충전으로 한다. //충방전전력이 1보다 크면 충전으로 한다.
if (Charge_Amp > 0.1) if (this.BMSInformation.current > 0.1)
{ {
//기존에 충전상태가 OFF였다면 충전중으로 알려준다 //기존에 충전상태가 OFF였다면 충전중으로 알려준다
if (IsCharging == false) if (IsCharging == false)
@@ -282,7 +482,7 @@ namespace arDev
ChargeEnd = new DateTime(1982, 11, 23); ChargeEnd = new DateTime(1982, 11, 23);
try try
{ {
ChargeDetect?.Invoke(this, new ChargetDetectArgs(ChargeStart, true, Current_Level)); ChargeDetect?.Invoke(this, new ChargetDetectArgs(ChargeStart, true, info.RawLevel));
} }
catch (Exception ex) { RaiseMessage(MessageType.Error, ex.Message); } catch (Exception ex) { RaiseMessage(MessageType.Error, ex.Message); }
} }
@@ -309,7 +509,7 @@ namespace arDev
IsCharging = false; IsCharging = false;
try try
{ {
ChargeDetect?.Invoke(this, new ChargetDetectArgs(ChargeEnd, false, Current_Level)); ChargeDetect?.Invoke(this, new ChargetDetectArgs(ChargeEnd, false, info.RawLevel));
} }
catch (Exception ex) { RaiseMessage(MessageType.Error, ex.Message); } catch (Exception ex) { RaiseMessage(MessageType.Error, ex.Message); }
} }
@@ -328,47 +528,6 @@ namespace arDev
public DateTime chk_timee { get; set; } = new DateTime(1982, 11, 23); public DateTime chk_timee { get; set; } = new DateTime(1982, 11, 23);
public float chk_values { get; set; } = 0f; public float chk_values { get; set; } = 0f;
public float chk_valuee { get; set; } = 0f; public float chk_valuee { get; set; } = 0f;
public float Charge_Amp { get; set; } = 0f;
public Int16 Charge_watt
{
get
{
return (Int16)((Charge_Amp) * Current_Volt);
}
}
/// <summary>
/// 전압
/// </summary>
public float Current_Volt { get; set; }
/// <summary>
/// 남은 잔량(%)
/// </summary>
public float Current_Level { get; set; }
public double[] CellVoltage = new double[] { 0, 0, 0, 0, 0, 0, 0, 0 };
public float Current_LevelA { get; set; }
/// <summary>
/// 남은 전류량
/// </summary>
public int Current_Amp { get; set; }
/// <summary>
/// BMS 온도값1
/// </summary>
public double Current_temp1 { get; set; }
/// <summary>
/// BMS 온도값2
/// </summary>
public double Current_temp2 { get; set; }
/// <summary>
/// 총 전류량
/// </summary>
public int Current_MaxAmp { get; set; }
public DateTime Current_DataTime = DateTime.Parse("1982-11-23"); public DateTime Current_DataTime = DateTime.Parse("1982-11-23");
public DateTime Current_CellTime = DateTime.Parse("1982-11-23"); public DateTime Current_CellTime = DateTime.Parse("1982-11-23");

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
namespace arDev namespace arDev
{ {
@@ -16,18 +17,10 @@ namespace arDev
} }
public class BMSInformationEventArgs : EventArgs public class BMSInformationEventArgs : EventArgs
{ {
public float Volt { get; set; } public BMSBasicInformation Data { get; set; }
public int CurAmp { get; set; } public BMSInformationEventArgs(BMSBasicInformation info)
public int MaxAmp { get; set; }
public float Level { get; set; }
public bool Changed { get; set; }
public BMSInformationEventArgs(float _volt, int _curamp, int _maxamp, float _level, bool _changed)
{ {
this.Volt = _volt; this.Data = info;
this.CurAmp = _curamp;
this.MaxAmp = _maxamp;
this.Level = _level;
this.Changed = _changed;
} }
} }
@@ -38,5 +31,9 @@ namespace arDev
{ {
voltage = new double[] { v1, v2, v3, v4, v5, v6, v7, v8 }; voltage = new double[] { v1, v2, v3, v4, v5, v6, v7, v8 };
} }
public override string ToString()
{
return string.Join(" ", voltage.Select(t => t.ToString()));
}
} }
} }

View File

@@ -142,7 +142,7 @@ namespace Project
//콜가능여부도 전송한다 //콜가능여부도 전송한다
if (VAR.BOOL[eVarBool.FLAG_AUTORUN] && if (VAR.BOOL[eVarBool.FLAG_AUTORUN] &&
VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false && VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false &&
PUB.BMS.Current_Level > PUB.setting.ChargeEmergencyLevel && PUB.BMS.BMSInformation.rsoc > PUB.setting.ChargeEmergencyLevel &&
PUB.sm.RunStep != StateMachine.ERunStep.BUFFER_OUT && PUB.sm.RunStep != StateMachine.ERunStep.BUFFER_OUT &&
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == false && VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == false &&
VAR.BOOL[eVarBool.WAIT_COVER_UP] == false) VAR.BOOL[eVarBool.WAIT_COVER_UP] == false)

View File

@@ -29,7 +29,7 @@ namespace Project
//충전중이라면 최대 충전 시간을 체크한다. //충전중이라면 최대 충전 시간을 체크한다.
var tsChargeRunTime = VAR.TIME.RUN(eVarTime.ChargeStart); var tsChargeRunTime = VAR.TIME.RUN(eVarTime.ChargeStart);
if (PUB.BMS.Current_Level >= PUB.setting.ChargeMaxLevel) if (PUB.BMS.BMSInformation.rsoc >= PUB.setting.ChargeMaxLevel)
{ {
PUB.AGV.AGVCharge(PUB.setting.ChargerID, false); PUB.AGV.AGVCharge(PUB.setting.ChargerID, false);
PUB.sm.ClearRunStep(); PUB.sm.ClearRunStep();

View File

@@ -170,18 +170,13 @@ namespace Project
} }
private void Bms_BMSDataReceive(object sender, EventArgs e) private void Bms_BMSDataReceive(object sender, arDev.BMSInformationEventArgs e)
{ {
VAR.TIME[eVarTime.LastRecv_BAT] = DateTime.Now; VAR.TIME[eVarTime.LastRecv_BAT] = DateTime.Now;
//PUB.mapctl.Manager.agv.BatteryLevel = PUB.BMS.Current_Level;
//PUB.mapctl.Manager.agv.BatteryTemp1 = PUB.BMS.Current_temp1;
//PUB.mapctl.Manager.agv.BatteryTemp2 = PUB.BMS.Current_temp2;
// [Sync] Update VirtualAGV Battery PUB.UpdateAGVBattery(e.Data.rsoc);
PUB.UpdateAGVBattery(PUB.BMS.Current_Level);
if (PUB.BMS.Current_Level <= PUB.setting.ChargeStartLevel) if (e.Data.rsoc <= PUB.setting.ChargeStartLevel)
{ {
//배터리 레벨이 기준보다 낮다면 경고를 활성화 한다 //배터리 레벨이 기준보다 낮다면 경고를 활성화 한다
if (VAR.BOOL[eVarBool.BATTERY_LOW] == false) if (VAR.BOOL[eVarBool.BATTERY_LOW] == false)

View File

@@ -59,10 +59,11 @@ namespace Project
panTopMenu.Enabled == false) panTopMenu.Enabled = true; panTopMenu.Enabled == false) panTopMenu.Enabled = true;
//배터리정보표시 //배터리정보표시
lbBat.VLevel = PUB.BMS.Current_Level; var bmsinfo = PUB.BMS.BMSInformation;
lbBat.Volt = PUB.BMS.Current_Volt; lbBat.VLevel = bmsinfo.rsoc;
lbBat.MaxA = PUB.BMS.Current_MaxAmp; lbBat.Volt = bmsinfo.packVoltage;
lbBat.CurA = PUB.BMS.Current_Amp; lbBat.MaxA = bmsinfo.fullCapacity;
lbBat.CurA = bmsinfo.remainingCapacity;
lbBat.IsOpen = PUB.BMS.IsOpen; lbBat.IsOpen = PUB.BMS.IsOpen;
//쓰레드로인해서 메인에서 진행하게한다. SPS는 메인쓰레드에서 진행 됨 //쓰레드로인해서 메인에서 진행하게한다. SPS는 메인쓰레드에서 진행 됨
@@ -174,8 +175,8 @@ namespace Project
var tsIdle = VAR.TIME.RUN(eVarTime.ChargeStart); var tsIdle = VAR.TIME.RUN(eVarTime.ChargeStart);
lbIDLE.ProgressMax = 100;// PUB.setting.ChargeMaxLevel; lbIDLE.ProgressMax = 100;// PUB.setting.ChargeMaxLevel;
lbIDLE.ProgressMin = 0; lbIDLE.ProgressMin = 0;
lbIDLE.Text = $"{PUB.BMS.Current_Level:N0}%"; lbIDLE.Text = $"{PUB.BMS.BMSInformation.rsoc}%";
lbIDLE.ProgressValue = (float)PUB.BMS.Current_Level; lbIDLE.ProgressValue = (float)PUB.BMS.BMSInformation.rsoc;
} }
else else
{ {
@@ -184,8 +185,8 @@ namespace Project
var tsIdle = VAR.TIME.RUN(eVarTime.ChargeStart); var tsIdle = VAR.TIME.RUN(eVarTime.ChargeStart);
lbIDLE.ProgressMax = PUB.setting.ChargeMaxLevel; lbIDLE.ProgressMax = PUB.setting.ChargeMaxLevel;
lbIDLE.ProgressMin = 0; lbIDLE.ProgressMin = 0;
lbIDLE.Text = $"({PUB.BMS.Current_Level:N0}/{PUB.setting.ChargeMaxLevel})%"; lbIDLE.Text = $"({PUB.BMS.BMSInformation.rsoc}/{PUB.setting.ChargeMaxLevel})%";
lbIDLE.ProgressValue = (float)PUB.BMS.Current_Level; lbIDLE.ProgressValue = (float)PUB.BMS.BMSInformation.rsoc;
//} //}
//else //else
//{ //{
@@ -380,7 +381,7 @@ namespace Project
/// </summary> /// </summary>
void Update_BatteryWarnSpeak() void Update_BatteryWarnSpeak()
{ {
if (PUB.BMS == null || PUB.BMS.Current_Level > 40) return; if (PUB.BMS == null || PUB.BMS.BMSInformation.rsoc > 40) return;
//가동중이거나 수동모드에서는 메세지 알림한다 //가동중이거나 수동모드에서는 메세지 알림한다
if (PUB.AGV.system1.agv_run || VAR.BOOL[eVarBool.FLAG_AUTORUN] == false) if (PUB.AGV.system1.agv_run || VAR.BOOL[eVarBool.FLAG_AUTORUN] == false)
@@ -605,7 +606,7 @@ namespace Project
{ {
//남은 충전시간 계산 //남은 충전시간 계산
string msg = string.Empty; string msg = string.Empty;
if (PUB.BMS.Current_Level < PUB.setting.ChargeEmergencyLevel) if (PUB.BMS.BMSInformation.rsoc < PUB.setting.ChargeEmergencyLevel)
{ {
msg = $"충전 진행 중(이동 불가)\n저전압으로 인해 사용이 불가 합니다"; msg = $"충전 진행 중(이동 불가)\n저전압으로 인해 사용이 불가 합니다";
} }

View File

@@ -328,7 +328,7 @@ namespace Project
var prevDir = selectedAGV.PrevDirection; var prevDir = selectedAGV.PrevDirection;
// 고급 경로 계획 사용 (노드 객체 직접 전달) // 고급 경로 계획 사용 (노드 객체 직접 전달)
var advancedResult = _advancedPathfinder.FindPath(startNode, targetNode, prevNode, prevDir, currentDirection); var advancedResult = _advancedPathfinder.FindBasicPath(startNode, targetNode, prevNode, prevDir);
var _simulatorCanvas = PUB._mapCanvas; var _simulatorCanvas = PUB._mapCanvas;

View File

@@ -31,8 +31,15 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lbcvSt = new System.Windows.Forms.Label(); this.lbcvSt = new System.Windows.Forms.Label();
this.panel11 = new System.Windows.Forms.Panel();
this.lbtemp2 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.panel10 = new System.Windows.Forms.Panel();
this.lbTemp1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel9 = new System.Windows.Forms.Panel(); this.panel9 = new System.Windows.Forms.Panel();
this.cv8 = new System.Windows.Forms.Label(); this.cv8 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label();
@@ -61,14 +68,11 @@
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.arLabel1 = new arCtl.arLabel(); this.arLabel1 = new arCtl.arLabel();
this.lbinfost = new System.Windows.Forms.Label(); this.lbinfost = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.lbCycle = new System.Windows.Forms.Label();
this.panel10 = new System.Windows.Forms.Panel();
this.lbTemp1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.panel11 = new System.Windows.Forms.Panel();
this.lbtemp2 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.panel11.SuspendLayout();
this.panel10.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.panel9.SuspendLayout(); this.panel9.SuspendLayout();
this.panel8.SuspendLayout(); this.panel8.SuspendLayout();
@@ -78,9 +82,6 @@
this.panel4.SuspendLayout(); this.panel4.SuspendLayout();
this.panel3.SuspendLayout(); this.panel3.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
this.groupBox2.SuspendLayout();
this.panel10.SuspendLayout();
this.panel11.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// timer1 // timer1
@@ -100,6 +101,100 @@
this.panel1.Size = new System.Drawing.Size(187, 577); this.panel1.Size = new System.Drawing.Size(187, 577);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
// //
// groupBox2
//
this.groupBox2.Controls.Add(this.lbcvSt);
this.groupBox2.Controls.Add(this.panel11);
this.groupBox2.Controls.Add(this.panel10);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(0, 465);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(187, 112);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Temp";
//
// lbcvSt
//
this.lbcvSt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbcvSt.AutoSize = true;
this.lbcvSt.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.lbcvSt.ForeColor = System.Drawing.Color.White;
this.lbcvSt.Location = new System.Drawing.Point(148, 82);
this.lbcvSt.Name = "lbcvSt";
this.lbcvSt.Size = new System.Drawing.Size(39, 27);
this.lbcvSt.TabIndex = 8;
this.lbcvSt.Text = "●";
//
// panel11
//
this.panel11.Controls.Add(this.lbtemp2);
this.panel11.Controls.Add(this.label7);
this.panel11.Dock = System.Windows.Forms.DockStyle.Top;
this.panel11.Location = new System.Drawing.Point(3, 57);
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(181, 40);
this.panel11.TabIndex = 10;
//
// lbtemp2
//
this.lbtemp2.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbtemp2.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbtemp2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.lbtemp2.Location = new System.Drawing.Point(47, 0);
this.lbtemp2.Name = "lbtemp2";
this.lbtemp2.Size = new System.Drawing.Size(134, 40);
this.lbtemp2.TabIndex = 0;
this.lbtemp2.Text = "--";
this.lbtemp2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label7
//
this.label7.Dock = System.Windows.Forms.DockStyle.Left;
this.label7.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.label7.Location = new System.Drawing.Point(0, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(47, 40);
this.label7.TabIndex = 0;
this.label7.Text = "#2";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel10
//
this.panel10.Controls.Add(this.lbTemp1);
this.panel10.Controls.Add(this.label3);
this.panel10.Dock = System.Windows.Forms.DockStyle.Top;
this.panel10.Location = new System.Drawing.Point(3, 17);
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(181, 40);
this.panel10.TabIndex = 9;
//
// lbTemp1
//
this.lbTemp1.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbTemp1.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbTemp1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.lbTemp1.Location = new System.Drawing.Point(47, 0);
this.lbTemp1.Name = "lbTemp1";
this.lbTemp1.Size = new System.Drawing.Size(134, 40);
this.lbTemp1.TabIndex = 0;
this.lbTemp1.Text = "--";
this.lbTemp1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Dock = System.Windows.Forms.DockStyle.Left;
this.label3.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.label3.Location = new System.Drawing.Point(0, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(47, 40);
this.label3.TabIndex = 0;
this.label3.Text = "#1";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.panel9); this.groupBox1.Controls.Add(this.panel9);
@@ -119,18 +214,6 @@
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Cell voltage"; this.groupBox1.Text = "Cell voltage";
// //
// lbcvSt
//
this.lbcvSt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbcvSt.AutoSize = true;
this.lbcvSt.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.lbcvSt.ForeColor = System.Drawing.Color.White;
this.lbcvSt.Location = new System.Drawing.Point(148, 82);
this.lbcvSt.Name = "lbcvSt";
this.lbcvSt.Size = new System.Drawing.Size(39, 27);
this.lbcvSt.TabIndex = 8;
this.lbcvSt.Text = "●";
//
// panel9 // panel9
// //
this.panel9.Controls.Add(this.cv8); this.panel9.Controls.Add(this.cv8);
@@ -484,93 +567,24 @@
this.lbinfost.TabIndex = 2; this.lbinfost.TabIndex = 2;
this.lbinfost.Text = "●"; this.lbinfost.Text = "●";
// //
// groupBox2 // lbCycle
// //
this.groupBox2.Controls.Add(this.lbcvSt); this.lbCycle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.panel11); this.lbCycle.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox2.Controls.Add(this.panel10); this.lbCycle.ForeColor = System.Drawing.Color.SkyBlue;
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; this.lbCycle.Location = new System.Drawing.Point(296, 8);
this.groupBox2.ForeColor = System.Drawing.Color.White; this.lbCycle.Name = "lbCycle";
this.groupBox2.Location = new System.Drawing.Point(0, 465); this.lbCycle.Size = new System.Drawing.Size(749, 27);
this.groupBox2.Name = "groupBox2"; this.lbCycle.TabIndex = 3;
this.groupBox2.Size = new System.Drawing.Size(187, 112); this.lbCycle.Text = "Cycle(2)";
this.groupBox2.TabIndex = 3; this.lbCycle.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Temp";
//
// panel10
//
this.panel10.Controls.Add(this.lbTemp1);
this.panel10.Controls.Add(this.label3);
this.panel10.Dock = System.Windows.Forms.DockStyle.Top;
this.panel10.Location = new System.Drawing.Point(3, 17);
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(181, 40);
this.panel10.TabIndex = 9;
//
// label2
//
this.lbTemp1.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbTemp1.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbTemp1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.lbTemp1.Location = new System.Drawing.Point(47, 0);
this.lbTemp1.Name = "label2";
this.lbTemp1.Size = new System.Drawing.Size(134, 40);
this.lbTemp1.TabIndex = 0;
this.lbTemp1.Text = "--";
this.lbTemp1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Dock = System.Windows.Forms.DockStyle.Left;
this.label3.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.label3.Location = new System.Drawing.Point(0, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(47, 40);
this.label3.TabIndex = 0;
this.label3.Text = "#1";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel11
//
this.panel11.Controls.Add(this.lbtemp2);
this.panel11.Controls.Add(this.label7);
this.panel11.Dock = System.Windows.Forms.DockStyle.Top;
this.panel11.Location = new System.Drawing.Point(3, 57);
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(181, 40);
this.panel11.TabIndex = 10;
//
// label5
//
this.lbtemp2.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbtemp2.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbtemp2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.lbtemp2.Location = new System.Drawing.Point(47, 0);
this.lbtemp2.Name = "label5";
this.lbtemp2.Size = new System.Drawing.Size(134, 40);
this.lbtemp2.TabIndex = 0;
this.lbtemp2.Text = "--";
this.lbtemp2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label7
//
this.label7.Dock = System.Windows.Forms.DockStyle.Left;
this.label7.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.label7.Location = new System.Drawing.Point(0, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(47, 40);
this.label7.TabIndex = 0;
this.label7.Text = "#2";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// fBms // fBms
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15))))); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.ClientSize = new System.Drawing.Size(1056, 583); this.ClientSize = new System.Drawing.Size(1056, 583);
this.Controls.Add(this.lbCycle);
this.Controls.Add(this.lbinfost); this.Controls.Add(this.lbinfost);
this.Controls.Add(this.arLabel1); this.Controls.Add(this.arLabel1);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
@@ -581,6 +595,10 @@
this.Load += new System.EventHandler(this.fFlag_Load); this.Load += new System.EventHandler(this.fFlag_Load);
this.VisibleChanged += new System.EventHandler(this.fAgv_VisibleChanged); this.VisibleChanged += new System.EventHandler(this.fAgv_VisibleChanged);
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.panel11.ResumeLayout(false);
this.panel10.ResumeLayout(false);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.panel9.ResumeLayout(false); this.panel9.ResumeLayout(false);
this.panel8.ResumeLayout(false); this.panel8.ResumeLayout(false);
@@ -590,10 +608,6 @@
this.panel4.ResumeLayout(false); this.panel4.ResumeLayout(false);
this.panel3.ResumeLayout(false); this.panel3.ResumeLayout(false);
this.panel2.ResumeLayout(false); this.panel2.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.panel10.ResumeLayout(false);
this.panel11.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -639,5 +653,6 @@
private System.Windows.Forms.Panel panel10; private System.Windows.Forms.Panel panel10;
private System.Windows.Forms.Label lbTemp1; private System.Windows.Forms.Label lbTemp1;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label lbCycle;
} }
} }

View File

@@ -63,18 +63,26 @@ namespace Project.ViewForm
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
timer1.Stop(); timer1.Stop();
this.arLabel1.Text = PUB.BMS.Current_Level.ToString("N1") + "%"; var data = PUB.BMS.BMSInformation;
this.arLabel1.Sign = $"{PUB.BMS.Current_Volt}v, {PUB.BMS.Charge_watt}w";// PUB.BMS.Current_Volt.ToString() + "v"; var volt = PUB.BMS.BMSCellVoltage;
this.cv1.Text = PUB.BMS.CellVoltage[0].ToString("N3") + "v"; if (PUB.BMS.IsOpen == false)
this.cv2.Text = PUB.BMS.CellVoltage[1].ToString("N3") + "v"; this.lbCycle.Text = "통신이 열려있지 않습니다";
this.cv3.Text = PUB.BMS.CellVoltage[2].ToString("N3") + "v"; else if (PUB.BMS.IsValid == false)
this.cv4.Text = PUB.BMS.CellVoltage[3].ToString("N3") + "v"; this.lbCycle.Text = "데이터가 유효하지 않습니다";
this.cv5.Text = PUB.BMS.CellVoltage[4].ToString("N3") + "v"; else
this.cv6.Text = PUB.BMS.CellVoltage[5].ToString("N3") + "v"; this.lbCycle.Text = $"Cell Average:{volt.Average},Delta:{volt.Delta},Cycle({data.cycleCount})";
this.cv7.Text = PUB.BMS.CellVoltage[6].ToString("N3") + "v"; this.arLabel1.Text = $"{data.rsoc}%";
this.cv8.Text = PUB.BMS.CellVoltage[7].ToString("N3") + "v"; this.arLabel1.Sign = $"{data.packVoltage}v, {data.watt}w";// PUB.BMS.Current_Volt.ToString() + "v";
this.lbTemp1.Text = PUB.BMS.Current_temp1.ToString() + ""; this.cv1.Text = volt.Voltage[0].ToString("N3") + "v";
this.lbtemp2.Text = PUB.BMS.Current_temp2.ToString() + ""; this.cv2.Text = volt.Voltage[1].ToString("N3") + "v";
this.cv3.Text = volt.Voltage[2].ToString("N3") + "v";
this.cv4.Text = volt.Voltage[3].ToString("N3") + "v";
this.cv5.Text = volt.Voltage[4].ToString("N3") + "v";
this.cv6.Text = volt.Voltage[5].ToString("N3") + "v";
this.cv7.Text = volt.Voltage[6].ToString("N3") + "v";
this.cv8.Text = volt.Voltage[7].ToString("N3") + "v";
this.lbTemp1.Text = data.ntcTemp[0].ToString() + "℃";
this.lbtemp2.Text = data.ntcTemp[1].ToString() + "℃";
timer1.Start(); timer1.Start();
} }

View File

@@ -756,7 +756,7 @@ namespace Project
private void lbBat_Click(object sender, EventArgs e) private void lbBat_Click(object sender, EventArgs e)
{ {
var bat = (int)PUB.BMS.Current_Level; var bat = (int)PUB.BMS.BMSInformation.rsoc;
var msg = $"{bat}퍼센트"; var msg = $"{bat}퍼센트";
PUB.Speak(msg, false, false); PUB.Speak(msg, false, false);
PUB.counter.CountQA += 1; PUB.counter.CountQA += 1;

View File

@@ -36,8 +36,9 @@
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.logTextBox1 = new arCtl.LogTextBox(); this.logTextBox1 = new arCtl.LogTextBox();
this.button3 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button(); this.btSendCV = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button();
this.logTextBox2 = new arCtl.LogTextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// comboBox1 // comboBox1
@@ -117,7 +118,7 @@
this.logTextBox1.MaxTextLength = ((uint)(4000u)); this.logTextBox1.MaxTextLength = ((uint)(4000u));
this.logTextBox1.MessageInterval = 50; this.logTextBox1.MessageInterval = 50;
this.logTextBox1.Name = "logTextBox1"; this.logTextBox1.Name = "logTextBox1";
this.logTextBox1.Size = new System.Drawing.Size(494, 351); this.logTextBox1.Size = new System.Drawing.Size(368, 395);
this.logTextBox1.TabIndex = 4; this.logTextBox1.TabIndex = 4;
this.logTextBox1.Text = ""; this.logTextBox1.Text = "";
// //
@@ -127,19 +128,19 @@
this.button3.Name = "button3"; this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(140, 20); this.button3.Size = new System.Drawing.Size(140, 20);
this.button3.TabIndex = 5; this.button3.TabIndex = 5;
this.button3.Text = "send query"; this.button3.Text = "read status";
this.button3.UseVisualStyleBackColor = true; this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click); this.button3.Click += new System.EventHandler(this.button3_Click);
// //
// button4 // btSendCV
// //
this.button4.Location = new System.Drawing.Point(447, 60); this.btSendCV.Location = new System.Drawing.Point(447, 60);
this.button4.Name = "button4"; this.btSendCV.Name = "btSendCV";
this.button4.Size = new System.Drawing.Size(140, 20); this.btSendCV.Size = new System.Drawing.Size(140, 20);
this.button4.TabIndex = 6; this.btSendCV.TabIndex = 6;
this.button4.Text = "send query"; this.btSendCV.Text = "read cellvoltage";
this.button4.UseVisualStyleBackColor = true; this.btSendCV.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click); this.btSendCV.Click += new System.EventHandler(this.button4_Click);
// //
// button5 // button5
// //
@@ -151,13 +152,33 @@
this.button5.UseVisualStyleBackColor = true; this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click); this.button5.Click += new System.EventHandler(this.button5_Click);
// //
// logTextBox2
//
this.logTextBox2.BackColor = System.Drawing.Color.WhiteSmoke;
this.logTextBox2.ColorList = new arCtl.sLogMessageColor[0];
this.logTextBox2.DateFormat = "yy-MM-dd HH:mm:ss";
this.logTextBox2.DefaultColor = System.Drawing.Color.LightGray;
this.logTextBox2.EnableDisplayTimer = true;
this.logTextBox2.EnableGubunColor = true;
this.logTextBox2.Font = new System.Drawing.Font("Consolas", 9F);
this.logTextBox2.ListFormat = "[{0}] {1}";
this.logTextBox2.Location = new System.Drawing.Point(401, 87);
this.logTextBox2.MaxListCount = ((ushort)(200));
this.logTextBox2.MaxTextLength = ((uint)(4000u));
this.logTextBox2.MessageInterval = 50;
this.logTextBox2.Name = "logTextBox2";
this.logTextBox2.Size = new System.Drawing.Size(368, 395);
this.logTextBox2.TabIndex = 8;
this.logTextBox2.Text = "";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(574, 450); this.ClientSize = new System.Drawing.Size(779, 494);
this.Controls.Add(this.logTextBox2);
this.Controls.Add(this.button5); this.Controls.Add(this.button5);
this.Controls.Add(this.button4); this.Controls.Add(this.btSendCV);
this.Controls.Add(this.button3); this.Controls.Add(this.button3);
this.Controls.Add(this.logTextBox1); this.Controls.Add(this.logTextBox1);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
@@ -185,8 +206,9 @@
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private arCtl.LogTextBox logTextBox1; private arCtl.LogTextBox logTextBox1;
private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4; private System.Windows.Forms.Button btSendCV;
private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button5;
private arCtl.LogTextBox logTextBox2;
} }
} }

View File

@@ -25,19 +25,16 @@ namespace Test_BMS
private void Bms_BMSCellDataReceive(object sender, arDev.BMSCelvoltageEventArgs e) private void Bms_BMSCellDataReceive(object sender, arDev.BMSCelvoltageEventArgs e)
{ {
var valuestr = string.Join(" ", e.voltage.Select(t => t.ToString())); var valuestr = e.ToString();// string.Join(" ", e.voltage.Select(t => t.ToString()));
addmsg($"voltage:{valuestr}"); addmsg2($"{valuestr}");
} }
private void Bms_BMSDataReceive(object sender, EventArgs e) private void Bms_BMSDataReceive(object sender, arDev.BMSInformationEventArgs e)
{ {
//최종 데이터가 수신되는 경우 //최종 데이터가 수신되는 경우
string msg = $"{bms.Current_Volt}v,{bms.Current_Level}%,{bms.Current_Amp}/{bms.Current_MaxAmp}"; addmsg(e.Data.ToString());
addmsg("Recv:" + msg);
} }
private void Bms_Message(object sender, arDev.BMSSerialComm.MessageEventArgs e) private void Bms_Message(object sender, arDev.BMSSerialComm.MessageEventArgs e)
{ {
var sb = new System.Text.StringBuilder(); var sb = new System.Text.StringBuilder();
@@ -61,7 +58,6 @@ namespace Test_BMS
else else
addmsg($"{e.MsgType}:{sb}"); addmsg($"{e.MsgType}:{sb}");
} }
void addmsg(string m) void addmsg(string m)
{ {
if (logTextBox1.InvokeRequired) if (logTextBox1.InvokeRequired)
@@ -76,6 +72,19 @@ namespace Test_BMS
} }
} }
void addmsg2(string m)
{
if (logTextBox2.InvokeRequired)
{
logTextBox2.BeginInvoke(new Action(() => {
logTextBox2.AddMsg(m);
}));
}
else
{
logTextBox2.AddMsg(m);
}
}
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {