All files / client agv-client.js

96.77% Statements 30/31
94.44% Branches 17/18
100% Functions 7/7
96.77% Lines 30/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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    25x 25x 25x     30x 30x 30x     1005x     60x     1065x   79x 4x   75x   6x     6x   27x 4x   23x   28x 4x   24x   684x 4x   680x   237x 4x   233x       35x                   35x     35x     25x  
"use strict";
/*! Copyright (c) 2021 Siemens AG. Licensed under the MIT License. */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgvClient = void 0;
const __1 = require("..");
class AgvClient extends __1.Client {
    constructor(agvId, options) {
        super(options);
        this.agvId = agvId;
        this.validateAgvId(agvId, false);
    }
    publish(topic, object, options) {
        return this.publishTopic(topic, this.agvId, object, options);
    }
    subscribe(topic, handler) {
        return this.subscribeTopic(topic, this.agvId, handler);
    }
    validateTopicDirection(topic, asInbound) {
        switch (topic) {
            case __1.Topic.Connection:
                if (asInbound) {
                    throw new TypeError("Inbound connection message not compatible with AgvClient");
                }
                break;
            case __1.Topic.Factsheet:
                Iif (asInbound) {
                    throw new TypeError("Inbound factsheet message not compatible with AgvClient");
                }
                break;
            case __1.Topic.InstantActions:
                if (!asInbound) {
                    throw new TypeError("Outbound instantActions message not compatible with AgvClient");
                }
                break;
            case __1.Topic.Order:
                if (!asInbound) {
                    throw new TypeError("Outbound order message not compatible with AgvClient");
                }
                break;
            case __1.Topic.State:
                if (asInbound) {
                    throw new TypeError("Inbound state message not compatible with AgvClient");
                }
                break;
            case __1.Topic.Visualization:
                if (asInbound) {
                    throw new TypeError("Inbound visualization message not compatible with AgvClient");
                }
                break;
        }
    }
    getLastWillTopic() {
        return {
            topic: __1.Topic.Connection,
            subject: this.agvId,
            object: {
                connectionState: __1.ConnectionState.Connectionbroken,
            },
            retainMessage: true,
        };
    }
    async onStarted() {
        await this.publish(__1.Topic.Connection, { connectionState: __1.ConnectionState.Online }, { retainMessage: true });
    }
    async onStopping() {
        await this.publish(__1.Topic.Connection, { connectionState: __1.ConnectionState.Offline }, { retainMessage: true });
    }
}
exports.AgvClient = AgvClient;