using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Text; using arCtl; using Project.StateMachine; using COMM; using AR; namespace Project { public partial class fMain { string lastbms03 = ""; string lastbms04 = ""; string lastbmsA03 = ""; string lastbmsA04 = ""; string lastbms = ""; DateTime lastbmstime03 = DateTime.Now; DateTime lastbmstime04 = DateTime.Now; DateTime lastbmstimeA03 = DateTime.Now; DateTime lastbmstimeA04 = DateTime.Now; 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); else { 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) { addlog = true; lastbms04 = "DD 04"; lastbmstime04 = DateTime.Now; } else { var ts = DateTime.Now - lastbmstime04; if (ts.TotalSeconds > logtimesec) { addlog = true; lastbms04 = "DD 04"; lastbmstime04 = DateTime.Now; } } } else if (hexstr.StartsWith("DD 03")) { if (lastbms03.Equals(hexstr.Substring(0, 5)) == false) { addlog = true; lastbms03 = "DD 03"; lastbmstime03 = DateTime.Now; } else { var ts = DateTime.Now - lastbmstime03; if (ts.TotalSeconds > logtimesec) { addlog = true; lastbms03 = "DD 03"; lastbmstime03 = DateTime.Now; } } } else if (hexstr.StartsWith("DD A5 04")) { if (lastbmsA04.Equals(hexstr.Substring(0, 8)) == false) { addlog = true; lastbmsA04 = "DD A5 04"; lastbmstimeA04 = DateTime.Now; } else { var ts = DateTime.Now - lastbmstimeA04; if (ts.TotalSeconds > logtimesec) { addlog = true; lastbmsA04 = "DD A5 04"; lastbmstimeA04 = DateTime.Now; } } } else if (hexstr.StartsWith("DD A5 03")) { if (lastbmsA03.Equals(hexstr.Substring(0, 8)) == false) { addlog = true; lastbmsA03 = "DD A5 03"; lastbmstimeA03 = DateTime.Now; } else { var ts = DateTime.Now - lastbmstimeA03; if (ts.TotalSeconds > logtimesec) { addlog = true; lastbmsA03 = "DD A5 03"; lastbmstimeA03 = DateTime.Now; } } } else if (hexstr.isEmpty() == false) { if (lastbms.Equals(hexstr) == false) { lastbms = hexstr; lastbmstime = DateTime.Now; addlog = true; } else { var ts = DateTime.Now - lastbmstime; if (ts.TotalSeconds > logtimesec) { addlog = true; lastbms = hexstr; lastbmstime = DateTime.Now; } } } if(addlog) PUB.logbms.Add("BMS:" + hexstr); } } 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) { if (PUB.setting.DetectManualCharge) { VAR.BOOL[eVarBool.FLAG_CHARGEONM] = true; PUB.Speak(Lang.충전이감지되어수동충전으로전환합니다); } else { PUB.log.Add($"충전이 감지되었지만 메뉴얼 전환 비활성화됨"); } } } private void Bms_BMSDataReceive(object sender, EventArgs e) { //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; if (PUB.BMS.Current_Level <= PUB.setting.ChargeStartLevel) { //배터리 레벨이 기준보다 낮다면 경고를 활성화 한다 if (VAR.BOOL[eVarBool.BATTERY_LOW] == false) { VAR.BOOL[eVarBool.BATTERY_LOW] = true; PUB.log.AddAT("배터리 부족 경고 활성화"); } } else { //배터리 경고를 해제한다 if (VAR.BOOL[eVarBool.BATTERY_LOW] == true) { VAR.BOOL[eVarBool.BATTERY_LOW] = false; PUB.log.AddAT("배터리 부족 경고 비활성화"); } } EEMStatus.MakeBMSInformation_INFO(); } private void BMS_BMSCellDataReceive(object sender, arDev.BMSCelvoltageEventArgs e) { EEMStatus.MakeBMSInformation_Cell(); } } }