Commit bf7f07cd 顾剑亮

debug

1 个父辈 b4ab9229
正在显示 47 个修改的文件 包含 288 行增加135 行删除
......@@ -153,8 +153,8 @@ namespace AGVControl_Elevator
{
for (int i = 0; i < Common.lineInfos.Count; i++)
{
lineDI[i].BackColor = Common.lineInfos[i].Call ? BACK_TRUE : BACK_FALSE;
lineShelf[i].BackColor = Common.lineInfos[i].Exist ? BACK_TRUE : BACK_FALSE;
lineDI[i].BackColor = Common.lineInfos[i].LineCall ? BACK_TRUE : BACK_FALSE;
lineShelf[i].BackColor = Common.lineInfos[i].ShelfExist ? BACK_TRUE : BACK_FALSE;
}
}
......@@ -177,10 +177,13 @@ namespace AGVControl_Elevator
private void ElevatorDO_Click(object sender, EventArgs e)
{
if (ChkMissionDebug.Checked)
{
Button btn = sender as Button;
int index = Array.FindIndex(elevatorDO, s => s == btn);
BLL.ManageWork.elevator.WriteDO(index);
}
}
private void FrmMain_Load(object sender, EventArgs e)
{
......@@ -190,6 +193,7 @@ namespace AGVControl_Elevator
LstMission.Items.AddRange(Common.agvMissions.Keys.ToArray());
NudShelfCurr.Value = Common.FirstFloorCurr;
NudShelfCount.Value = Common.FirstFloorCount;
ChkAutoCharge.Checked = Common.AutoCharge;
for (int i = 0; i < Common.agvInfos.Count; i++)
{
......@@ -287,9 +291,10 @@ namespace AGVControl_Elevator
info.IsAuto = !info.IsAuto;
DgvName.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = info.IsAuto.ToString();
Common.appConfig.AppSettings.Settings[info.Name].Value = info.IsAuto.ToString();
Common.appConfig.Save();
Common.appConfig.Save(System.Configuration.ConfigurationSaveMode.Modified);
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
Common.log.Info("手动修改 " + info.Name + " IsUse=" + info.IsAuto);
Common.log.UI_Display(string.Format("手动修改 {0} 的自动状态为{1}", info.Name, info.IsAuto));
Common.log.Info(string.Format("手动修改 {0} 的自动状态为{1}", info.Name, info.IsAuto));
}
else if (e.ColumnIndex == DgvName.Columns.Count - 1) //最后一列,清除任务
{
......@@ -303,8 +308,10 @@ namespace AGVControl_Elevator
info.Place = "";
DgvName.Rows[e.RowIndex].Cells[e.ColumnIndex - 1].Value = info.IsAuto.ToString();
Common.appConfig.AppSettings.Settings[info.Name].Value = info.IsAuto.ToString();
Common.appConfig.Save();
Common.appConfig.Save(System.Configuration.ConfigurationSaveMode.Modified);
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
Common.log.UI_Display(string.Format("手动清除 {0} 的当前任务,并且自动状态改为{1}", info.Name, info.IsAuto));
Common.log.Info(string.Format("手动清除 {0} 的当前任务,并且自动状态改为{1}", info.Name, info.IsAuto));
}
}
}
......@@ -316,8 +323,8 @@ namespace AGVControl_Elevator
DialogResult dr = MessageBox.Show(text, "", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dr == DialogResult.No) return;
info.Call = false;
lineDI[CboLineName.SelectedIndex].BackColor = info.Call ? BACK_TRUE : BACK_FALSE;
info.LineCall = false;
lineDI[CboLineName.SelectedIndex].BackColor = info.LineCall ? BACK_TRUE : BACK_FALSE;
Common.log.Info(string.Format("手动取消{0}呼叫", info.Name));
BLL.ManageWork.line.Save();
}
......@@ -329,35 +336,42 @@ namespace AGVControl_Elevator
DialogResult dr = MessageBox.Show(text, "", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dr == DialogResult.No) return;
info.Exist = !info.Exist;
lineShelf[CboLineName.SelectedIndex].BackColor = info.Exist ? BACK_TRUE : BACK_FALSE;
Common.log.Info(string.Format("手动改变{0}货架状态{1}", info.Name, info.Exist));
info.ShelfExist = !info.ShelfExist;
lineShelf[CboLineName.SelectedIndex].BackColor = info.ShelfExist ? BACK_TRUE : BACK_FALSE;
Common.log.Info(string.Format("手动改变{0}货架状态{1}", info.Name, info.ShelfExist));
BLL.ManageWork.line.Save();
}
private void ChkMissionDebug_CheckedChanged(object sender, EventArgs e)
{
CboLineName.Enabled = ChkMissionDebug.Checked;
BtnLineCall.Enabled = ChkMissionDebug.Checked;
BtnLineShelf.Enabled = ChkMissionDebug.Checked;
NudShelfCurr.Enabled = ChkMissionDebug.Checked;
NudShelfCount.Enabled = ChkMissionDebug.Checked;
BtnShelfGet.Enabled = ChkMissionDebug.Checked;
BtnShelfSet.Enabled = ChkMissionDebug.Checked;
ChkAutoCharge.Enabled = ChkMissionDebug.Checked;
}
private void BtnClearLog_Click(object sender, EventArgs e)
{
TxtLog.Text = "";
Common.log.UI_Clear();
}
private void BtnShelfSet_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(NudShelfCurr.Value);
Common.FirstFloorCurr = n;
System.IO.File.WriteAllText(Common.PATH_FIRST_FLOOR_CURR, n.ToString(), Encoding.UTF8);
Common.FirstFloorCurr = Convert.ToInt32(NudShelfCurr.Value);
BLL.ManageWork.FirstFloorSave();
n = Convert.ToInt32(NudShelfCount.Value);
int n = Convert.ToInt32(NudShelfCount.Value);
if (Common.FirstFloorCount != n)
{
Common.FirstFloorCount = n;
Common.appConfig.AppSettings.Settings["FirstFloorCount"].Value = n.ToString();
Common.appConfig.Save();
Common.appConfig.Save(System.Configuration.ConfigurationSaveMode.Modified);
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
}
MessageBox.Show("设置保存成功");
}
......@@ -365,7 +379,7 @@ namespace AGVControl_Elevator
{
Common.AutoCharge = ChkAutoCharge.Checked;
Common.appConfig.AppSettings.Settings["AutoCharge"].Value = Common.AutoCharge.ToString();
Common.appConfig.Save();
Common.appConfig.Save(System.Configuration.ConfigurationSaveMode.Modified);
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
}
......@@ -374,5 +388,49 @@ namespace AGVControl_Elevator
NudShelfCurr.Value = Common.FirstFloorCurr;
NudShelfCount.Value = Common.FirstFloorCount;
}
private void BtnEmptyError_Click(object sender, EventArgs e)
{
//System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(BLL.ManageWork.EmptyErrorDispose));
//thread.Start();
if (DgvName.SelectedCells.Count == 0) return;
AgvInfo info = Common.agvInfos[DgvName.SelectedCells[0].RowIndex];
if (info.IsAuto)
{
MessageBox.Show(info.Name + "自动模式不允许操作");
}
else
{
BLL.ManageWork.EmptyErrorDispose();
Common.log.Info("手动异常处理,结束回收货架任务");
MessageBox.Show("结束回收货架任务处理完成", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void BtnFullError_Click(object sender, EventArgs e)
{
//System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(BLL.ManageWork.FullErrorDispose));
//thread.Start();
if (DgvName.SelectedCells.Count == 0) return;
AgvInfo info = Common.agvInfos[DgvName.SelectedCells[0].RowIndex];
if (info.IsAuto)
{
MessageBox.Show(info.Name + "自动模式不允许操作");
}
else
{
BLL.ManageWork.FullErrorDispose();
Common.log.Info("手动异常处理,结束送满料任务");
MessageBox.Show("结束送满料任务处理完成", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
......@@ -62,7 +62,7 @@ namespace AGVControl_Elevator
if (Common.appConfig.AppSettings.Settings[str[1]] == null)
{
Common.appConfig.AppSettings.Settings.Add(str[1], "false");
Common.appConfig.Save();
Common.appConfig.Save(System.Configuration.ConfigurationSaveMode.Modified);
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
}
else
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<appSettings>
<add key="FLEET_IP" value="10.85.199.3" />
<add key="FleetSend" value="true" />
<add key="BatteryMax" value="100" />
<add key="BatteryMin" value="20" />
<add key="BatteryIdle" value="80" />
<add key="ElevatorIOIP" value="10.85.199.148" />
<add key="FirstFloorCount" value="2" />
<add key="AutoCharge" value="true" />
<add key="12号车" value="false" />
<add key="FLEET_IP" value="10.85.199.3"/>
<add key="FleetSend" value="true"/>
<add key="BatteryMax" value="100"/>
<add key="BatteryMin" value="20"/>
<add key="BatteryIdle" value="80"/>
<add key="ElevatorIOIP" value="10.85.199.148"/>
<add key="FirstFloorCount" value="2"/>
<add key="AutoCharge" value="true"/>
</appSettings>
</configuration>
\ No newline at end of file
......@@ -3,8 +3,10 @@ MoveStandby,1ca1ba19-1e6a-11eb-b091-94c691a7387d
MoveElevatorSide,3383a4dc-1e6a-11eb-b091-94c691a7387d
EnterElevatorFull,4b3ffeba-1e6a-11eb-b091-94c691a7387d
EnterElevatorEmpty,5fcad6a1-1ea9-11eb-b091-94c691a7387d
LeaveShelf,887f0e4b-20d1-11eb-b091-94c691a7387d
CarryElevatorSide,c7242eee-20d2-11eb-b091-94c691a7387d
CarryFullD1,43cc7897-200c-11eb-b091-94c691a7387d
CarryFullD2,5fa6b99e-200c-11eb-b091-94c691a7387d
CarryFullD2,27c0a726-22ba-11eb-90bb-94c691a7334a
CarryFullD3,73ddebc6-200c-11eb-b091-94c691a7387d
CarryFullD4,8949860d-200c-11eb-b091-94c691a7387d
CarryFullD5,9e21bda5-200c-11eb-b091-94c691a7387d
......@@ -33,7 +35,5 @@ CarryEmptyT6,e0fb038d-200e-11eb-b091-94c691a7387d
CarryEmptyT7,f2619898-200e-11eb-b091-94c691a7387d
CarryEmptyT8,05a18e78-200f-11eb-b091-94c691a7387d
CarryEmptyT9,1d13831b-200f-11eb-b091-94c691a7387d
LeaveShelf,887f0e4b-20d1-11eb-b091-94c691a7387d
CarryElevatorSide,c7242eee-20d2-11eb-b091-94c691a7387d
PickShelf,9807e65c-1e9b-11eb-998e-94c691a7334a
PlaceShelf,dbfd5a43-1e9b-11eb-998e-94c691a7334a
\ No newline at end of file
[2020-11-10 10:15:04,691][1][AGVControl:18]INFO =====程序开始=====
[2020-11-10 10:15:04,749][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\AgvName.csv
[2020-11-10 10:15:04,755][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\AgvMission.csv
[2020-11-10 10:15:04,762][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\Line.csv
[2020-11-10 10:15:04,768][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\Elevator.csv
[2020-11-10 10:15:04,887][1][AGVControl:18]INFO 加载缓存文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\LineWork.txt
[2020-11-10 10:15:07,371][12][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:09,863][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:11,873][11][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:13,873][9][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:15,873][11][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:17,873][9][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:19,875][10][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:21,864][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:23,874][8][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:25,869][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:28,360][12][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:30,376][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:32,865][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:34,861][8][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:37,369][14][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:39,363][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:41,361][14][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:43,367][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:44,659][1][AGVControl:18]INFO =====程序结束=====
[2020-11-10 10:15:04,911][1][IO_Elevator:63]INFO ===== IO[10.85.199.148] Open =====
[2020-11-10 10:15:06,874][6][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:08,866][7][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:10,861][8][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:13,365][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:15,369][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:17,363][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:19,368][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:21,369][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:23,363][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:25,373][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:27,373][14][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:29,863][6][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:31,875][10][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:33,872][11][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:36,361][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:38,869][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:40,867][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:42,871][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:44,641][1][IO_Elevator:78]INFO ===== IO[10.85.199.148] Close =====
[2020-11-10 10:15:07,370][12][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:09,863][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:11,873][11][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:13,873][9][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:15,873][11][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:17,873][9][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:19,875][10][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:21,864][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:23,874][8][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:25,869][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:28,360][12][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:30,375][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:32,865][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:34,861][8][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:37,369][14][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:39,363][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:41,361][14][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:43,367][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
......@@ -54,16 +54,16 @@ namespace BLL
fullShelfStep.NextStep(FullShelfStep.CallElevator);
fullShelfStep.Msg = string.Format("{0} 电梯可以使用", _info.Name);
}
//else if (ManageWork.FindElevatorWork())
//{
// //送满架子时,同时要回收空架子
// ManageWork.PauseFull = true;
// mission = Common.MISSION_LEAVE_SHELF;
// move = new MissionJob(mission);
// move.Execute(_info);
// fullShelfStep.NextStep(FullShelfStep.LeaveShelf);
// fullShelfStep.Msg = string.Format("{0} 暂停送满货架,优先拉空货架", _info.Name);
//}
else if (ManageWork.FindElevatorWork())
{
//送满架子时,同时要回收空架子
ManageWork.PauseFull = true;
mission = Common.MISSION_LEAVE_SHELF;
move = new MissionJob(mission);
move.Execute(_info);
fullShelfStep.NextStep(FullShelfStep.LeaveShelf);
fullShelfStep.Msg = string.Format("{0} 暂停送满货架,优先拉空货架", _info.Name);
}
else
{
Common.log.Debug(string.Format("{0} 电梯还未应答使用请求", _info.Name));
......@@ -123,7 +123,8 @@ namespace BLL
{
//离开信号保持几秒后,取消所有信号
ManageWork.ElevatorEnd();
Common.FirstFloorCurr++;
ManageWork.FirstFloorAdd();
fullShelfStep.Msg = string.Format("{0} 送满料任务结束,当前一楼货架数量{1}个", _info.Name, Common.FirstFloorCurr);
fullShelfStep.NextStep(FullShelfStep.End);
}
......@@ -141,9 +142,17 @@ namespace BLL
{
IsEnd = true;
if (ManageWork.PauseFull)
{
return new RecycleJob();
}
else
{
IJob job = ManageWork.GetJob();
if (job == null)
return new StandbyJob();
else
return job;
}
}
return this;
......
......@@ -47,7 +47,8 @@ namespace BLL
if (ts.Seconds >= 3)
{
ManageWork.ElevatorEnd();
Common.FirstFloorCurr--;
ManageWork.FirstFloorMinus();
recycleStep.Msg = string.Format("{0} 回收空货架任务,当前一楼货架数量{1}个", _info.Name, Common.FirstFloorCurr);
FindLine();
}
......@@ -69,9 +70,17 @@ namespace BLL
{
IsEnd = true;
if (ManageWork.PauseFull)
{
return new FullShelfJob();
}
else
{
IJob job = ManageWork.GetJob();
if (job == null)
return new StandbyJob();
else
return job;
}
}
return this;
......
......@@ -33,6 +33,7 @@ namespace BLL
if (move.IsEnd)
{
_info.Place = "待机位";
_info.MissionName = "";
standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = _info.Name + " 到达待机位";
}
......@@ -49,6 +50,10 @@ namespace BLL
standbyStep.Msg = string.Format("{0} 电量小于{1}%,执行充电任务", _info.Name, Common.BatteryMin);
return new ChargeJob();
}
else
{
standbyStep.Msg = string.Format("{0} 电量小于{1}%,不在执行任务,并且没有打开自动充电。", _info.Name, Common.BatteryMin);
}
}
else
{
......@@ -64,6 +69,7 @@ namespace BLL
return new ChargeJob();
}
}
standbyStep.Msg = string.Format("{0} 空闲,当前电量{1}%", _info.Name, _info.Battery);
}
else
{
......
......@@ -101,7 +101,7 @@ namespace BLL
foreach (Process process in processes)
{
if (process.Id == current.Id) continue; //自己
if (process.MainModule.FileName == current.MainModule.FileName)
if (process.MainModule.ModuleName == current.MainModule.ModuleName)
{
//显示已打开的程序
ShowWindow(process.MainWindowHandle, SW_RESTORE);
......
......@@ -39,6 +39,7 @@ namespace BLL
Advantech.IO_State sta = module.ReadDO(add);
sta = module.ReverseStatus(sta);
module.WriteDO(add, sta);
Common.log.Info(string.Format("手动操作 {0}={1}", Common.elevatorInfos[index].Name, sta.ToString()));
}
public IJob GetJob()
......@@ -104,7 +105,7 @@ namespace BLL
return Common.elevatorInfos[idx].State;
}
public void FullShelf()
public void FullShelfLeave()
{
//送满料
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_FULL_SHELF);
......@@ -117,7 +118,7 @@ namespace BLL
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.On);
}
public void EmptyShelf()
public void EmptyShelfLeave()
{
//离开信号
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_LEAVE);
......@@ -139,6 +140,9 @@ namespace BLL
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.Off);
idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_CALL);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.Off);
}
private void Module_Connect_Event(Advantech.IO_Module box)
......
......@@ -41,7 +41,7 @@ namespace BLL
{
if (Common.FirstFloorCurr < Common.FirstFloorCount)
{
int index = Common.lineInfos.FindIndex(s => s.Call && s.Exist); //有呼叫状态同时存在架子
int index = Common.lineInfos.FindIndex(s => s.LineCall && s.ShelfExist);
if (index > -1)
{
Common.log.Info(Common.lineInfos[index].Name + "呼叫送满架");
......@@ -64,8 +64,8 @@ namespace BLL
{
int index = Common.lineInfos.FindIndex(s => s.Key == key);
if (index == -1) return;
Common.lineInfos[index].Call = false;
Common.lineInfos[index].Exist = false;
Common.lineInfos[index].LineCall = false;
Common.lineInfos[index].ShelfExist = false;
Common.lineInfos[index].FinalDate = DateTime.Now;
Save();
DI_Changed?.Invoke();
......@@ -75,8 +75,8 @@ namespace BLL
{
int index = Common.lineInfos.FindIndex(s => s.Key == key);
if (index == -1) return;
Common.lineInfos[index].Call = false;
Common.lineInfos[index].Exist = true;
Common.lineInfos[index].LineCall = false;
Common.lineInfos[index].ShelfExist = true;
Save();
DI_Changed?.Invoke();
}
......@@ -96,8 +96,8 @@ namespace BLL
if (str.Length != 4) continue;
int index = Common.lineInfos.FindIndex(s => s.Key == str[0]);
if (index == -1) continue;
Common.lineInfos[index].Call = Convert.ToBoolean(str[1]);
Common.lineInfos[index].Exist = Convert.ToBoolean(str[2]);
Common.lineInfos[index].LineCall = Convert.ToBoolean(str[1]);
Common.lineInfos[index].ShelfExist = Convert.ToBoolean(str[2]);
Common.lineInfos[index].FinalDate = Convert.ToDateTime(str[3]);
}
Common.log.Info("加载缓存文件 " + Common.PATH_LINE_WORK);
......@@ -114,7 +114,7 @@ namespace BLL
string[] content = new string[Common.lineInfos.Count + 1];
content[0] = "产线名,呼叫,架子,时间";
for (int i = 0; i < Common.lineInfos.Count; i++)
content[i + 1] = string.Format("{0},{1},{2},{3:yyyy-MM-dd HH:mm:ss}", Common.lineInfos[i].Key, Common.lineInfos[i].Call, Common.lineInfos[i].Exist, Common.lineInfos[i].FinalDate);
content[i + 1] = string.Format("{0},{1},{2},{3:yyyy-MM-dd HH:mm:ss}", Common.lineInfos[i].Key, Common.lineInfos[i].LineCall, Common.lineInfos[i].ShelfExist, Common.lineInfos[i].FinalDate);
System.IO.File.WriteAllLines(Common.PATH_LINE_WORK, content, Encoding.UTF8);
Common.log.Info("保存缓存文件 " + Common.PATH_LINE_WORK);
}
......@@ -138,10 +138,13 @@ namespace BLL
bool change = false;
if (sta[add] == Advantech.IO_State.On)
{
Common.lineInfos[lineIdx].Call = true;
if (!Common.lineInfos[lineIdx].LineCall) //已经呼叫了就不在更新时间了
{
Common.lineInfos[lineIdx].LineCall = true;
Common.lineInfos[lineIdx].FinalDate = DateTime.Now;
change = true;
}
}
if (change) Save();
DI_Changed?.Invoke();
......
......@@ -9,9 +9,11 @@ namespace BLL
public static LineWork line;
public static ElevatorWork elevator;
public static bool PauseFull;
public static string frontLine;
public static void Init()
{
frontLine = "";
PauseFull = false;
line = new LineWork();
elevator = new ElevatorWork();
......@@ -41,6 +43,8 @@ namespace BLL
return job;
}
/// <summary>
/// 查找产线呼叫
/// </summary>
......@@ -49,7 +53,22 @@ namespace BLL
/// <returns></returns>
public static bool FindLineWork(out string key, out string name)
{
int index = Common.lineInfos.FindIndex(s => s.Call && s.Exist);
//按时间的先后顺序
int index = -1;
DateTime dt = DateTime.Now;
for (int i = 0; i < Common.lineInfos.Count; i++)
{
if (Common.lineInfos[i].LineCall && Common.lineInfos[i].ShelfExist)
{
if (dt > Common.lineInfos[i].FinalDate)
{
dt = Common.lineInfos[i].FinalDate;
index = i;
}
}
}
//int index = Common.lineInfos.FindIndex(s => s.Call && s.Exist);
if (index == -1)
{
key = "";
......@@ -81,19 +100,56 @@ namespace BLL
/// <returns></returns>
public static bool FindLineWithoutShelf(out string key, out string name)
{
int index = Common.lineInfos.FindIndex(s => s.Exist == false);
int index;
int startIndex = Common.lineInfos.FindIndex(s => s.Key == frontLine);
if (startIndex == -1) //没有关键字
{
index = Common.lineInfos.FindIndex(s => s.ShelfExist == false);
}
else if (startIndex == Common.lineInfos.Count - 1) //最后一行
{
index = Common.lineInfos.FindIndex(s => s.ShelfExist == false);
}
else
{
index = Common.lineInfos.FindIndex(++startIndex, s => s.ShelfExist == false);
if (index == -1) //从头开始
index = Common.lineInfos.FindIndex(s => s.ShelfExist == false);
}
if (index == -1)
{
key = "";
name = "";
frontLine = "";
return false;
}
else
{
key = Common.lineInfos[index].Key;
name = Common.lineInfos[index].Name;
frontLine = key;
return true;
}
//int index = Common.lineInfos.FindIndex(s => s.Exist == false);
//if (index == -1)
//{
// key = "";
// name = "";
// return false;
//}
//else
//{
// key = Common.lineInfos[index].Key;
// name = Common.lineInfos[index].Name;
// return true;
//}
}
/// <summary>
......@@ -131,11 +187,19 @@ namespace BLL
return elevator.UseAnswer();
}
/// <summary>
/// 电梯呼叫
/// </summary>
/// <param name="sta"></param>
public static void ElevatorCall(bool sta)
{
elevator.CallElevator(sta);
}
/// <summary>
/// 电梯已准备好(到达4楼并开门)
/// </summary>
/// <returns></returns>
public static bool ElevatorReady()
{
bool rtn1 = elevator.ArriveFloor();
......@@ -148,7 +212,7 @@ namespace BLL
/// </summary>
public static void ElevatorFullShelf()
{
elevator.FullShelf();
elevator.FullShelfLeave();
}
/// <summary>
......@@ -156,7 +220,7 @@ namespace BLL
/// </summary>
public static void ElevatorEmptyShelf()
{
elevator.EmptyShelf();
elevator.EmptyShelfLeave();
}
/// <summary>
......@@ -168,5 +232,58 @@ namespace BLL
}
public static void FirstFloorAdd()
{
Common.FirstFloorCurr++;
if (Common.FirstFloorCurr > Common.FirstFloorCount)
Common.FirstFloorCurr = Common.FirstFloorCount;
System.IO.File.WriteAllText(Common.PATH_FIRST_FLOOR_CURR, Common.FirstFloorCurr.ToString(), Encoding.UTF8);
}
public static void FirstFloorMinus()
{
Common.FirstFloorCurr--;
if (Common.FirstFloorCurr < 0)
Common.FirstFloorCurr = 0;
System.IO.File.WriteAllText(Common.PATH_FIRST_FLOOR_CURR, Common.FirstFloorCurr.ToString(), Encoding.UTF8);
}
public static void FirstFloorSave()
{
if (Common.FirstFloorCurr < 0)
Common.FirstFloorCurr = 0;
else if (Common.FirstFloorCurr > Common.FirstFloorCount)
Common.FirstFloorCurr = Common.FirstFloorCount;
System.IO.File.WriteAllText(Common.PATH_FIRST_FLOOR_CURR, Common.FirstFloorCurr.ToString(), Encoding.UTF8);
}
/// <summary>
/// 回收空货架错误处理
/// </summary>
public static void EmptyErrorDispose()
{
elevator.EmptyShelfLeave();
System.Threading.Thread.Sleep(3000);
elevator.EndTask();
FirstFloorMinus();
}
/// <summary>
/// 送满货架错误处理
/// </summary>
public static void FullErrorDispose()
{
elevator.FullShelfLeave();
System.Threading.Thread.Sleep(3000);
elevator.EndTask();
FirstFloorAdd();
}
}
}
......@@ -33,8 +33,8 @@ namespace Model
public string IP { private set; get; }
public int Address { private set; get; }
public string Key { private set; get; }
public bool Call { set; get; }
public bool Exist { set; get; }
public bool LineCall { set; get; }
public bool ShelfExist { set; get; }
public DateTime FinalDate { set; get; }
......@@ -44,8 +44,8 @@ namespace Model
IP = ip;
Address = Convert.ToInt32(address);
Key = key;
Call = false;
Exist = true;
LineCall = false;
ShelfExist = true;
FinalDate = DateTime.Now;
}
}
......
using System;
using System.Collections.Generic;
namespace Model
{
public class Log
{
private readonly log4net.ILog LOG;
private List<string> history;
private const int MAX_LINES = 50;
public Log(string name)
{
LOG = log4net.LogManager.GetLogger(name);
history = new List<string>();
}
public System.Windows.Forms.TextBox LogBox { set; get; }
......@@ -36,15 +40,25 @@ namespace Model
public void UI_Display(string s)
{
if (LogBox == null) return;
string text = string.Format("[{0:HH:mm:ss}] {1}\r\n", DateTime.Now, s);
string text = string.Format("[{0:HH:mm:ss}] {1}", DateTime.Now, s);
if (history.Count >= MAX_LINES)
history.RemoveAt(0);
history.Add(text);
LogBox.Invoke(new Action(() =>
{
LogBox.AppendText(text);
LogBox.Text = string.Join("\r\n", history);
LogBox.ScrollToCaret();
}));
}
public void UI_Clear()
{
if (LogBox == null) return;
history.Clear();
LogBox.Invoke(new Action(() => { LogBox.Text = ""; }));
}
}
}
......@@ -9,4 +9,3 @@ D:\Neotel\AGVControl_Elevator\Model\obj\Debug\Model.csproj.CopyComplete
D:\Neotel\AGVControl_Elevator\Model\obj\Debug\Model.dll
D:\Neotel\AGVControl_Elevator\Model\obj\Debug\Model.pdb
D:\Neotel\AGVControl_Elevator\Model\bin\Debug\log4net.config
D:\Neotel\AGVControl_Elevator\Model\obj\Debug\Model.csprojAssemblyReference.cache
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!