//ConcurrentDictionary<int, TaskServer> test = new();
IConveyer conveyer = new Conveyer();
private readonly ILogService logService;
private GlobalData global;
RecipeData currentRecipe;
//RecipeData currentRecipe;
CancellationTokenSource cts;
//CancellationTokenSource cts;
Task runTask;
//Task runTask;
public async void Inital()
{
Json<ConnectConfig>.Read();
if (Json<ConnectConfig>.Data.BatcherConfigs.Count==0)
{
InitBatcherConfig();
Json<ConnectConfig>.Save();
}
if (Json<ConnectConfig>.Data.ConveyerConfigs.Count == 0)
{
InitConveyerConfig();
Json<ConnectConfig>.Save();
}
#region 实例初始化配料机
batchers.TryAdd(1, new Batcher());
batchers.TryAdd(2, new Batcher());
batchers.TryAdd(4, new Batcher());
batchers.TryAdd(5, new Batcher());
//SetBatcherComm(1, "192.168.6.100");
//SetBatcherComm(2, "192.168.6.101");
//SetBatcherComm(4, "192.168.6.102");
//SetBatcherComm(5, "192.168.6.103");
SetBatcherComm(1, "192.168.6.100");
SetBatcherComm(2, "192.168.6.101");
SetBatcherComm(4, "192.168.6.102");
SetBatcherComm(5, "192.168.6.103");
SetBatcherComm(1, "127.0.0.1", 503);
SetBatcherComm(2, "127.0.0.1", 504);
SetBatcherComm(4, "127.0.0.1", 505);
SetBatcherComm(5, "127.0.0.1", 506);
//SetBatcherComm(1, "127.0.0.1", 503);
//SetBatcherComm(2, "127.0.0.1", 504);
//SetBatcherComm(4, "127.0.0.1", 505);
//SetBatcherComm(5, "127.0.0.1", 506);
foreach (var batcher in batchers.Values)
{
await batcher.Initial();
}
#endregion
//conveyer.SetCommParam(1, "192.168.6.104");
conveyer.SetCommParam(1, "127.0.0.1",510);
conveyer.SetCommParam(1, "192.168.6.104",508);
//conveyer.SetCommParam(1, "127.0.0.1",510);
await conveyer.Initial();
//currentTask.Clear();
currentTask.Clear();
ActionRegister();
TaskManage.GetInstance.StartLong(() =>
{
if (global.RecipeQueue.Count>0 && currentRecipe is null )
InterActive();
for (int i = 0; i < currentTask.Count; i++)
{
if (currentTask[i].CurrentRecipe.IsMakeComplete.All(b=>b==true))
{
currentTask.RemoveAt(i);
break;
}
}
if (global.RecipeQueue.Count>0/* && currentRecipe is null*/ )
{
//多配方情况下,必须在工位1没有碗位置,才能进行下发,否则会与之前的配方冲突。
if (/*!conveyer.HaveVessel[0] &&*/ global.RecipeQueue.ElementAt(0) is not null && global.RecipeQueue.ElementAt(0) is RecipeData)
if (/*!conveyer.HaveVessel[0] &&*/ global.RecipeQueue.ElementAt(0) is not null && global.RecipeQueue.ElementAt(0) is RecipeData && currentTask.Count <5 )