質問編集履歴
1
コード、画像の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -67,3 +67,63 @@
|
|
67
67
|
```
|
68
68
|
|
69
69
|
|
70
|
+
3/14追記
|
71
|
+
```JavaScript
|
72
|
+
$.ajax({
|
73
|
+
url : '/data',
|
74
|
+
type : 'GET',
|
75
|
+
dataType : 'json',
|
76
|
+
})
|
77
|
+
//通信成功時の処理
|
78
|
+
.done(function(json){
|
79
|
+
/*
|
80
|
+
console.log(data(['production']['machine1']));
|
81
|
+
console.log(data(['cycletime']['machine1']));
|
82
|
+
console.log(data(['green']['machine1']));
|
83
|
+
console.log(data(['yellow']['machine1']));
|
84
|
+
*/
|
85
|
+
|
86
|
+
console.log(json);
|
87
|
+
const obj = JSON.parse(JSON.stringify(json));
|
88
|
+
|
89
|
+
console.log(obj.production);
|
90
|
+
console.log(obj.cycletime);
|
91
|
+
console.log(obj.green);
|
92
|
+
console.log(obj.yellow);
|
93
|
+
|
94
|
+
|
95
|
+
var production = obj.production;
|
96
|
+
var cycletime = obj.cycletime;
|
97
|
+
var green = obj.green;
|
98
|
+
var yellow = obj.yellow;
|
99
|
+
|
100
|
+
|
101
|
+
console.log(production);
|
102
|
+
console.log(cycletime);
|
103
|
+
console.log(green);
|
104
|
+
console.log(yellow);
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
if(green===0){
|
109
|
+
ctx1.fillStyle = "rgb(0, 255, 0)";
|
110
|
+
console.log("OK");
|
111
|
+
}
|
112
|
+
else if(yellow===1){
|
113
|
+
ctx1.fillStyle = "rgb(255, 255, 0)";
|
114
|
+
}
|
115
|
+
else{
|
116
|
+
ctx1.fillStyle = "rgb(255, 0, 0)";
|
117
|
+
console.log('赤');
|
118
|
+
}
|
119
|
+
|
120
|
+
})
|
121
|
+
|
122
|
+
//通信失敗時の処理
|
123
|
+
.fail(function(data) {
|
124
|
+
console.log('データが取れていません');
|
125
|
+
})
|
126
|
+
```
|
127
|
+
|
128
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-03-14/d0c31c71-0e7d-4c13-b4b5-a0a8c8c696e1.png)
|
129
|
+
|