using IoTClient; namespace WCS.Application; public static class PLCService { public static void OnChangeEvent(object sender, EventArgs e) { var mod = sender as WcsDeviceDto; Console.WriteLine("PLC值为" + mod.Value); switch (mod.Type) { case PLCTypeEnum.StackingMachine: if (mod.Value == 820) { //测试写入830 var result = mod.PLCUtil.SetPlcDBValue(mod.PosType.Value, mod.DbNumber, mod.PlcPos, "830"); //写入是否成功 if (result.IsSucceed) { } } else if (mod.Value == 840) { //测试批量读取 Dictionary listaddress = new Dictionary(); foreach (var modStation in mod.listStation) { listaddress.Add(modStation.PlcPos, modStation.PosType.Value); } var result = mod.PLCUtil.GetPlcBatchDBValue(listaddress); if (!result.IsSucceed) { if (result.Value.Count > 0)//有错误的也有成功的 { } } } else if (mod.Value == 860) { } break; case PLCTypeEnum.ConveyorLine: break; case PLCTypeEnum.AGV: break; case PLCTypeEnum.PalletMachine: break; default: break; } } }