dev
liulb@mesnac.com 1 year ago
parent 3db26d6a0c
commit 7893a1f9b5

@ -36,15 +36,12 @@ namespace Aucma.Core.OldBoxFoam.Business
{
try
{
///Task.Run(() =>
//{
// Thread.Sleep(3000);
Thread.Sleep(3000);
plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
plc2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
plc3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
plc4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4"));
//while (true)
//{
BoxTypeList.Clear();
HolderStatusList.Clear();
HolderOutPutList.Clear();
@ -84,29 +81,41 @@ namespace Aucma.Core.OldBoxFoam.Business
ReadStoreAmount(plc4, StoreAmountList);
for (int i = 0; i < 24; i++)
{
//if (listFixtureStatus.Count > 0)
//{
FixtureStatus model = new FixtureStatus();
model.ObjId = i + 1;
if (BoxTypeList.Count > 0) model.FixtureBoxType = BoxTypeList[i].ToString();
if (HolderStatusList.Count > 0) model.Status = HolderStatusList[i];
if (HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i];
if (SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i];
listFixtureStatus.Add(model);
//}
//else
//{
// FixtureStatus model = new FixtureStatus();
// model.ObjId = i + 1;
// if (BoxTypeList.Count > 0) model.FixtureBoxType = BoxTypeList[i].ToString();
// if (HolderStatusList.Count > 0) model.Status = HolderStatusList[i];
// if (HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i];
// if (SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i];
// listFixtureStatus.Add(model);
//}
FixtureStatus model = new FixtureStatus();
model.ObjId = i + 1;
if (BoxTypeList.Count > 0&& BoxTypeList!=null)
{
model.FixtureBoxType = BoxTypeList[i].ToString();
}
else
{
model.FixtureBoxType = "";
}
if (HolderStatusList.Count > 0 && HolderStatusList != null)
{
model.Status = HolderStatusList[i];
}
else
{
model.Status = HolderStatusList[i];
}
if (HolderOutPutList.Count > 0 && HolderOutPutList != null)
{
model.Yield = HolderOutPutList[i];
}
else
{
model.Yield = 0;
}
if (SolidifyTimeList.Count > 0 && HolderOutPutList != null)
{
model.PlanCuringTime = SolidifyTimeList[i];
}
else
{
model.PlanCuringTime = 0;
}
listFixtureStatus.Add(model);
}
for (int i = 0; i < 8; i++)
{
@ -116,9 +125,6 @@ namespace Aucma.Core.OldBoxFoam.Business
if (StoreAmountList.Count > 0) model.StoreAmount = Convert.ToInt32(StoreAmountList[i]);
spaceDetailModel.Add(model);
}
// Thread.Sleep(10000);
//}
//});
}catch(Exception ex)
{
Console.WriteLine(ex.Message);

@ -16,16 +16,11 @@ namespace Aucma.Core.RunPlc
#region 构造函数
public RunPlcService()
{
Task.Run(async () =>
{
await StartMelsecMcPlcServer();//三菱PLC
await StartSiemensPlcServer();//西门子
});
StartMelsecMcPlcServer();
StartSiemensPlcServer();
}
#endregion
#region 心跳
public Task StartPlcAsync()
{
@ -42,30 +37,30 @@ namespace Aucma.Core.RunPlc
return Task.CompletedTask;
}
private static Task StartMelsecMcPlcServer()
private static void StartMelsecMcPlcServer()
{
var allPlcServices = Appsettings.app<PlcModel>("PLCServer").ToList();
if (allPlcServices == null) return Task.CompletedTask;
if (allPlcServices == null) return ;
var list = allPlcServices.FindAll(d => d.PlcType == "Melsec" && d.Enabled == true);
foreach (var item in list)
for (int i = 1; i <= list.Count; i++)
{
PlcModel model = new PlcModel();
model.Id = item.Id;
model.EquipName = item.EquipName;
model.IP = item.IP;
model.Port = item.Port;
model.PlcType = item.PlcType;
model.plc = new MelsecPlc(item.IP, item.Port);
model.Id = list[i-1].Id;
model.EquipName = list[i - 1].EquipName;
model.IP = list[i - 1].IP;
model.Port = list[i - 1].Port;
model.PlcType = list[i - 1].PlcType;
model.plc = new MelsecPlc(list[i - 1].IP, list[i - 1].Port);
PlcHelper.melsecList.Add(model);
}
return Task.CompletedTask;
// return Task.CompletedTask;
}
private static Task StartSiemensPlcServer()
private static void StartSiemensPlcServer()
{
List<PlcModel> allPlcServices = Appsettings.app<PlcModel>("PLCServer").ToList();
if (allPlcServices == null) return Task.CompletedTask;
if (allPlcServices == null) return ;
var list = allPlcServices.FindAll(d => d.PlcType=="Siemens" && d.Enabled == true);
foreach (var item in list)
@ -79,7 +74,7 @@ namespace Aucma.Core.RunPlc
model.plc = new SiemensPlc(item.IP, item.Port);
PlcHelper.siemensList.Add(model);
}
return Task.CompletedTask;
}
#endregion

Loading…
Cancel
Save