This commit is contained in:
dev02 2023-01-04 18:38:44 +08:00
commit 3920174726
6 changed files with 474 additions and 1625 deletions

View File

@ -240,13 +240,7 @@
var tarElePath = ''; var tarElePath = '';
var sysSubList = []; var sysSubList = [];
var floList = []; //每個樓層
var subSeviceData = []; //每個設備訂閱點位值
var allEleDevList = [];
var viewer3DNodeIds = []; var viewer3DNodeIds = [];
var elev3DBind = {};
var elev3DOption = {};
var elev3DObj = [];
var timeOuters = []; var timeOuters = [];
var eveDayElecChart = null; var eveDayElecChart = null;
var eveWeekElecChart = null; var eveWeekElecChart = null;
@ -288,25 +282,25 @@
$(document).ready(function () { $(document).ready(function () {
show3DModel(); show3DModel();
getSubList(); getSubList();
getElevData();
getFirstEletric(); getFirstEletric();
subDeviceSetStatus();
timeOutGetData(); timeOutGetData();
}); });
function demoSubList() { function demoSubList() {
let isExiNames = $("#sysSubBtnList .dev-group button[id^=sysSubCardBtn]").toArray().map(x => $(x).text()); let isExiNames = $("#sysSubBtnList .dev-group button[id^=sysSubCardBtn]").toArray().map(x => $(x).text());
let strHtml = ``; let strHtml = ``;
$.each(tempSysSubText, (idx, obj) => { $.each(tempSysSubText, (idx, obj) => {
if (isExiNames.indexOf(obj.text) == -1) { if (isExiNames.indexOf(obj.text) == -1 && $("#sysSubBtnList .dev-group").length < 12) {
let iconObj = sysIconList.filter(x => x.mainSys == obj.mainSys && x.subSys == obj.subSys)[0]; let iconObj = sysIconList.filter(x => x.mainSys == obj.mainSys && x.subSys == obj.subSys)[0];
strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group"> strHtml = `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group">
<button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4"><i class="${iconObj.iconClass || "fal fa-hdd"} fa-2x py-2"></i></button> <button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4"><i class="${iconObj.iconClass || "fal fa-hdd"} fa-2x py-2"></i></button>
<button id="sysSubCardBtn${obj.subSys}" type="button" class="btn btn-secondary" data-id="${obj.subSys}">${obj.text}</button> <button id="sysSubCardBtn${obj.subSys}" type="button" class="btn btn-secondary" data-id="${obj.subSys}">${obj.text}</button>
</div>`; </div>`;
$("#sysSubBtnList").append(strHtml);
} }
}) })
$("#sysSubBtnList").append(strHtml);
} }
//取得 左下方 各系統小類 //取得 左下方 各系統小類
@ -386,10 +380,8 @@
let yesterday = displayDate(getTimeByType(null, -1), "date").replaceAll("/", "-") + "T00:00:00"; let yesterday = displayDate(getTimeByType(null, -1), "date").replaceAll("/", "-") + "T00:00:00";
let tomorrow = displayDate(getTimeByType(null, 1), "date").replaceAll("/", "-") + "T00:00:00"; let tomorrow = displayDate(getTimeByType(null, 1), "date").replaceAll("/", "-") + "T00:00:00";
// 今日用電量 // 今日用電量
getElectricMeterDayDataByBaja(devNum + "_kWh_tot", n4Sup, today, tomorrow, (data) => { getElectricMeterDayDataByBaja(devNum + "_KWH", n4Sup, today, tomorrow, (data) => {
let result = data?.data[0]?.sum; let result = data?.data[0]?.sum;
result = result ? parseFloat(result).toFixed(2) : 0; result = result ? parseFloat(result).toFixed(2) : 0;
$("#todayUseElec").text(result); $("#todayUseElec").text(result);
@ -397,7 +389,7 @@
}) })
// 今日用電量 (每小時) // 今日用電量 (每小時)
getElectricMeterHourDataByBaja(devNum + "_kWh_tot", n4Sup, yesterday, tomorrow, (data) => { getElectricMeterHourDataByBaja(devNum + "_KWH", n4Sup, yesterday, tomorrow, (data) => {
let todayData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year") && x.timestamp.$date.$month == getTimeByType("month") && x.timestamp.$date.$day == getTimeByType("date")); let todayData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year") && x.timestamp.$date.$month == getTimeByType("month") && x.timestamp.$date.$day == getTimeByType("date"));
let yesData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year", -1) && x.timestamp.$date.$month == getTimeByType("month", -1) && x.timestamp.$date.$day == getTimeByType("date", -1)); let yesData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year", -1) && x.timestamp.$date.$month == getTimeByType("month", -1) && x.timestamp.$date.$day == getTimeByType("date", -1));
@ -406,7 +398,7 @@
}) })
// 昨日用電量 // 昨日用電量
getElectricMeterDayDataByBaja(devNum + "_kWh_tot", n4Sup, yesterday, today, (data) => { getElectricMeterDayDataByBaja(devNum + "_KWH", n4Sup, yesterday, today, (data) => {
let result = data?.data[0]?.sum; let result = data?.data[0]?.sum;
result = result ? parseFloat(result).toFixed(2) : 0; result = result ? parseFloat(result).toFixed(2) : 0;
$("#yesUseElec").text(result); $("#yesUseElec").text(result);
@ -414,7 +406,7 @@
}) })
// 本週與上週用電量 (每天) // 本週與上週用電量 (每天)
getElectricMeterDayDataByBaja(devNum + "_kWh_tot", n4Sup, prevTwoWeek, tomorrow, (data) => { getElectricMeterDayDataByBaja(devNum + "_KWH", n4Sup, prevTwoWeek, tomorrow, (data) => {
let curDay = (new Date()).getDay() == 0 ? 7 : (new Date()).getDay(); let curDay = (new Date()).getDay() == 0 ? 7 : (new Date()).getDay();
let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr)); let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr));
let prevWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - 7 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr) && strToDate(new Date(), null, 0 - 7) >= strToDate(x.timestamp.$cEncStr)); let prevWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - 7 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr) && strToDate(new Date(), null, 0 - 7) >= strToDate(x.timestamp.$cEncStr));
@ -746,32 +738,6 @@
}) })
} }
// 取得電梯資料
function getElevData() {
let url = baseApiUrl + "/api/Device/GetDeviceList";
let sendData = {
sub_system_tag: "EL",
building_tag: pageAct.buiTag,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$.each(res.data, (index, floObj) => {
let masters = floObj.device_list.map(x => x.device_number?.split("_")[5]).Distinct();
$.each(masters, (idx, master) => {
floObj.device_list.filter(x => x.device_number?.split("_")[5] == master).forEach((devObj) => {
allEleDevList.push(devObj);
allEleDevList = allEleDevList.oSort("priority");
})
})
})
}
}, null, "POST").send();
}
//function timeOutGetData() { //function timeOutGetData() {
// let timeOut3s = setInterval(() => { // let timeOut3s = setInterval(() => {
// getAlarmSub(); // getAlarmSub();
@ -784,154 +750,23 @@
function show3DModel() { function show3DModel() {
launchViewerNoTools(pageAct.urn, (viewer) => { launchViewerNoTools(pageAct.urn, (viewer) => {
let nodeIds = allEleDevList.filter(x => !isNaN(parseInt(x.forge_dbid))).map(x => { return { devNum: x.device_number, nodeId: parseInt(x.forge_dbid) } }); let elevOption = {
selector: "#forgeViewer",
$.each(nodeIds, (idx, item) => {
elev3DBind[item.devNum] = item.nodeId;
})
nodeIds = nodeIds.map(x => x.nodeId);
$.each(nodeIds, function (idx, node) {
let options = {
element: $("#forgeViewer"),
viewer: viewer, viewer: viewer,
nodeId: node, ordPath: {
floorHeight: elev3DOption.floorHeight ?? [],
inited: function () {
}
}
let elevator3DObj = new elevator3D(options);
let devNum = Object.keys(elev3DBind).filter(x => elev3DBind[x] == node)[0];
let subData = subSeviceData.filter(x => x.device_number == devNum)[0];
if (elev3DObj.filter(x => x.nodeId == node).length == 0) {
elev3DObj.push({ id: devNum, nodeId: node, obj: elevator3DObj });
}
if (subData) {
let elevObj = elev3DObj.filter(x => x.nodeId == node)[0];
if (!elevObj.id) {
elevObj.id = devNum;
}
elevObj.obj = Object.assign(elevObj, elevator3DObj ?? {})
elevObj.obj.init(function () {
let frags = elevObj.obj.fragProxys.filter(x => x.nodeId == node);
frags.forEach((fragProxy) => {
fragProxy.frag.position.z = elev3DOption.floorHeight.filter(x => x.floor == subData["CP"])[0]?.height ?? 0;
fragProxy.frag.updateAnimTransform()
})
elevObj.obj.viewer.impl.sceneUpdated(true);
})
}
})
});
}
function subDeviceSetStatus() {
let subOrdPath = {
"area_tag": pageAct.AreaTag, "area_tag": pageAct.AreaTag,
"building_tag": pageAct.buiTag, "building_tag": pageAct.buiTag,
"system_tag": "ELEV", },
"name_tag": "EL",
};
myBaja = new subscriptionDevices();
myBaja.setSubscribeDevicesByBql(subOrdPath);
myBaja.setSubscribeDevicesCallBack(function (data) {
if (allEleDevList.length == 0) {
return false;
}
data.device_number = data.device_number_full;
let matchDevice = allEleDevList.filter(x => x.device_number == data.device_number)[0];
let master = matchDevice?.device_number.split("_")[5];
if (!matchDevice) {
return;
} }
if (data.point_name == "CP") { // 電梯移動訂閱程序載入
if (elev3DObj.length != 0) { let forge3DElev = new Forge3DElevFull(elevOption);
let elevObj = elev3DObj.filter(x => x.nodeId == elev3DBind[matchDevice.device_number])[0]; forge3DElev.bajaEndCallback = function () {
if (elevObj && elevObj.id) { endPageLoading();
elevObj.obj.setElevatorFloor(data.value)
elevObj.obj.movElevator();
} }
} forge3DElev.init();
}
//將訂閱值塞入 subSeviceData
if (subSeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) {
let obj = {};
obj.device_number = matchDevice.device_number;
subSeviceData.push(obj)
}
let subData = subSeviceData.filter(x => x.device_number == matchDevice.device_number)[0];
if (subData) {
subData[data.point_name] = data.value;
}
});
myBaja.setSubscribeDeviceEndCallBack(function (data) {
let devNumArr = data.map(x => { return { devNum: x.device_number_full, priority: allEleDevList.filter(y => y.device_number == x.device_number_full)[0]?.priority } }).DistinctBy("devNum");
devNumArr = devNumArr.oSort("priority");
$.each(devNumArr, (idx, devObj) => {
devNum = devObj.devNum;
let subData = subSeviceData.filter(x => x.device_number == devNum)[0];
if (subData) {
//// 左側 3D 電梯 nodeID 與 device_number match
//if (Object.keys(elev3DBind).indexOf(devNum) == -1 && viewer3DNodeIds.length != 0) {
// elev3DBind[devNum] = viewer3DNodeIds[Object.keys(elev3DBind).length];
//}
// 左側 3D 電梯 Viewer Option 設置
/*elev3DOption.nodes = Object.keys(elev3DBind).map(x => elev3DBind[x]);*/
floList = Object.keys(subData).filter(x => x.startsWith("SP_FLS_")).map(x => x?.split("SP_FLS_")[1]);
elev3DOption.nodeId = elev3DBind[devNum];
elev3DOption.floorHeight = floList.map((x) => { return { floor: x } });
elev3DOption.floorHeight.forEach((floObj, idx) => {
if (floObj.floor.startsWith("B")) {
let floor = parseInt(floObj.floor.split("B")[1].split("F")[0]);
floObj.height = floor * -13;
} else {
let floor = parseInt(floObj.floor.split("F")[0]);
if (floor == 1) {
floObj.height = 0;
} else if (floor == 2) {
floObj.height = 14.75;
} else {
floObj.height = (14.75 + ((floor - 2) * 9.75));
}
}
})
if (elev3DObj.length != 0) {
let elevObj = elev3DObj.filter(x => x.nodeId == elev3DBind[devNum])[0];
if (!elevObj.id) {
elevObj.id = devNum;
}
elevObj.obj = Object.assign(elevObj.obj, elev3DOption);
elevObj.obj.init(function () {
let frags = elevObj.obj.fragProxys.filter(x => x.nodeId == elev3DBind[devNum]);
frags.forEach((fragProxy) => {
fragProxy.frag.position.z = elev3DOption.floorHeight.filter(x => x.floor == subData["CP"])[0]?.height ?? 0;
fragProxy.frag.updateAnimTransform();
})
elevObj.obj.viewer.impl.sceneUpdated(true);
}); });
} }
}
})
})
}
$(window).on("timeout:5m", function () { $(window).on("timeout:5m", function () {
console.log("五分鐘更新") console.log("五分鐘更新")

View File

@ -223,6 +223,22 @@ input:-webkit-autofill {
grid-template-columns: var(--c-grid-temp-col); grid-template-columns: var(--c-grid-temp-col);
} }
.vakata-context, .vakata-context ul { background-color: #3f3f3f; box-shadow: 2px 2px 2px #111111; }
.vakata-context li > a { color: white; text-shadow: 1px 1px 0 #4b4b4b; }
.vakata-context .vakata-context-hover > a { background-color: #666666; box-shadow: 0 0 2px #2f2f2f; }
.vakata-context li > a:hover { background-color: #636363; box-shadow: 0 0 2px #2f2f2f; }
.yt-left-navbar { position: fixed; left: 0; top: 0; height: 100%; z-index: 10; background-color: var(--theme-fusion-900); width: auto; max-width: 300px; margin-top: 4.125rem; }
.yt-navbar-content ul { padding: 1rem 0rem; list-style-type: none; }
.yt-navbar-content ul li { position: relative; display: flex; flex-wrap: wrap; }
.yt-navbar-content ul li a { font-size: 0.9rem; padding: 0.75rem 2rem; position: relative; width: 100%; }
.yt-navbar-content ul li a:hover { background-color: var(--theme-fusion-600); }
.yt-navbar-content ul li a:active, .yt-navbar-content ul li a.active { background-color: var(--theme-fusion-500); }
@media screen and (max-width: 576px){
.yt-left-navbar { width: 100%; max-width: 100%; margin-top: 0; }
}
@keyframes lds-ring { @keyframes lds-ring {
0% { 0% {
transform: rotate(0deg); transform: rotate(0deg);
@ -289,12 +305,8 @@ input:-webkit-autofill {
/* ================================================================ */ /* ================================================================ */
/* 單一方法 */ /* 單一方法 */
/* ================================================================ */ /* ================================================================ */
/* cursor */ /* cursor */
.cur-def { .cur-def { cursor: default !important; }
cursor: default !important;
}
.cur-poi { .cur-poi {
cursor: pointer !important; cursor: pointer !important;

File diff suppressed because it is too large Load Diff

View File

@ -83,7 +83,8 @@ function launchViewerForHotspot(urn, callback, _selector = "#forgeViewer") {
}); });
} }
function launchViewerNoTools(urn, callback) { function launchViewerNoTools(urn, callback, _selector = "#forgeViewer") {
selector = _selector;
var options = { var options = {
env: 'AutodeskProduction', env: 'AutodeskProduction',
getAccessToken: getForgeToken getAccessToken: getForgeToken
@ -330,9 +331,9 @@ function onDocumentLoadSuccess(doc, eleOption) {
let instanceTree = viewer.model.getData().instanceTree; let instanceTree = viewer.model.getData().instanceTree;
console.log(instanceTree.nodeAccess) console.log(instanceTree.nodeAccess)
allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
getNodeIdByDbIds("【電梯】", (nodeIds) => { /*getNodeIdByDbIds("【電梯】", (nodeIds) => {*/
$(selector).trigger("autodesk:loaded", nodeIds); $(selector).trigger("autodesk:loaded");
}); /*});*/
}); });
@ -494,6 +495,7 @@ function getAllDbIds(viewer) {
* Autodesk.Viewing.Document.load() failuire callback. * Autodesk.Viewing.Document.load() failuire callback.
*/ */
function onDocumentLoadFailure(viewerErrorCode) { function onDocumentLoadFailure(viewerErrorCode) {
$(selector).trigger("autodesk:loaded");
console.error("onDocumentLoadFailure() - errorCode:" + viewerErrorCode); console.error("onDocumentLoadFailure() - errorCode:" + viewerErrorCode);
} }
@ -671,7 +673,15 @@ function hideColor(nodeId) {//顏色改成透明
} }
//------------------ 紀錄熱點座標 ---------------
function getHopspotPoint(data) {
//var av = Autodesk.Viewing;
myDataList = data;
//viewer.addEventListener(av.GEOMETRY_LOADED_EVENT, addHotPoint, {
// once: true,
//});
}
//-------------------- end ----------------------
//------------------- 加入熱點 ----------------- //------------------- 加入熱點 -----------------
async function addHotPoint(data) { async function addHotPoint(data) {
@ -710,7 +720,7 @@ async function addHotPoint(data) {
myDataList.forEach((myData, index) => { myDataList.forEach((myData, index) => {
const dbId = 10 + index; const dbId = 10 + index;
const myPosition = JSON.parse(myData.device_coordinate_3d); const myPosition = myData.position;
const viewable = new DataVizCore.SpriteViewable(myPosition, style, dbId); const viewable = new DataVizCore.SpriteViewable(myPosition, style, dbId);
myData._dbId = dbId; myData._dbId = dbId;
viewableData.addViewable(viewable); viewableData.addViewable(viewable);
@ -726,6 +736,7 @@ async function addHotPoint(data) {
if (event != undefined && event != null) { if (event != undefined && event != null) {
if (event.dbId >= dbIdStart && event.dbId <= dbIdEnd) {//event.dbId > 0 && event.dbId < 19 if (event.dbId >= dbIdStart && event.dbId <= dbIdEnd) {//event.dbId > 0 && event.dbId < 19
console.log(`Sprite clicked: ${event.dbId}`); console.log(`Sprite clicked: ${event.dbId}`);
openHotspotModal();
for (let i = dbIdStart; i <= dbIdEnd; i++) { for (let i = dbIdStart; i <= dbIdEnd; i++) {
changeColorForHotspot(i, false); changeColorForHotspot(i, false);
changeScaleForHotspot(i, false); changeScaleForHotspot(i, false);
@ -752,6 +763,7 @@ async function addHotPoint(data) {
// if (dbIds.length > 0) { // if (dbIds.length > 0) {
// // 處理已選取元件的邏輯 // // 處理已選取元件的邏輯
// $(selector).trigger("autodesk:click:sprite", event); // $(selector).trigger("autodesk:click:sprite", event);
// //openHotspotModal();
// console.log(`------ name: ${viewer.model.getInstanceTree().getNodeName(dbIds)} , dbId: ${dbIds}`);//, id: ${event.clickInfo.object.id}, position.x: ${event.clickInfo.point.x}, y: ${event.clickInfo.point.y}, z: ${event.clickInfo.point.z} // console.log(`------ name: ${viewer.model.getInstanceTree().getNodeName(dbIds)} , dbId: ${dbIds}`);//, id: ${event.clickInfo.object.id}, position.x: ${event.clickInfo.point.x}, y: ${event.clickInfo.point.y}, z: ${event.clickInfo.point.z}
// } else { // } else {
// // 處理沒有選取元件的邏輯 // // 處理沒有選取元件的邏輯
@ -796,14 +808,49 @@ async function changeScaleForHotspot(dbId, type = true) {
//------------------- end -------------- //------------------- end --------------
//------------------------------ 熱圖 --------------------------------- //----------------- 開關熱點小視窗 ----------------------
async function loadHeatmaps(model, roomsArr) { function openHotspotModal() {
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization"); //var modal = document.getElementById("hotspotModal");
var devices = []; //modal.style.display = "block";
//$("#pills-register-tab").removeClass("active");
//$("#pills-alarm-tab").removeClass("active");
//$("#pills-operation-tab").removeClass("active");
//$("#pills-login-tab").tab("show");
}
myDataList.forEach((myData, index) => { function closeHotspotModal() {
devices.push({ id: index, position: JSON.parse(myData.device_coordinate_3d), sensorTypes: ["temperature", "humidity"] }); //var modal = document.getElementById("hotspotModal");
}); //modal.style.display = "none";
}
//------------------ end --------------------------------
//------------------ 熱圖 -------------------------------
async function loadHeatmaps(model) {
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
//取三個空調設備的位置打點
const devices = [
{
id: "Oficina 5",
//name: "Oficina-",
position: { x: 6.98, y: -19.00, z: 16.86 }, // x: 0, y: 25, z: -2.5 (-4.93, -20.61, 16.86)
sensorTypes: ["temperature", "humidity"]
},
{
id: "Oficina 4",
//name: "Oficina-",
position: { x: 35.85, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (23.94, -3.85, 16.86)
sensorTypes: ["temperature", "humidity"]
},
{
id: "Oficina 3",
//name: "Oficina-",
position: { x: 6.98, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (-4.93, -3.85, 16.86)
sensorTypes: ["temperature", "humidity"]
}
];
//冷氣N5: (-4.93, -20.61, 16.86), N4: (23.94, -3.85, 16.86), N3: (-4.93, -3.85, 16.86)
// Initialize sensor values // Initialize sensor values
let sensorVals = []; let sensorVals = [];
@ -812,9 +859,7 @@ async function loadHeatmaps(model, roomsArr) {
} }
const roomDbIds = []; const roomDbIds = [];
for (var i = 0; i < roomsArr.length; i++) { roomDbIds.push(7567);
roomDbIds.push(roomsArr[i]);
}
const { const {
SurfaceShadingData, SurfaceShadingData,
@ -839,10 +884,11 @@ async function loadHeatmaps(model, roomsArr) {
// Setup surface shading // Setup surface shading
await dataVizExtn.setupSurfaceShading(model, heatmapData); await dataVizExtn.setupSurfaceShading(model, heatmapData);
dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]); dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]);
function getSensorValue(device, sensorType) { function getSensorValue(device, sensorType) {
return sensorVals[parseInt(device.id)]; return sensorVals[parseInt(device.id.slice(-1)) - 1];
} }
dataVizExtn.renderSurfaceShading("Room Panel", "temperature", getSensorValue); dataVizExtn.renderSurfaceShading("Room Panel", "temperature", getSensorValue);
@ -855,7 +901,95 @@ async function loadHeatmaps(model, roomsArr) {
dataVizExtn.updateSurfaceShading(getSensorValue); dataVizExtn.updateSurfaceShading(getSensorValue);
}, 2000); }, 2000);
} }
//------------------------------ end ---------------------------------- //------------------ end --------------------------------
async function loadHeatmapsForFloor(model) {
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
//x: -17.33, y: 51.03, z: -2.52
const devices = [
{
id: "Oficina 5",
//name: "Oficina-",
position: { x: 6.98, y: -19.00, z: 16.86 }, // x: 0, y: 25, z: -2.5 (-4.93, -20.61, 16.86)
sensorTypes: ["temperature", "humidity"]
},
{
id: "Oficina 4",
//name: "Oficina-",
position: { x: 35.85, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (23.94, -3.85, 16.86)
sensorTypes: ["temperature", "humidity"]
},
{
id: "Oficina 3",
//name: "Oficina-",
position: { x: 6.98, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (-4.93, -3.85, 16.86)
sensorTypes: ["temperature", "humidity"]
}
];
// Initialize sensor values
let sensorVals = [];
for (let i = 0; i < devices.length; i++) {
sensorVals[i] = Math.random();
}
const roomDbIds = [];
roomDbIds.push(7567);
const {
SurfaceShadingData,
SurfaceShadingPoint,
SurfaceShadingNode,
} = Autodesk.DataVisualization.Core;
const shadingNode = new SurfaceShadingNode("Room Panel", roomDbIds);
devices.forEach((device) => {
const shadingPoint = new SurfaceShadingPoint(
device.id,
device.position,
device.sensorTypes
);
shadingNode.addPoint(shadingPoint);
});
const heatmapData = new SurfaceShadingData();
heatmapData.addChild(shadingNode);
heatmapData.initialize(model);
// Setup surface shading
await dataVizExtn.setupSurfaceShading(model, heatmapData);
//dataVizExtn.registerSurfaceShadingColors("co2", [0x00ff00, 0xff0000]);
dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]);
function getSensorValue(device, sensorType) {
return sensorVals[parseInt(device.id.slice(-1)) - 1];
}
dataVizExtn.renderSurfaceShading("Room Panel", "temperature", getSensorValue);
setInterval(() => {
// Modify sensor values.
for (let i = 0; i < devices.length; i++) {
sensorVals[i] = Math.random();
}
dataVizExtn.updateSurfaceShading(getSensorValue);
}, 2000);
}
//
async function loadHeatmap() {
const model = viewer.model;
loadHeatmaps(model);
}
async function loadHeatmapForFloor() {
const model = viewer.model;
loadHeatmapsForFloor(model);
}
//------------ 剖面 ---------------------- //------------ 剖面 ----------------------
async function getRemoteLevels() { async function getRemoteLevels() {
@ -956,6 +1090,21 @@ function changeColorTransparency(nodeId, color) {//變綠色
viewer.setThemingColor(nodeId, color); viewer.setThemingColor(nodeId, color);
} }
//隱藏全物件
function hideAllObjects() {
//viewer.hide(4);//只針對一個物件(dbid為4)做隱藏
for (var i = 0; i < allDbIdsStr.length; i++) {
viewer.hide(parseInt(allDbIdsStr[i]));
}
}
//顯示全物件
function showAllObjects() {
//viewer.show(4); //只針對一個物件(dbid為4)做顯示
for (var i = 0; i < allDbIdsStr.length; i++) {
viewer.show(parseInt(allDbIdsStr[i]));
}
}
//======================== 外部呼叫function =========================== //======================== 外部呼叫function ===========================
//紀錄熱點座標 //紀錄熱點座標
function getHopspotPoint(data) { function getHopspotPoint(data) {

View File

@ -179,6 +179,10 @@ function creImg(ele, text = null, id = null, name = null, cls = [], data = {}, a
function creI(cls = [], data = {}, attr = {}, id = null, name = null, text = null) { function creI(cls = [], data = {}, attr = {}, id = null, name = null, text = null) {
return creEle("i", text, id, name, cls, data, attr); return creEle("i", text, id, name, cls, data, attr);
} }
function creA(text = null, attr = {}, cls = [], id = null, data = {}, name = null) {
return creEle("a", text, id, name, cls, data, attr);
}
/** /**
* 根據該棟建築底下的'所有'電梯執行緒物件 * 根據該棟建築底下的'所有'電梯執行緒物件
* */ * */

View File

@ -0,0 +1,148 @@
/**
* YourTeam 上方 Tab 頁籤
*
* 使用方式
* <button type="button" data-tabname="testTab" data-target="testDiv1">頁籤按鈕1</button>
* <button type="button" data-tabname="testTab" data-target="testDiv2">頁籤按鈕2</button>
*
* <div id="testDiv1" data-tabname="testTab" data-tabrole="child"></div>
* <div id="testDiv2" data-tabname="testTab" data-tabrole="child"></div>
* */
var YT = YT || {};
$(function () {
initNavBarByEle();
})
/**
* 初始全頁面 yt tab
* */
function initNavBarByEle() {
/*_ytTabInited = [];*/
$(".yt-navbar").each(function (index, value) {
let type = null;
if ($(value).hasClass("yt-left-navbar")) {
type = "left";
}
let option = { element: value, type: type };
let navbar = new YourTeamNavbar(option);
})
}
class YourTeamNavbar {
constructor(option = {}) {
this.element = option.element;
this.type = option.type ?? "left";
this.isOpen = false;
this.init();
}
init = function () {
this.initClose();
this.checkIsOpen();
$(this.element)[0]._ytNavbar = this;
this.chkTrigger();
}
checkIsOpen = function () {
if ($(this.element).is(":visible")) {
this.isOpen = true;
} else {
this.isOpen = false;
}
}
open = function () {
if (this.type == "left") {
let curLeft = parseInt($(this.element).css("left").split("px")[0]);
if (curLeft >= 0) {
$(this.element).css("opacity", 0);
$(this.element).show();
let width = $(this.element)[0].offsetWidth;
$(this.element).css("left",0 - width);
$(this.element).hide();
$(this.element).css("opacity", 1);
}
$(this.element).show();
$(this.element).animate({ left: 0}, 200, () => {
this.checkIsOpen();
})
}
}
close = function () {
let width = $(this.element)[0].offsetWidth;
if (this.type == "left") {
$(this.element).animate({ left: 0 - width }, 200, () => {
$(this.element).hide();
this.checkIsOpen();
})
}
}
initClose = function () {
debugger
let width = $(this.element)[0].offsetWidth;
if (this.type == "left") {
$(this.element).css("left", 0 - width);
$(this.element).hide();
}
}
toggle = function () {
if (this.isOpen) {
this.close();
} else {
this.open();
}
}
chkTrigger = function () {
$("[data-toggle=navbar]").each((idx, ele) => {
let target = $(ele).data("target");
if ($(this.element)[0] == $(target)[0]) {
$(ele).off("click").on("click", () => {
this.toggle();
})
}
})
}
}
$.fn.YTNavbar = function (method) {
let nbObj = $(this)[0]._ytNavbar;
let target = $(this).data("target");
if (!nbObj && $(target).length != 0) {
nbObj = $(target)[0]._ytNavbar;
}
if (!nbObj) return this;
if (method == "show") {
nbObj.open();
} else if (method == "hide") {
nbObj.close();
} else if (method == "init") {
nbObj.init();
}
return nbObj;
}
function getTogNavbar() {
$("[data-toggle=navbar]").each((idx, ele) => {
let target = $(ele).data("target");
$(ele).off("click").on("click", function () {
let ngObj = $(target)[0]._ytNavbar;
ngObj.toggle();
})
})
}
YT.NavBar = YT.NavBar || YourTeamNavbar;