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    7x 7x 7x     13x 13x 13x     608x     34x     642x   38x 3x   35x   4x     4x   15x 3x   12x   16x 3x   13x   435x 3x   432x   134x 3x   131x       16x                   16x     16x     7x  
"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;