Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+834
@@ -0,0 +1,834 @@
|
||||
'use strict';
|
||||
|
||||
var exampleSocket;
|
||||
var SelBranchVal = "";
|
||||
var connectedToServer = false;
|
||||
var assetType = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]; // Todo Eintraege beim fuellen erstellen.
|
||||
var buildingsArr = [];
|
||||
var assetsArrBsm = [];
|
||||
var assetsArrBcu = [];
|
||||
var assetsArrIpsIn = [];
|
||||
var assetsArrIpsOut = [];
|
||||
var assetsArrCameraIn = [];
|
||||
var assetsArrCameraOut = [];
|
||||
var assetsArrMdu = [];
|
||||
var assetsArrEgcu = [];
|
||||
var assetsArrAnnouncements = [];
|
||||
var assetsArrBuildingNetworkSwitch = [];
|
||||
var mountPointArr = [];
|
||||
var objectArr = [];
|
||||
var buildingId = -1;
|
||||
var tempType = 1;
|
||||
|
||||
var collator = new Intl.Collator(undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base"
|
||||
});
|
||||
function sortEntries(a, b)
|
||||
{
|
||||
return collator.compare(a.designation, b.designation);
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
WebSocketTest();
|
||||
}
|
||||
|
||||
function debug() {
|
||||
console.log("BSMAssets: " + assetsArrBsm);
|
||||
console.log("BCUAssets: " + assetsArrBcu);
|
||||
console.log("IpsInAssets; " + assetsArrIpsIn);
|
||||
console.log("IpsOutAssets: " + assetsArrIpsOut);
|
||||
console.log("CameraInAssets: " + assetsArrCameraIn);
|
||||
console.log("CameraOutAssets: " + assetsArrCameraOut);
|
||||
console.log("MDUAssets: " + assetsArrMdu);
|
||||
console.log("EGCUAssets: " + assetsArrEgcu);
|
||||
console.log("AnnouncementAssets: " + assetsArrAnnouncements);
|
||||
console.log("BuildingNetworkSwitch: " + assetsArrBuildingNetworkSwitch);
|
||||
console.log("Buildings: " + buildingsArr);
|
||||
}
|
||||
|
||||
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"
|
||||
sendGetEssentials();//sendet Anfrage erhält obj mit arrays der Essentials
|
||||
document.getElementById('selectAsset').value = 1;
|
||||
};
|
||||
//wird immer aufgerufen wenn der Socket eine Nachricht vom Server empfängt
|
||||
exampleSocket.onmessage = function (event) {
|
||||
var msg = JSON.parse(event.data);
|
||||
console.log (JSON.stringify(msg));
|
||||
console.log (JSON.stringify(event));
|
||||
switch (msg.type) {
|
||||
case "essentials":
|
||||
objectArr = []
|
||||
buildingsArr = []
|
||||
msg.data.objects.forEach(element => {
|
||||
var bg = {
|
||||
designation: element.designation,
|
||||
id: element.id
|
||||
};
|
||||
objectArr.push(bg);
|
||||
buildingsArr.push(element.designation);
|
||||
});
|
||||
createBuildingsHtml();
|
||||
|
||||
var html = ""
|
||||
msg.data.areas.forEach(element => {
|
||||
html += JSON.stringify(element) + "<br>"
|
||||
});
|
||||
document.getElementById("area").innerHTML = html;
|
||||
|
||||
html = ""
|
||||
msg.data.trainingAreas.forEach(element => {
|
||||
html += JSON.stringify(element) + "<br>"
|
||||
});
|
||||
document.getElementById("trainingArea").innerHTML = html;
|
||||
|
||||
handleMountingPoint(msg.data.mountingPoints);
|
||||
//console.log("essentials finish");
|
||||
break;
|
||||
case "assets":
|
||||
console.log("msg=");
|
||||
console.log(msg);
|
||||
handleAssets(msg);
|
||||
break;
|
||||
case "assetStateObject":
|
||||
html = JSON.stringify(msg) + "<br>"
|
||||
document.getElementById("assetStateObject").innerHTML = html;
|
||||
handleAssetStateObject(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
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 update() {
|
||||
switch (tempType)
|
||||
{
|
||||
case 1: updateBsm(); break;
|
||||
case 2: updateBcu(); break;
|
||||
case 3: updateCameraOut(); break;
|
||||
case 4: updateCameraIn(); break;
|
||||
case 5: updateIpsOut(); break;
|
||||
case 6: updateIpsIn(); break;
|
||||
case 7: updateMdu(); break;
|
||||
case 10: updateAnnouncement(); break;
|
||||
case 12: updateEgcu(); break;
|
||||
case 14: updateBuildingNetworkSwitch(); break;
|
||||
}
|
||||
}
|
||||
|
||||
function checkedBuilding(rObj) {
|
||||
//array der radiobuttons abfragen
|
||||
clearAssetArrays();
|
||||
setBuilding(rObj.value);
|
||||
return false;
|
||||
}
|
||||
|
||||
function findIdByDesignation(arr, designation)
|
||||
{
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (designation == arr[i].designation) {
|
||||
return arr[i].id;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
async function setBuilding(building) {
|
||||
buildingId = findIdByDesignation(objectArr, building);
|
||||
document.getElementById("BuildingTable").innerHTML = building;
|
||||
sendGetAssets();//schickt anfragen an den Server
|
||||
sendGetEssentials();
|
||||
sendGetBuildingState();
|
||||
show('mountAssets');
|
||||
}
|
||||
|
||||
function sendMountAssets(MountingPoints, Assets) {
|
||||
var mountPoint = document.querySelector('input[name="mp"]:checked').value;
|
||||
//console.log("Asset="+document.querySelector('input[name="ASSET"]:checked').value);
|
||||
var asset = document.querySelector('input[name="ASSET"]:checked').value;
|
||||
var mountPointId = findIdByDesignation(mountPointArr, mountPoint);
|
||||
var assetId = findIdByDesignation(assetsArrBsm, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrBcu, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrIpsIn, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrIpsOut, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrCameraIn, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrCameraOut, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrMdu, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrAnnouncements, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrEgcu, asset);
|
||||
if (assetId < 0)
|
||||
assetId = findIdByDesignation(assetsArrBuildingNetworkSwitch, asset);
|
||||
if ((mountPointId > 0) && (assetId > 0)) {
|
||||
var message = JSON.stringify({
|
||||
type: "mount",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
mountingPointId: mountPointId,
|
||||
assetId: assetId
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
console.log(message);
|
||||
exampleSocket.send(message);
|
||||
sendGetEssentials();
|
||||
sendGetBuildingState();
|
||||
sendGetAssets();
|
||||
document.querySelector('#rbMountPointsBsm').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsBcu').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsIpsIn').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsIpsOut').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsCameraIn').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsCameraOut').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsMdu').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsAnnouncement').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsEgcu').innerHTML = "";
|
||||
document.querySelector('#rbMountPointsBuildingNetworkSwitch').innerHTML = "";
|
||||
}
|
||||
|
||||
function sendMount() {
|
||||
var mountingPointId = String(mount_mountingPointId.value);
|
||||
var assetId = String(mount_assetId.value);
|
||||
|
||||
if (mountingPointId.length == 0)
|
||||
mountingPointId = null;
|
||||
else
|
||||
mountingPointId = Number(mountingPointId);
|
||||
|
||||
if (assetId.length == 0)
|
||||
assetId = null;
|
||||
else
|
||||
assetId = Number(assetId);
|
||||
|
||||
message = JSON.stringify({
|
||||
type: "mount",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
mountingPointId: mountingPointId,
|
||||
assetId: assetId
|
||||
}
|
||||
});
|
||||
exampleSocket.send(message);
|
||||
sendGetAssets();
|
||||
sendGetBuildingState();
|
||||
sendGetEssentials();
|
||||
}
|
||||
|
||||
function mountingHackForBldg56Ref() {
|
||||
var messages = ['{"type":"mount","uuid":"UUID","data":{"mountingPointId":36,"assetId":10}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":40,"assetId":11}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":45,"assetId":12}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":53,"assetId":13}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":31,"assetId":31}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":56,"assetId":32}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":51,"assetId":33}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":64,"assetId":34}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":88,"assetId":35}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":83,"assetId":36}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":54,"assetId":23}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":61,"assetId":24}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":46,"assetId":25}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":34,"assetId":22}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":67,"assetId":29}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":92,"assetId":26}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":85,"assetId":27}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":77,"assetId":21}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":89,"assetId":28}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":18,"assetId":50}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":19,"assetId":51}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":20,"assetId":52}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":21,"assetId":53}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":22,"assetId":54}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":23,"assetId":55}}',
|
||||
'{"type":"mount","uuid":"UUID","data":{"mountingPointId":27,"assetId":41}}'];
|
||||
|
||||
function sendMessage(message) {
|
||||
exampleSocket.send(message);
|
||||
}
|
||||
messages.forEach(sendMessage);
|
||||
}
|
||||
|
||||
function sendMountTag() {
|
||||
//console.log("sendMountTag ");
|
||||
|
||||
var mountingPointTag = String(mountTag_mountingPointTag.value);
|
||||
//console.log(mountTag_mountingPointTag.value);
|
||||
if (mountingPointTag.length == 0)
|
||||
mountingPointTag = null;
|
||||
|
||||
var assetTag = String(mountTag_assetTag.value);
|
||||
if (assetTag.length == 0)
|
||||
assetTag = null;
|
||||
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "mountTag",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
mountingPointTag: mountingPointTag,
|
||||
assetTag: assetTag
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendUnmountAsset() {
|
||||
//console.log("sendUnmountAsset ");
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "unmountAsset",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
assetId: Number(unmountAsset_assetId.value)
|
||||
}
|
||||
}));
|
||||
sendGetEssentials();
|
||||
sendGetBuildingState();
|
||||
sendGetAssets();
|
||||
}
|
||||
|
||||
function sendUnmountMountingPoint() {
|
||||
//console.log("sendUnmountMountingPoint ");
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "unmountMountingPoint",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
mountingPointId: Number(unmountMountingPoint_mountingPointId.value)
|
||||
}
|
||||
}));
|
||||
sendGetEssentials();
|
||||
sendGetBuildingState();
|
||||
sendGetAssets();
|
||||
}
|
||||
//---------noch nicht funktionsfähig/getestet----------//
|
||||
function sendUnmountObject() {
|
||||
//console.log("sendUnmountObject ");js/infrastructure.js:219
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "unmountObject",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
objectId: Number(unmountObject_objectId.value)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendUnmountArea() {
|
||||
//console.log("sendUnmountArea ");
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "unmountArea",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
areaId: Number(unmountArea_areaId.value)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendObjectMountingReady() {
|
||||
//console.log("sendObjectMountingReady ");
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "objectMountingReady",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
plannedMountingId: Number(objectMountingReady_plannedMountingId.value),
|
||||
objectId: Number(objectMountingReady_objectId.value)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendGetAssetState() {
|
||||
var assetTag = String(getAssetState_assetTag.value);
|
||||
if (assetTag.length == 0)
|
||||
assetTag = null;
|
||||
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "getAssetState",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
assetId: Number(getAssetState_assetId.value),
|
||||
assetTag: assetTag
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendGetBuildingStateManually() {
|
||||
//console.log("sendGetBuildingState ");
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "getBuildingState",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
buildingId: Number(getBuildingState_buildingId.value)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function sendGetBuildingState() {
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "getBuildingState",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
buildingId: buildingId
|
||||
}
|
||||
}));
|
||||
}
|
||||
//--------------------------------------------------------//
|
||||
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, 14]
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
function sendGetEssentials() {
|
||||
|
||||
mountPointArr = [];
|
||||
initMountingPointTable();
|
||||
|
||||
document.getElementById("area").innerHTML = "";
|
||||
document.getElementById("assetState").innerHTML = "";
|
||||
document.getElementById("assetStateObject").innerHTML = "";
|
||||
document.getElementById("assetType").innerHTML = "";
|
||||
document.getElementById("error").innerHTML = "";
|
||||
document.getElementById("level").innerHTML = "";
|
||||
document.getElementById("mountingPoint").innerHTML = "";
|
||||
document.getElementById("object").innerHTML = "";
|
||||
document.getElementById("objectMounting").innerHTML = "";
|
||||
document.getElementById("ok").innerHTML = "";
|
||||
document.getElementById("plannedMounting").innerHTML = "";
|
||||
document.getElementById("room").innerHTML = "";
|
||||
document.getElementById("trainingArea").innerHTML = "";
|
||||
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "getEssentials",
|
||||
uuid: "UUID"
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
async function sendUnmountAssetById(id) {
|
||||
exampleSocket.send(JSON.stringify({
|
||||
type: "unmountAsset",
|
||||
uuid: "UUID",
|
||||
data: {
|
||||
assetId: id
|
||||
}
|
||||
}));
|
||||
sendGetEssentials();
|
||||
sendGetBuildingState();
|
||||
sendGetAssets();
|
||||
}
|
||||
|
||||
|
||||
function handleAssetStateObject(msg) {
|
||||
var table = "";
|
||||
var assetDesignator = "";
|
||||
var mountPointDesignation = "";
|
||||
table += "<tr><th>assetId</th>";
|
||||
table += "<th>assetTypeId</th>";
|
||||
// table += "<th>assetType</th>";
|
||||
table += "<th>ipAddr</th>";
|
||||
table += "<th>mountingPointId</th>";
|
||||
table += "<th>state</th>";
|
||||
table += "<th>unmount</th></tr>";
|
||||
|
||||
// no assetsArrBcu - they are internal and must not be unmounted
|
||||
const items = [assetsArrBsm, assetsArrIpsIn, assetsArrIpsOut,
|
||||
assetsArrCameraIn, assetsArrCameraOut, assetsArrMdu, assetsArrEgcu, assetsArrBuildingNetworkSwitch];
|
||||
|
||||
msg.data.assetStates.forEach(asset => {
|
||||
var assetIdToSearchFor = asset.assetId;
|
||||
|
||||
var assetDesignator = null;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var searchedAsset = items[i].find(entry => {
|
||||
return (entry.id == assetIdToSearchFor);
|
||||
});
|
||||
if (searchedAsset)
|
||||
{
|
||||
assetDesignator = searchedAsset.designation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetDesignator) {
|
||||
table += "<tr>";
|
||||
table += "<td>" + assetDesignator;
|
||||
table += " (" + asset.assetId + ")</td>";
|
||||
table += "<td>" + asset.assetTypeId + "</td>";
|
||||
// table += "<td>" + assetType[asset.assetTypeId] + "</td>";
|
||||
table += "<td>" + asset.ipAddr + "</td>";
|
||||
for (var i = 0; i < mountPointArr.length; i++) {
|
||||
if (mountPointArr[i].id == asset.mountingPointId) {
|
||||
mountPointDesignation = mountPointArr[i].designation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
table += "<td>" + mountPointDesignation;
|
||||
table += " (" + asset.mountingPointId + ")</td>";
|
||||
table += "<td>" + asset.state + "</td>";
|
||||
var id = asset.assetId;
|
||||
table += "<td><input type=\"button\" id=\"unmount\" value=\"unmount\" onclick=\"Javascript:sendUnmountAssetById(" + id + ")\"></td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
});
|
||||
document.querySelector('#AssetStateTable').innerHTML = table;
|
||||
}
|
||||
|
||||
// Assets: Speichern aller Assets
|
||||
function handleAssets(msg) {
|
||||
clearAssetArrays();
|
||||
document.querySelector('#rbAssetsBsm').innerHTML = "";
|
||||
document.querySelector('#rbAssetsBcu').innerHTML = "";
|
||||
document.querySelector('#rbAssetsCameraOut').innerHTML = "";
|
||||
document.querySelector('#rbAssetsCameraIn').innerHTML = "";
|
||||
document.querySelector('#rbAssetsIpsIn').innerHTML = "";
|
||||
document.querySelector('#rbAssetsIpsOut').innerHTML = "";
|
||||
document.querySelector('#rbAssetsMdu').innerHTML = "";
|
||||
document.querySelector('#rbAssetsAnnouncement').innerHTML = "";
|
||||
document.querySelector('#rbAssetsEgcu').innerHTML = "";
|
||||
document.querySelector('#rbAssetsBuildingNetworkSwitch').innerHTML = "";
|
||||
|
||||
msg.data.forEach(msg => {
|
||||
switch (msg.assetTypeId)
|
||||
{
|
||||
case 1: assetsArrBsm.push(msg);
|
||||
console.log("push assetsArrBsm");
|
||||
break;
|
||||
case 2: assetsArrBcu.push(msg); break;
|
||||
case 3: assetsArrCameraOut.push(msg); break;
|
||||
case 4: assetsArrCameraIn.push(msg); break;
|
||||
case 5:
|
||||
case 6: assetsArrIpsIn.push(msg);
|
||||
assetsArrIpsOut.push(msg); break;
|
||||
case 7: assetsArrMdu.push(msg); break;
|
||||
case 10: assetsArrAnnouncements.push(msg); break;
|
||||
case 12: assetsArrEgcu.push(msg); break;
|
||||
case 14: assetsArrBuildingNetworkSwitch.push(msg);
|
||||
console.log("push assetsArrBuildingNetworkSwitch");
|
||||
break;
|
||||
default: console.log("Unknown assetTypeId: " + msg);
|
||||
}
|
||||
});
|
||||
update();
|
||||
}
|
||||
function clearAssetArrays() {
|
||||
assetsArrBsm = [];
|
||||
assetsArrBcu = [];
|
||||
assetsArrIpsIn = [];
|
||||
assetsArrIpsOut = [];
|
||||
assetsArrCameraIn = [];
|
||||
assetsArrCameraOut = [];
|
||||
assetsArrMdu = [];
|
||||
assetsArrEgcu = [];
|
||||
assetsArrAnnouncements = [];
|
||||
assetsArrBuildingNetworkSwitch = [];
|
||||
}
|
||||
|
||||
function initMountingPointTable() {
|
||||
var table = "";
|
||||
table += "<tr><th>assetId</th>";
|
||||
table += "<th>designation</th>";
|
||||
table += "<th>id</th>";
|
||||
table += "<th>levelId</th>";
|
||||
table += "<th>objectId</th>";
|
||||
table += "<th>supportedAssetTypeIds</th>";
|
||||
table += "</tr>";
|
||||
|
||||
document.querySelector('#mountingPointTable').innerHTML = table;
|
||||
}
|
||||
|
||||
|
||||
function createRadioButtonHtml(arr, type)
|
||||
{
|
||||
function createHtml(entry)
|
||||
{
|
||||
return "<input type=\"radio\" name=\"mp\" value=\"" + entry.designation + "\"> " + entry.designation + "<br>";
|
||||
}
|
||||
var html = "";
|
||||
arr.sort(sortEntries);
|
||||
arr.forEach(entry => {
|
||||
if (entry.assetId < 0 && entry.supportedAssetTypeIds[0] == type) {
|
||||
html += createHtml(entry);
|
||||
}
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
function createRadioButtonAssetHtml(arr)
|
||||
{
|
||||
function createHtml(entry)
|
||||
{
|
||||
return "<input type=\"radio\" name=\"ASSET\" value=\"" + entry.designation + "\"> " + entry.designation + "<br>";
|
||||
}
|
||||
var html = "";
|
||||
arr.sort(sortEntries);
|
||||
arr.forEach(entry => {
|
||||
console.log(entry);
|
||||
//if (entry.state == "Unmounted") {
|
||||
if (entry.mountingPointId == -1) {
|
||||
html += createHtml(entry);
|
||||
}
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
// BSM's mounten
|
||||
// Radio-Buttons zur Auswahl von BSM's und Assets
|
||||
function updateBsm() {
|
||||
document.querySelector('#rbMountPointsBsm').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 1); // Only BSM
|
||||
document.querySelector('#rbAssetsBsm').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrBsm);
|
||||
}
|
||||
|
||||
// BCU's mounten
|
||||
// Radio-Buttons zur Auswahl von BCU's und Assets
|
||||
function updateBcu() {
|
||||
console.log("updateBcu");
|
||||
console.log(assetsArrBcu.length);
|
||||
|
||||
document.querySelector('#rbMountPointsBcu').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 2); // Only BCU
|
||||
document.querySelector('#rbAssetsBcu').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrBcu);
|
||||
}
|
||||
|
||||
|
||||
// Radio-Buttons zur Auswahl von IPS's und Assets
|
||||
function updateIpsIn() {
|
||||
document.querySelector('#rbMountPointsIpsIn').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 6); // Only IPS In
|
||||
document.querySelector('#rbAssetsIpsIn').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrIpsIn);
|
||||
}
|
||||
|
||||
// Radio-Buttons zur Auswahl von IPS's und Assets
|
||||
function updateIpsOut() {
|
||||
document.querySelector('#rbMountPointsIpsOut').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 5); // Only IPS Out
|
||||
document.querySelector('#rbAssetsIpsOut').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrIpsOut);
|
||||
}
|
||||
|
||||
|
||||
// Radio-Buttons zur Auswahl von Indoor Cameras und Assets
|
||||
function updateCameraIn() {
|
||||
document.querySelector('#rbMountPointsCameraIn').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 4); // Only Camera In
|
||||
document.querySelector('#rbAssetsCameraIn').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrCameraIn);
|
||||
}
|
||||
|
||||
|
||||
// Radio-Buttons zur Auswahl von Outdoor Cameras und Assets
|
||||
function updateCameraOut() {
|
||||
document.querySelector('#rbMountPointsCameraOut').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 3); // Only Camera Out
|
||||
document.querySelector('#rbAssetsCameraOut').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrCameraOut);
|
||||
}
|
||||
|
||||
// Radio-Buttons zur Auswahl von Indoor Cameras und Assets
|
||||
function updateMdu() {
|
||||
document.querySelector('#rbMountPointsMdu').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 7); // Only Meteo Data Unit
|
||||
document.querySelector('#rbAssetsMdu').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrMdu);
|
||||
}
|
||||
|
||||
// Radio-Buttons zur Auswahl von EGCU's
|
||||
function updateEgcu() {
|
||||
document.querySelector('#rbMountPointsEgcu').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 12); // Only EGCU
|
||||
document.querySelector('#rbAssetsEgcu').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrEgcu);
|
||||
}
|
||||
|
||||
// Radio-Buttons zur Auswahl von AnnouncementUnits
|
||||
function updateAnnouncement() {
|
||||
document.querySelector('#rbMountPointsAnnouncement').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 10); // Only AnnouncementUnits
|
||||
document.querySelector('#rbAssetsAnnouncement').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrAnnouncements);
|
||||
}
|
||||
|
||||
// Radio-Buttons zur Auswahl von BuildingNetworkSwitch
|
||||
function updateBuildingNetworkSwitch() {
|
||||
console.log("updateBuildingNetworkSwitch");
|
||||
console.log(assetsArrBuildingNetworkSwitch.length);
|
||||
document.querySelector('#rbMountPointsBuildingNetworkSwitch').innerHTML
|
||||
= createRadioButtonHtml(mountPointArr, 14); // Only BuildingNetworkSwitch
|
||||
document.querySelector('#rbAssetsBuildingNetworkSwitch').innerHTML
|
||||
= createRadioButtonAssetHtml(assetsArrBuildingNetworkSwitch);
|
||||
}
|
||||
|
||||
function handleMountingPoint(msg) {
|
||||
|
||||
if (buildingId == -1)
|
||||
return;
|
||||
|
||||
mountPointArr = []
|
||||
msg.forEach(function(obj) {
|
||||
if (obj.objectId == buildingId) {
|
||||
var mp = {
|
||||
assetId: obj.assetId,
|
||||
designation: obj.designation,
|
||||
id: obj.id,
|
||||
levelId: obj.levelId,
|
||||
objectId: obj.objectId,
|
||||
supportedAssetTypeIds: obj.supportedAssetTypeIds
|
||||
};
|
||||
mountPointArr.push(mp);
|
||||
}
|
||||
});
|
||||
|
||||
mountPointArr.sort(sortEntries);
|
||||
|
||||
var header = "<tr>";
|
||||
header += "<th>assetId</th>";
|
||||
header += "<th>designation</th>";
|
||||
header += "<th>id</th>";
|
||||
header += "<th>levelId</th>";
|
||||
header += "<th>objectId</th>";
|
||||
header += "<th>supportedAssetTypeIds</th>";
|
||||
header += "</tr>";
|
||||
mountPointArr.forEach(function (entry) {
|
||||
header += "<tr>";
|
||||
header += "<td>" + entry.assetId + "</td>";
|
||||
header += "<td>" + entry.designation + "</td>";
|
||||
header += "<td>" + entry.id + "</td>";
|
||||
header += "<td>" + entry.levelId + "</td>";
|
||||
header += "<td>" + entry.objectId + "</td>";
|
||||
header += "<td>" + entry.supportedAssetTypeIds + "</td>";
|
||||
header += "</tr>";
|
||||
|
||||
});
|
||||
document.querySelector('#mountingPointTable').innerHTML = header;
|
||||
selectAssetType(tempType);
|
||||
}
|
||||
|
||||
function createBuildingsHtml() {
|
||||
buildingsArr.sort();
|
||||
|
||||
var rows = "";
|
||||
buildingsArr.forEach(building => {
|
||||
//console.log("buildingsArr[" + i + "]=" + buildingsArr[i] + " buildingCounter=" + buildingCounter);
|
||||
rows += "<input type=\"radio\" name=\"bg\" value=\"";
|
||||
rows += building;
|
||||
rows += "\" id= \"";
|
||||
rows += building;
|
||||
rows += "\"> ";
|
||||
rows += building;
|
||||
rows += "<br>";
|
||||
});
|
||||
document.getElementById("rbBuildings").innerHTML = rows
|
||||
}
|
||||
|
||||
function show(id) {
|
||||
if (document.getElementById) {
|
||||
var mydiv = document.getElementById(id);
|
||||
mydiv.style.display = "block";
|
||||
}
|
||||
}
|
||||
function toggle(id) {
|
||||
if (document.getElementById) {
|
||||
var mydiv = document.getElementById(id);
|
||||
mydiv.style.display = (mydiv.style.display == 'block' ? 'none' : 'block');
|
||||
}
|
||||
}
|
||||
|
||||
function selectAssetType(type) {
|
||||
type = Number(type);
|
||||
tempType = type;
|
||||
|
||||
document.getElementById('divBuildingSensorModule').style.display = 'none';
|
||||
document.getElementById('divBuildingControlUnit').style.display = 'none';
|
||||
document.getElementById('divOutdoorCamera').style.display = 'none';
|
||||
document.getElementById('divIndoorCamera').style.display = 'none';
|
||||
document.getElementById('divOutdoorIPS').style.display = 'none';
|
||||
document.getElementById('divIndoorIPS').style.display = 'none';
|
||||
document.getElementById('divAnnouncementUnit').style.display = 'none';
|
||||
document.getElementById('divMeteoDataUnit').style.display = 'none';
|
||||
document.getElementById('divEffectGenerationControlUnit').style.display = 'none';
|
||||
document.getElementById('divOutdoorControlUnit').style.display = 'none';
|
||||
document.getElementById('divBuildingNetworkSwitch').style.display = 'none';
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
document.getElementById('divBuildingSensorModule').style.display = 'block';
|
||||
break;
|
||||
case 2:
|
||||
document.getElementById('divBuildingControlUnit').style.display = 'block';
|
||||
break;
|
||||
case 3:
|
||||
document.getElementById('divOutdoorCamera').style.display = 'block';
|
||||
break;
|
||||
case 4:
|
||||
document.getElementById('divIndoorCamera').style.display = 'block';
|
||||
break;
|
||||
case 5:
|
||||
document.getElementById('divOutdoorIPS').style.display = 'block';
|
||||
break;
|
||||
case 6:
|
||||
document.getElementById('divIndoorIPS').style.display = 'block';
|
||||
break;
|
||||
case 7:
|
||||
document.getElementById('divMeteoDataUnit').style.display = 'block';
|
||||
break;
|
||||
case 10:
|
||||
document.getElementById('divAnnouncementUnit').style.display = 'block';
|
||||
break;
|
||||
case 12:
|
||||
document.getElementById('divEffectGenerationControlUnit').style.display = 'block';
|
||||
break;
|
||||
case 13:
|
||||
document.getElementById('divOutdoorControlUnit').style.display = 'block';
|
||||
break;
|
||||
case 14:
|
||||
document.getElementById('divBuildingNetworkSwitch').style.display = 'block';
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user