#
luxiaotao1123
2022-07-05 4bd338d1b8a81061c279ba718db5fa0420272a97
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
61
62
63
64
65
66
67
68
69
70
71
72
73
import {InitPallet, InitGoods} from './StoreGoods.js';
 
// 输送线当前运行状态对象
function StaTask(staData, object) {
    let that = this;
 
    that.object = object;
 
    that.no = 0;
    that.objectType = null;
    that.isDel = false;
    that.readyIn = false;
    that.run = false;
    that.loaded = 0;
    that.wrkNo = null;
 
    that.inlet = -1;
    that.outlet = -1;
 
    that.position = null;
 
    let init = function () {
        that.no = staData.no;
        that.inlet = staData.inlet;
        that.outlet = staData.outlet;
 
        let item = getArrVal(conveyObjects.objects, "no", that.no+"");
        if (!that.position && item) {
            that.objectType = item.objectType;
            that.position = item.position;
        }
        if (!item) {
            that.isDel = true;
        }
    }
    init();
 
    that.modify = function (staData) {
        if (that.no === 0) {
            return;
        }
 
        // 添加
        if (staData.loaded === 1 && staData.wrkNo && staData.wrkNo !== '0' && that.wrkNo !== staData.wrkNo) {
            if (that.outlet !== 1) {     // 由堆垛机出库,不需要添加model
                if (that.loaded === 1) {
                    console.log("sta_" + that.no + " remove:" + that.wrkNo + "-Pallet; " + that.wrkNo + "-Goods");
                    that.object.removeObject(that.wrkNo + "-Pallet");
                    that.object.removeObject(that.wrkNo + "-Goods");
                }
 
                InitPallet(that.object, [{wrkNo: staData.wrkNo}], {position: that.position, objectType: that.objectType}, 2);
                InitGoods(that.object, [{wrkNo: staData.wrkNo}], {position: that.position, objectType: that.objectType}, 2);
            }
        }
 
        // 移除
        if (staData.loaded === 0) {
            if (that.loaded === 1 && that.wrkNo && that.wrkNo !== '0') {
                if (that.inlet !== 1) {     // 堆垛机需要搬运,不能直接移除
                    that.object.removeObject(that.wrkNo + "-Pallet");
                    that.object.removeObject(that.wrkNo + "-Goods");
                }
            }
        }
 
        that.loaded = staData.loaded;
        that.wrkNo = staData.wrkNo;
    }
 
}
 
export {StaTask}