TTaskSimulation.js
5.12 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
layui.config({
base: "/js/"
}).use(['form', 'I18nPage', 'element', 'vue', 'layer', 'jquery', 'hhweb'], function () {
var form = layui.form,
layer = layui.layer,
element = layui.element,
$ = layui.jquery,
hhweb = layui.hhweb,
I18nPage = layui.I18nPage;
var AreaName = 'task';
var TableName = 'TTaskSimulation';
var Lang = I18nPage.GetLang();
var MessageContainer = {};
I18nPage.GetI18nMessage({
Type: "PM",
Code: "TTaskSimulation",
Container: MessageContainer,
});
I18nPage.GetI18nText({
Type: "LP",
Code: "TTaskSimulation",
});
if (Lang == "cn") {
$($(':radio[name="action"]')[0]).attr("title","前进");
$($(':radio[name="action"]')[1]).attr("title","后退");
$($(':radio[name="action"]')[2]).attr("title", "左转");
$($(':radio[name="action"]')[3]).attr("title", "右转");
$($(':radio[name="action"]')[4]).attr("title", "上升");
$($(':radio[name="action"]')[5]).attr("title", "下降");
$($(':radio[name="action"]')[6]).attr("title", "转盘左转");
$($(':radio[name="action"]')[7]).attr("title", "转盘右转");
}
else {
$($(':radio[name="action"]')[0]).attr("title","Forward");
$($(':radio[name="action"]')[1]).attr("title","Back off");
$($(':radio[name="action"]')[2]).attr("title", "Turn Left");
$($(':radio[name="action"]')[3]).attr("title", "Turn Right");
$($(':radio[name="action"]')[4]).attr("title", "Rise");
$($(':radio[name="action"]')[5]).attr("title", "Decline");
$($(':radio[name="action"]')[6]).attr("title", "Turntable Left");
$($(':radio[name="action"]')[7]).attr("title", "Turntable Right");
}
form.render()
var link = false;
$("#LinkAgv").on('click', function () {
var agvNo = $("#agvNo").val();
if (agvNo == undefined || agvNo == "") {
layer.alert(MessageContainer["AgvNoNotInput"], { icon: 5, shadeClose: true, title: MessageContainer["ErrorInfo"] });
return;
}
var index = layer.load();
$.ajax({
url: "/" + AreaName + "/" + TableName + "/LinkAgv",
type: "post",
data: { agvNo: agvNo, link: !link },
dataType: "json",
success: function (result) {
layer.close(index);
Log("Agv:【" + agvNo + "】,Link:【" + link + "】, Message: 【" + result.Message + "】");
if (result.Code == 200 && result.Status) {
link = !link;
if (link) {
$("[name='LP_LinkAgv']").html(MessageContainer["CloseLink"]);
$("#DivAction").show();
}
else {
$("[name='LP_LinkAgv']").html(MessageContainer["Connect"]);
$("#DivAction").hide();
}
}
else {
layer.alert(result.Message, { icon: 5, shadeClose: true, title: MessageContainer["ErrorInfo"] });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.close(index);
layer.alert(errorThrown, { icon: 2, shadeClose: true, title: MessageContainer["ErrorInfo"] });
}
});
});
$("#btnSend").mousedown(function () {
SendTask();
})
$("#btnSend").mouseup(function () {
StopTask();
})
$("#btnClear").on("click", function () {
$("#Msg").val("");
})
function Log(msg) {
$("#Msg").val(msg + "\r\n" + $("#Msg").val());
}
function SendTask() {
var agvNo = $("#agvNo").val();
var action = $(':radio[name="action"]:checked').val();
console.info(action);
$.ajax({
url: "/" + AreaName + "/" + TableName + "/ControlAgv",
type: "post",
data: { agvNo: agvNo, action: action },
dataType: "json",
success: function (result) {
Log("Agv:【" + agvNo + "】,Task Send:【" + $(':radio[name="action"]:checked')[0].title + "】, Message: 【" + result.Message + "】");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.close(index);
layer.alert(errorThrown, { icon: 2, shadeClose: true, title: MessageContainer["ErrorInfo"] });
}
});
}
function StopTask() {
var agvNo = $("#agvNo").val();
$.ajax({
url: "/" + AreaName + "/" + TableName + "/ControlAgv",
type: "post",
data: { agvNo: agvNo, action: 0 },
dataType: "json",
success: function (result) {
Log("Agv:【" + agvNo + "】,Task Send:【Stop】, Message: 【" + result.Message + "】");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.close(index);
layer.alert(errorThrown, { icon: 2, shadeClose: true, title: MessageContainer["ErrorInfo"] });
}
});
}
});