hwh
2024-08-22 a8029953301875e30b4dfcfc599a6fb4ebcd0c0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
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<string, PLCDataTypeEnum> listaddress = new Dictionary<string, PLCDataTypeEnum>();
                    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;
        }
    }
 
}