BMS 를 RS232 클래스에서 폴링방식 전용 클래스로 변경
BMS 정보중 현재 사용 전류와 와트를 표시함 사용전류를 통해서 충전여부를 자동 판다시키고, 해당 값은 Manual Charge 플래그에 설정함.
This commit is contained in:
@@ -106,8 +106,7 @@ namespace Project
|
||||
PUB.log.Add($"충전상태전환 {agv_chg}");
|
||||
VAR.BOOL[eVarBool.FLAG_CHARGEONA] = agv_chg;
|
||||
}
|
||||
//자동충전해제시 곧바로 수동 충전되는 경우가 있어 자동 상태를 BMS에 넣는다 230118
|
||||
PUB.BMS.AutoCharge = agv_chg;
|
||||
|
||||
|
||||
if (PUB.AGV.error.Charger_pos_error != VAR.BOOL[eVarBool.CHG_POSERR])
|
||||
{
|
||||
|
||||
@@ -25,15 +25,18 @@ namespace Project
|
||||
DateTime lastbmstime = DateTime.Now;
|
||||
private void Bms_Message(object sender, arDev.BMS.MessageEventArgs e)
|
||||
{
|
||||
if (e.MsgType == arDev.arRS232.MessageType.Error) PUB.logbms.AddE( e.Message);
|
||||
|
||||
if (e.MsgType == arDev.BMSSerialComm.MessageType.Error) PUB.logbms.AddE(e.Message);
|
||||
else
|
||||
{
|
||||
VAR.TIME[eVarTime.LastRecv_BAT] = DateTime.Now;
|
||||
|
||||
var hexstr = e.Data.GetHexString().Trim();
|
||||
bool addlog = false;
|
||||
var logtimesec = 30;
|
||||
if (hexstr.StartsWith("DD 04"))
|
||||
{
|
||||
if (lastbms04.Equals(hexstr.Substring(0,5)) == false)
|
||||
if (lastbms04.Equals(hexstr.Substring(0, 5)) == false)
|
||||
{
|
||||
addlog = true;
|
||||
lastbms04 = "DD 04";
|
||||
@@ -133,37 +136,49 @@ namespace Project
|
||||
}
|
||||
}
|
||||
|
||||
if(addlog)
|
||||
PUB.logbms.Add("BMS:" + hexstr);
|
||||
if (addlog)
|
||||
{
|
||||
//if (e.MsgType == arDev.arRS232.MessageType.Recv)
|
||||
// PUB.logbms.Add("RX", e.Data.GetHexString());
|
||||
//else if (e.MsgType == arDev.arRS232.MessageType.Send)
|
||||
// PUB.logbms.Add("TX", e.Data.GetHexString());
|
||||
//else
|
||||
{
|
||||
PUB.logbms.Add(e.MsgType.ToString(),e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private void BMS_ChargeDetect(object sender, arDev.ChargetDetectArgs e)
|
||||
{
|
||||
//자동충전중이아니고 멈춰있다면 수동 충전으로 전환한다
|
||||
if (PUB.AGV.system1.Battery_charging == false && PUB.AGV.system1.agv_stop == true && VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false)
|
||||
VAR.TIME[eVarTime.LastRecv_BAT] = DateTime.Now;
|
||||
if (e.Detected == true) //충전이 감지되었다.
|
||||
{
|
||||
if (PUB.setting.DetectManualCharge)
|
||||
if (VAR.BOOL[eVarBool.FLAG_AUTORUN] == false && VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false)
|
||||
{
|
||||
VAR.BOOL[eVarBool.FLAG_CHARGEONM] = true;
|
||||
PUB.Speak(Lang.충전이감지되어수동충전으로전환합니다);
|
||||
if (PUB.AGV.system1.agv_run == true) PUB.AGV.AGVMoveStop("수동충전감지");
|
||||
}
|
||||
else
|
||||
{
|
||||
PUB.log.Add($"충전이 감지되었지만 메뉴얼 전환 비활성화됨");
|
||||
}
|
||||
|
||||
}
|
||||
else PUB.logbms.AddI("Battery Charge Off");
|
||||
|
||||
}
|
||||
|
||||
private void Bms_BMSDataReceive(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
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
|
||||
// [Sync] Update VirtualAGV Battery
|
||||
PUB.UpdateAGVBattery(PUB.BMS.Current_Level);
|
||||
|
||||
if (PUB.BMS.Current_Level <= PUB.setting.ChargeStartLevel)
|
||||
@@ -188,6 +203,7 @@ namespace Project
|
||||
}
|
||||
private void BMS_BMSCellDataReceive(object sender, arDev.BMSCelvoltageEventArgs e)
|
||||
{
|
||||
VAR.TIME[eVarTime.LastRecv_BAT] = DateTime.Now;
|
||||
EEMStatus.MakeBMSInformation_Cell();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Project
|
||||
lock (connectobj)
|
||||
{
|
||||
ConnectSerialPort(PUB.XBE, PUB.setting.Port_XBE, PUB.setting.Baud_XBE,
|
||||
eVarTime.LastConn_XBE, eVarTime.LastConnTry_XBE, eVarTime.LastRecv_XBE);
|
||||
eVarTime.LastConn_XBE, eVarTime.LastConnTry_XBE, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ namespace Project
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ========== 2. XBee 상태 전송 ==========
|
||||
if (PUB.XBE != null && PUB.XBE.IsOpen)
|
||||
{
|
||||
@@ -147,7 +146,7 @@ namespace Project
|
||||
/// <summary>
|
||||
/// 시리얼 포트 연결 (arDev.arRS232)
|
||||
/// </summary>
|
||||
bool ConnectSerialPort(arDev.ISerialComm dev, string port, int baud, eVarTime conn, eVarTime conntry, eVarTime recvtime)
|
||||
bool ConnectSerialPort(arDev.ISerialComm dev, string port, int baud, eVarTime conn, eVarTime conntry, eVarTime? recvtime)
|
||||
{
|
||||
if (port.isEmpty()) return false;
|
||||
|
||||
@@ -159,13 +158,13 @@ namespace Project
|
||||
VAR.TIME.Update(conntry);
|
||||
try
|
||||
{
|
||||
VAR.TIME.Update(recvtime);
|
||||
if (recvtime != null) VAR.TIME.Update(recvtime);
|
||||
dev.PortName = port;
|
||||
dev.BaudRate = baud;
|
||||
PUB.log.Add($"Connect to {port}:{baud}");
|
||||
if (dev.Open())
|
||||
{
|
||||
VAR.TIME[recvtime] = DateTime.Now; //값을 수신한것처럼한다
|
||||
if (recvtime != null) VAR.TIME[recvtime] = DateTime.Now; //값을 수신한것처럼한다
|
||||
PUB.log.Add(port, $"[{port}:{baud}] 연결 완료");
|
||||
}
|
||||
else
|
||||
@@ -202,7 +201,7 @@ namespace Project
|
||||
|
||||
VAR.TIME.Update(conntry);
|
||||
}
|
||||
else if (dev.IsOpen)
|
||||
else if (dev.IsOpen && recvtime != null)
|
||||
{
|
||||
//연결은 되었으나 통신이 지난지 10초가 지났다면 자동종료한다
|
||||
var tsRecv = VAR.TIME.RUN(recvtime);
|
||||
|
||||
Reference in New Issue
Block a user