add_blocks_for_timer_and_fix_bugs
This commit is contained in:
23
js/MixIO.js
23
js/MixIO.js
@@ -79,13 +79,14 @@ var MixIO = {
|
||||
DATA_TABLE: 10,
|
||||
DASHBOARD: 11,
|
||||
DATA_MAP: 12,
|
||||
WEATHER: 13
|
||||
WEATHER: 13,
|
||||
TIMER: 14
|
||||
},
|
||||
|
||||
oldTags: ["input_button", "input_slider", "input_keyboard", "input_controller", "input_rgb", "output_bulb", "output_text",
|
||||
"output_chart", "output_bar", "table", "output_dashboard", "output_map", "input_weather"
|
||||
"output_chart", "output_bar", "table", "output_dashboard", "output_map", "input_weather", "timer"
|
||||
],
|
||||
zhcnTags: ["按键/开关", "滑杆", "文本输入", "摇杆手柄", "RGB色盘", "指示灯", "文本显示屏", "折线图表", "柱状图表", "数据表格", "仪表盘", "数据地图", "实时气象仪"],
|
||||
zhcnTags: ["按键/开关", "滑杆", "文本输入", "摇杆手柄", "RGB色盘", "指示灯", "文本显示屏", "折线图表", "柱状图表", "数据表格", "仪表盘", "数据地图", "实时气象仪", "定时触发器"],
|
||||
|
||||
/*合法的MixIO事件种类*/
|
||||
eventTags: {
|
||||
@@ -121,7 +122,9 @@ var MixIO = {
|
||||
DATA_MAP_CHANGED: "1211", //数据地图收到消息
|
||||
|
||||
WEATHER_SYNCED: "1311", //气象仪更新数据
|
||||
WEATHER_SENT: "1312" //气象仪发送数据
|
||||
WEATHER_SENT: "1312", //气象仪发送数据
|
||||
|
||||
TIMER_TRIGGERED: "1411"
|
||||
|
||||
},
|
||||
|
||||
@@ -159,8 +162,9 @@ var MixIO = {
|
||||
DATA_MAP_CLEAR: "1222", //清空数据地图数据
|
||||
|
||||
WEATHER_SYNC: "1321", //更新气象仪数据
|
||||
WEATHER_SEND: "1322" //发送气象仪数据
|
||||
WEATHER_SEND: "1322", //发送气象仪数据
|
||||
|
||||
TRIGGER_TIMER: "1411"
|
||||
},
|
||||
publish: function(topic, message) {
|
||||
// if message undefined
|
||||
@@ -328,6 +332,15 @@ var MixIO = {
|
||||
instance.getData = function(type) {
|
||||
return sepMsgs[type]
|
||||
}
|
||||
} else if (type === MixIO.typeTags.TIMER){
|
||||
instance.getTriggerTimes = function(){
|
||||
try{
|
||||
return parseInt(instance.attr('user-times'))
|
||||
}
|
||||
catch{
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var globalVer = "MixIO ver 1.11.24"
|
||||
var isChanged = false;
|
||||
var initCodeMirror = false;
|
||||
var globalBLE = {}
|
||||
function copy(obj) {
|
||||
return JSON.parse(JSON.stringify(obj))
|
||||
@@ -1917,7 +1918,7 @@ function view_project(projectName, projectType) {
|
||||
window.addEventListener("resize", function() {
|
||||
chart.resize();
|
||||
});
|
||||
if (projectType == LOGIC_MODE && isCode) {
|
||||
if (projectType == LOGIC_MODE && isCode && !initCodeMirror) {
|
||||
init_codemirror()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2403,6 +2403,7 @@ function add_magic(user_title, user_topic, user_content, user_style, title_style
|
||||
async function add_timer(user_title, user_topic, user_content, user_style, title_style, isObserve) {
|
||||
if(MixIO.editor == undefined)
|
||||
{
|
||||
initCodeMirror = true
|
||||
await init_codemirror()
|
||||
}
|
||||
var isAlive = true
|
||||
@@ -2430,19 +2431,23 @@ async function add_timer(user_title, user_topic, user_content, user_style, title
|
||||
var itemdiv = add_block(1, 1, contents, attrs)
|
||||
MixIO.triggers[title.text()] = function() {
|
||||
var localTime = 0
|
||||
title.parent().parent().attr('user-times', localTime)
|
||||
MixIO.setInterval(function() {
|
||||
if (triggerTimes == 0 || localTime < triggerTimes) {
|
||||
itemdiv.addClass("triggered")
|
||||
setTimeout(function() {
|
||||
itemdiv.removeClass("triggered")
|
||||
}, 150)
|
||||
// Aug 2025
|
||||
var sendMessage = triggerMessage
|
||||
if(triggerMessage=="$CURR_TIME$")
|
||||
MixIO.publish(triggerTopic, (new Date().getHours() > 10 ? new Date().getHours()+"" : ("0" + new Date().getHours())) +":"+ (new Date().getMinutes() > 10 ? new Date().getMinutes()+"" : ("0" + new Date().getMinutes())) +":"+ (new Date().getSeconds() > 10 ? new Date().getSeconds()+"" : ("0" + new Date().getSeconds())))
|
||||
sendMessage = (new Date().getHours() > 10 ? new Date().getHours()+"" : ("0" + new Date().getHours())) +":"+ (new Date().getMinutes() > 10 ? new Date().getMinutes()+"" : ("0" + new Date().getMinutes())) +":"+ (new Date().getSeconds() > 10 ? new Date().getSeconds()+"" : ("0" + new Date().getSeconds()))
|
||||
else if(triggerMessage=="$RAN_NUM$")
|
||||
MixIO.publish(triggerTopic, Math.round(Math.random()*99+1))
|
||||
else
|
||||
MixIO.publish(triggerTopic, triggerMessage)
|
||||
sendMessage = Math.round(Math.random()*99+1)
|
||||
MixIO.publish(triggerTopic, sendMessage)
|
||||
localTime = localTime + 1
|
||||
title.parent().parent().attr('user-times', localTime)
|
||||
itemdiv.trigger(MixIO.eventTags.TIMER_TRIGGERED, sendMessage)
|
||||
}
|
||||
}, triggerInterval)
|
||||
}
|
||||
@@ -2623,6 +2628,7 @@ async function add_timer(user_title, user_topic, user_content, user_style, title
|
||||
async function add_trigger(user_title, user_topic, user_content, user_style, title_style, isObserve) {
|
||||
if(MixIO.editor == undefined)
|
||||
{
|
||||
initCodeMirror = true
|
||||
await init_codemirror()
|
||||
}
|
||||
var isAlive = true
|
||||
|
||||
Reference in New Issue
Block a user