Files
qt5-legatus-legacy/Lts/Tools/EsriHTML/Websockets/js/websocket.js
T
2026-08-13 18:33:10 +02:00

201 lines
4.5 KiB
JavaScript
Executable File

var exampleSocket;
var firstMsg = true;
var textBoxArr = [];
var SelBranchVal = "";
var connectedToServer = false;
var msg;
window.onload = function () {
WebSocketTest();
}
function WebSocketTest() {
if ("WebSocket" in window) {
{
var ipadresse = document.getElementById("ipadresse").value;
exampleSocket = new WebSocket("ws://" + ipadresse);
connectedToServer = true;
}
exampleSocket.onopen = function () {
document.getElementById("Serverconnect").innerHTML = "Server: connected";
document.getElementById("Serverconnect").style.color = "green"
};
//wird immer aufgerufen wenn der Socket eine Nachricht vom Server empfängt
exampleSocket.onmessage = function (event) {
console.log(msg);
msg = JSON.parse(event.data);
document.getElementById("receivedMessages").innerHTML += JSON.stringify(msg);
document.getElementById("receivedMessages").innerHTML += "<br>";
};
exampleSocket.onclose = function () {
// websocket is closed.
document.getElementById("Serverconnect").innerHTML = "Server: not connected";
document.getElementById("Serverconnect").style.color = "grey";
// document.getElementById("Wlsconnect").innerHTML = "Wls: not connected";
document.getElementById("Wlsconnect").style.color = "red";
connectedToServer = false;
alert("Connection to Server closed.");
};
}
else {
// The browser doesn't support WebSocket
alert("WebSocket is NOT supported by your Browser!");
}
}
function sendGetEssentials() {
exampleSocket.send(JSON.stringify({
type: "getEssentials",
uuid: "UUID"
}));
}
function sendMountTags() {
exampleSocket.send(JSON.stringify({
type: "mountTag",
uuid: "UUID",
data: {
mountingPointTag : "BarcodeTag1",
assetTag: "BarcodeAsset1"
}
}));
exampleSocket.send(JSON.stringify({
type: "mountTag",
uuid: "UUID",
data: {
mountingPointTag : "BarcodeTag2",
assetTag: "BarcodeAsset2"
}
}));
}
function sendGetAssets() {
exampleSocket.send(JSON.stringify({
type: "getAssets",
uuid: "UUID"
}));
}
function sendGetPlannedMounting() {
exampleSocket.send(JSON.stringify({
type: "getPlannedMounting",
uuid: "UUID"
}));
}
function sendGetObjectMounting() {
exampleSocket.send(JSON.stringify({
type: "getObjectMounting",
uuid: "UUID"
}));
}
//--------------------------------------------------------//
function servicePortsInformationRequest() {
console.log("servicePortsInformationRequest");
exampleSocket.send(JSON.stringify({
type: "servicePortsInformationRequest",
uuid: "UUID"
}));
}
//--------------------------------------------------------//
function baseDlRequest() {
exampleSocket.send(JSON.stringify({
type: "baseDlRequest",
uuid: "UUID"
}));
}
function pdfListRequest() {
exampleSocket.send(JSON.stringify({
type: "pdfListRequest",
uuid: "UUID"
}));
}
//--------------------------------------------------------//
function sendGetAssets() {
//exampleSocket schickt eine Abfrage an den Server
//liefert das asset mit der TypId zurück
// BSM
exampleSocket.send(JSON.stringify({
type: "getAssets",
uuid: "UUID",
data: {
assetTypeId: [1, 2, 3, 4, 5, 6, 10, 12]
}
}));
}
function sendAvsEndEnd() {
console.log("sendAvsEndEnd");
exampleSocket.send(JSON.stringify({
endTime: 1641887329958,
eventTime: 1641887329958,
eventType: 10,
id: 72774090,
lastRangeClosed: true,
streamName: "av_0141"
}));
}
function sendAvsOpen() {
console.log("sendAvsOpen");
exampleSocket.send(JSON.stringify({
endTime: 1641887329958,
eventTime: 1641887329958,
eventType: 10,
id: 72774090,
lastRangeClosed: true,
streamName: "av_0141"
}));
}
function sendMountTags() {
exampleSocket.send(JSON.stringify({
type: "mountTag",
uuid: "UUID",
data: {
mountingPointTag: "se_barcode_1",
assetTag: "asset_barcode_1"
}
}));
exampleSocket.send(JSON.stringify({
type: "mountTag",
uuid: "UUID",
data: {
mountingPointTag: "se_barcode_2",
assetTag: "asset_barcode_2"
}
}));
}