hexss 0.9.2__tar.gz → 0.9.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hexss-0.9.2 → hexss-0.9.4}/PKG-INFO +1 -1
- {hexss-0.9.2 → hexss-0.9.4}/hexss/control_robot/app.py +25 -3
- {hexss-0.9.2 → hexss-0.9.4}/hexss/control_robot/robot.py +4 -2
- {hexss-0.9.2 → hexss-0.9.4}/hexss/control_robot/server.py +1 -1
- hexss-0.9.4/hexss/control_robot/templates/index.html +193 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/camera_server.py +1 -1
- {hexss-0.9.2 → hexss-0.9.4}/hexss.egg-info/PKG-INFO +1 -1
- {hexss-0.9.2 → hexss-0.9.4}/setup.py +1 -1
- hexss-0.9.2/hexss/control_robot/templates/index.html +0 -184
- {hexss-0.9.2 → hexss-0.9.4}/LICENSE +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/MANIFEST.in +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/constants/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/constants/cml.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/control_robot/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/control_robot/static/jquery-3.6.0.min.js +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/detector/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/detector/object_detector.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/camera_server.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/detector.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/image.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/json.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/multicore.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/multicore2.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/templates/index.html +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/threading.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/example/threading_app.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/image/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/image/func.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/json/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/json/func.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/kill.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/multiprocessing/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/multiprocessing/func.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/multiprocessing/multicore.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/network.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/serial.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/file_manager_server.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/processes.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/static/script.js +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/static/styles.css +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/templates/camera.html +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/templates/file_manager.html +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/server/templates/process.html +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/string.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/threading/__init__.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss/threading/mutithread.py +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss.egg-info/SOURCES.txt +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss.egg-info/dependency_links.txt +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss.egg-info/entry_points.txt +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/hexss.egg-info/top_level.txt +0 -0
- {hexss-0.9.2 → hexss-0.9.4}/setup.cfg +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
from flask import Flask, render_template, request, jsonify, abort, Response
|
|
3
4
|
from hexss.serial import get_comport
|
|
4
5
|
from hexss.control_robot.robot import Robot
|
|
5
6
|
import threading
|
|
@@ -143,6 +144,21 @@ def set_to():
|
|
|
143
144
|
return jsonify({'status': 'error', 'message': str(e)}), 500
|
|
144
145
|
|
|
145
146
|
|
|
147
|
+
# new function
|
|
148
|
+
@app.route('/socket/current_position', methods=['GET', 'POST'])
|
|
149
|
+
def current_position_socket():
|
|
150
|
+
def generate():
|
|
151
|
+
result = ''
|
|
152
|
+
while True:
|
|
153
|
+
robot.current_position()
|
|
154
|
+
old_result = result
|
|
155
|
+
result = f"data: {json.dumps(robot.current_position_vel)}\n\n"
|
|
156
|
+
if result != old_result:
|
|
157
|
+
yield result
|
|
158
|
+
time.sleep(0.1)
|
|
159
|
+
return Response(generate(), mimetype='text/event-stream')
|
|
160
|
+
|
|
161
|
+
|
|
146
162
|
@app.errorhandler(400)
|
|
147
163
|
def bad_request(error):
|
|
148
164
|
return jsonify({'status': 'error', 'message': error.description}), 400
|
|
@@ -154,4 +170,10 @@ def internal_server_error(error):
|
|
|
154
170
|
|
|
155
171
|
|
|
156
172
|
def run(data):
|
|
157
|
-
|
|
173
|
+
log = logging.getLogger('werkzeug')
|
|
174
|
+
log.setLevel(logging.ERROR)
|
|
175
|
+
app.config['data'] = data
|
|
176
|
+
ipv4 = data['config']['ipv4']
|
|
177
|
+
port = data['config']['port']
|
|
178
|
+
print(f" * Running on http://{ipv4}:{port}")
|
|
179
|
+
app.run(ipv4, port, debug=True, use_reloader=False)
|
|
@@ -68,6 +68,8 @@ class Robot:
|
|
|
68
68
|
self.send_data('all', '05', '040B', '0000')
|
|
69
69
|
|
|
70
70
|
def jog(self, slave: str, positive_side: bool, move: bool) -> None:
|
|
71
|
+
if move:
|
|
72
|
+
self.logger.info(f'Jog slave:{slave} {"+" if positive_side else "-"}')
|
|
71
73
|
register = '0416' if positive_side else '0417'
|
|
72
74
|
data = 'FF00' if move else '0000'
|
|
73
75
|
self.send_data(slave, '05', register, data)
|
|
@@ -113,7 +115,7 @@ class Robot:
|
|
|
113
115
|
vel = int(string[7:-2], 16)
|
|
114
116
|
if vel > 0x7FFFFFFF:
|
|
115
117
|
vel -= 0x100000000
|
|
116
|
-
self.logger.info(f"Slave: {slave}, Velocity: {vel}, Hex: {hex(vel)}")
|
|
118
|
+
# self.logger.info(f"Slave: {slave}, Velocity: {vel}, Hex: {hex(vel)}")
|
|
117
119
|
self.current_position_vel[slave] = vel
|
|
118
120
|
|
|
119
121
|
def run(self) -> None:
|
|
@@ -124,7 +126,7 @@ class Robot:
|
|
|
124
126
|
while b'\r\n' in self.buffer:
|
|
125
127
|
message, self.buffer = self.buffer.split(b'\r\n', 1)
|
|
126
128
|
if message.startswith(b':'):
|
|
127
|
-
self.logger.info(f"Received: {message.decode()}\\r\\n")
|
|
129
|
+
# self.logger.info(f"Received: {message.decode()}\\r\\n")
|
|
128
130
|
self.evens(message.decode())
|
|
129
131
|
except serial.SerialException as e:
|
|
130
132
|
self.logger.error(f"Serial communication error: {e}")
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Robot Control Panel</title>
|
|
7
|
+
<script src="static/jquery-3.6.0.min.js"></script>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: Arial, sans-serif;
|
|
11
|
+
max-width: 800px;
|
|
12
|
+
margin: 0 auto;
|
|
13
|
+
padding: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
button, input {
|
|
17
|
+
margin: 5px;
|
|
18
|
+
padding: 5px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.jog-control {
|
|
22
|
+
margin-bottom: 10px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
h2 {
|
|
26
|
+
margin: 30px 0 10px;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<h1>Robot Control Panel</h1>
|
|
32
|
+
|
|
33
|
+
<section aria-labelledby="jog-control-heading">
|
|
34
|
+
<h2 id="jog-control-heading">Jog Control</h2>
|
|
35
|
+
<div id="jog-controls"></div>
|
|
36
|
+
</section>
|
|
37
|
+
|
|
38
|
+
<section aria-labelledby="other-controls-heading">
|
|
39
|
+
<h2 id="other-controls-heading">Other Controls</h2>
|
|
40
|
+
<div>
|
|
41
|
+
<button id="servo-on">Servo ON</button>
|
|
42
|
+
<button id="servo-off">Servo OFF</button>
|
|
43
|
+
</div>
|
|
44
|
+
<div>
|
|
45
|
+
<button id="pause-on">Pause ON</button>
|
|
46
|
+
<button id="pause-off">Pause OFF</button>
|
|
47
|
+
</div>
|
|
48
|
+
<div>
|
|
49
|
+
<button id="alarm-reset">Alarm Reset</button>
|
|
50
|
+
<button id="home">Home</button>
|
|
51
|
+
<button id="current-position">Current Position</button>
|
|
52
|
+
</div>
|
|
53
|
+
</section>
|
|
54
|
+
|
|
55
|
+
<section aria-labelledby="move-to-heading">
|
|
56
|
+
<h2 id="move-to-heading">Move To</h2>
|
|
57
|
+
<div>
|
|
58
|
+
<input type="number" id="move-to-row" placeholder="Row" aria-label="Row number">
|
|
59
|
+
<button id="move-to">Move To</button>
|
|
60
|
+
</div>
|
|
61
|
+
</section>
|
|
62
|
+
|
|
63
|
+
<section aria-labelledby="set-to-heading">
|
|
64
|
+
<h2 id="set-to-heading">Set To</h2>
|
|
65
|
+
<div>
|
|
66
|
+
<input type="text" id="set-to-slave" placeholder="Slave" aria-label="Slave ID">
|
|
67
|
+
<input type="number" id="set-to-row" placeholder="Row" aria-label="Row number">
|
|
68
|
+
<input type="number" id="set-to-position" placeholder="Position" aria-label="Position">
|
|
69
|
+
<input type="number" id="set-to-speed" placeholder="Speed" aria-label="Speed">
|
|
70
|
+
<input type="number" id="set-to-acc" placeholder="Acceleration" aria-label="Acceleration">
|
|
71
|
+
<input type="number" id="set-to-dec" placeholder="Deceleration" aria-label="Deceleration">
|
|
72
|
+
<button id="set-to">Set To</button>
|
|
73
|
+
</div>
|
|
74
|
+
</section>
|
|
75
|
+
|
|
76
|
+
<section aria-labelledby="status-heading">
|
|
77
|
+
<h2 id="status-heading">Status</h2>
|
|
78
|
+
<pre id="status" aria-live="polite"></pre>
|
|
79
|
+
<pre id="error_status" aria-live="polite"></pre>
|
|
80
|
+
</section>
|
|
81
|
+
|
|
82
|
+
<script>
|
|
83
|
+
$(document).ready(function () {
|
|
84
|
+
initJogControls();
|
|
85
|
+
bindEventHandlers();
|
|
86
|
+
initPositionSocket();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
function initJogControls() {
|
|
90
|
+
const jogControlsHtml = ['01', '02', '03', '04'].map(slaveId => `
|
|
91
|
+
<div class="jog-control">
|
|
92
|
+
<label>Slave ${slaveId}:</label>
|
|
93
|
+
<button class="jog-btn" data-slave="${slaveId}" data-direction="plus">Jog +</button>
|
|
94
|
+
<button class="jog-btn" data-slave="${slaveId}" data-direction="minus">Jog -</button>
|
|
95
|
+
<span id="position${slaveId}">??? mm</span>
|
|
96
|
+
</div>
|
|
97
|
+
`).join('');
|
|
98
|
+
$('#jog-controls').html(jogControlsHtml);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function bindEventHandlers() {
|
|
102
|
+
$(document).on('mousedown mouseup mouseleave', '.jog-btn', function (event) {
|
|
103
|
+
const slave = $(this).data('slave');
|
|
104
|
+
const direction = $(this).data('direction');
|
|
105
|
+
jog(slave, direction === 'plus', event.type === 'mousedown');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
$('#servo-on').click(() => servo(true));
|
|
109
|
+
$('#servo-off').click(() => servo(false));
|
|
110
|
+
$('#pause-on').click(() => pause(true));
|
|
111
|
+
$('#pause-off').click(() => pause(false));
|
|
112
|
+
$('#alarm-reset').click(alarmReset);
|
|
113
|
+
$('#home').click(home);
|
|
114
|
+
$('#current-position').click(currentPosition);
|
|
115
|
+
$('#move-to').click(moveTo);
|
|
116
|
+
$('#set-to').click(setTo);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function initPositionSocket() {
|
|
120
|
+
const eventSource = new EventSource('/socket/current_position');
|
|
121
|
+
eventSource.onmessage = function (event) {
|
|
122
|
+
const positions = JSON.parse(event.data);
|
|
123
|
+
for (let slave in positions) {
|
|
124
|
+
$(`#position${slave}`).text(`${positions[slave] / 100} mm`);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
eventSource.onerror = function (error) {
|
|
128
|
+
console.error('EventSource failed:', error);
|
|
129
|
+
$('#error_status').text(`Error in position update: ${error.message}`);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function apiCall(endpoint, method, data) {
|
|
134
|
+
return $.ajax({
|
|
135
|
+
url: `/api/${endpoint}`,
|
|
136
|
+
method: method,
|
|
137
|
+
contentType: 'application/json',
|
|
138
|
+
data: JSON.stringify(data)
|
|
139
|
+
}).then(response => {
|
|
140
|
+
console.log(`${endpoint}:`, response);
|
|
141
|
+
$('#status').text(`${endpoint}\nStatus: ${response.status}`);
|
|
142
|
+
return response;
|
|
143
|
+
}).catch(error => {
|
|
144
|
+
console.error(`Error in ${endpoint}:`, error);
|
|
145
|
+
$('#error_status').text(`Error in ${endpoint}: ${error.statusText}`);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function servo(on) {
|
|
150
|
+
apiCall('servo', 'POST', {on: on});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function alarmReset() {
|
|
154
|
+
apiCall('alarm_reset', 'POST');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function pause(pause) {
|
|
158
|
+
apiCall('pause', 'POST', {pause: pause});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function home() {
|
|
162
|
+
apiCall('home', 'POST');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function currentPosition() {
|
|
166
|
+
apiCall('current_position', 'GET');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function jog(slave, positiveSide, move) {
|
|
170
|
+
apiCall('jog', 'POST', {
|
|
171
|
+
slave: slave,
|
|
172
|
+
positive_side: positiveSide,
|
|
173
|
+
move: move
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function moveTo() {
|
|
178
|
+
apiCall('move_to', 'POST', {row: parseInt($('#move-to-row').val())});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function setTo() {
|
|
182
|
+
apiCall('set_to', 'POST', {
|
|
183
|
+
slave: $('#set-to-slave').val(),
|
|
184
|
+
row: parseInt($('#set-to-row').val()),
|
|
185
|
+
position: parseFloat($('#set-to-position').val()),
|
|
186
|
+
speed: parseFloat($('#set-to-speed').val()),
|
|
187
|
+
acc: parseFloat($('#set-to-acc').val()),
|
|
188
|
+
dec: parseFloat($('#set-to-dec').val())
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
</script>
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Robot Control Panel</title>
|
|
7
|
-
<script src="static/jquery-3.6.0.min.js"></script>
|
|
8
|
-
<style>
|
|
9
|
-
body {
|
|
10
|
-
font-family: Arial, sans-serif;
|
|
11
|
-
max-width: 800px;
|
|
12
|
-
margin: 0 auto;
|
|
13
|
-
padding: 20px;
|
|
14
|
-
}
|
|
15
|
-
button, input {
|
|
16
|
-
margin: 5px;
|
|
17
|
-
padding: 5px;
|
|
18
|
-
}
|
|
19
|
-
.jog-control {
|
|
20
|
-
margin-bottom: 10px;
|
|
21
|
-
}
|
|
22
|
-
h2 {
|
|
23
|
-
margin: 30px 0 10px;
|
|
24
|
-
}
|
|
25
|
-
</style>
|
|
26
|
-
</head>
|
|
27
|
-
<body>
|
|
28
|
-
<h1>Robot Control Panel</h1>
|
|
29
|
-
|
|
30
|
-
<section aria-labelledby="jog-control-heading">
|
|
31
|
-
<h2 id="jog-control-heading">Jog Control</h2>
|
|
32
|
-
<div id="jog-controls"></div>
|
|
33
|
-
</section>
|
|
34
|
-
|
|
35
|
-
<section aria-labelledby="other-controls-heading">
|
|
36
|
-
<h2 id="other-controls-heading">Other Controls</h2>
|
|
37
|
-
<div>
|
|
38
|
-
<button id="servo-on">Servo ON</button>
|
|
39
|
-
<button id="servo-off">Servo OFF</button>
|
|
40
|
-
</div>
|
|
41
|
-
<div>
|
|
42
|
-
<button id="pause-on">Pause ON</button>
|
|
43
|
-
<button id="pause-off">Pause OFF</button>
|
|
44
|
-
</div>
|
|
45
|
-
<div>
|
|
46
|
-
<button id="alarm-reset">Alarm Reset</button>
|
|
47
|
-
<button id="home">Home</button>
|
|
48
|
-
<button id="current-position">Current Position</button>
|
|
49
|
-
</div>
|
|
50
|
-
</section>
|
|
51
|
-
|
|
52
|
-
<section aria-labelledby="move-to-heading">
|
|
53
|
-
<h2 id="move-to-heading">Move To</h2>
|
|
54
|
-
<div>
|
|
55
|
-
<input type="number" id="move-to-row" placeholder="Row" aria-label="Row number">
|
|
56
|
-
<button id="move-to">Move To</button>
|
|
57
|
-
</div>
|
|
58
|
-
</section>
|
|
59
|
-
|
|
60
|
-
<section aria-labelledby="set-to-heading">
|
|
61
|
-
<h2 id="set-to-heading">Set To</h2>
|
|
62
|
-
<div>
|
|
63
|
-
<input type="text" id="set-to-slave" placeholder="Slave" aria-label="Slave ID">
|
|
64
|
-
<input type="number" id="set-to-row" placeholder="Row" aria-label="Row number">
|
|
65
|
-
<input type="number" id="set-to-position" placeholder="Position" aria-label="Position">
|
|
66
|
-
<input type="number" id="set-to-speed" placeholder="Speed" aria-label="Speed">
|
|
67
|
-
<input type="number" id="set-to-acc" placeholder="Acceleration" aria-label="Acceleration">
|
|
68
|
-
<input type="number" id="set-to-dec" placeholder="Deceleration" aria-label="Deceleration">
|
|
69
|
-
<button id="set-to">Set To</button>
|
|
70
|
-
</div>
|
|
71
|
-
</section>
|
|
72
|
-
|
|
73
|
-
<section aria-labelledby="status-heading">
|
|
74
|
-
<h2 id="status-heading">Status</h2>
|
|
75
|
-
<pre id="status" aria-live="polite"></pre>
|
|
76
|
-
<pre id="error_status" aria-live="polite"></pre>
|
|
77
|
-
</section>
|
|
78
|
-
|
|
79
|
-
<script>
|
|
80
|
-
$(document).ready(function () {
|
|
81
|
-
initJogControls();
|
|
82
|
-
bindEventHandlers();
|
|
83
|
-
setInterval(currentPosition, 1000);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
function initJogControls() {
|
|
87
|
-
const jogControlsHtml = ['01', '02', '03', '04'].map(slaveId => `
|
|
88
|
-
<div class="jog-control">
|
|
89
|
-
<label>Slave ${slaveId}:</label>
|
|
90
|
-
<button class="jog-btn" data-slave="${slaveId}" data-direction="plus">Jog +</button>
|
|
91
|
-
<button class="jog-btn" data-slave="${slaveId}" data-direction="minus">Jog -</button>
|
|
92
|
-
<span id="position${slaveId}">??? mm</span>
|
|
93
|
-
</div>
|
|
94
|
-
`).join('');
|
|
95
|
-
$('#jog-controls').html(jogControlsHtml);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function bindEventHandlers() {
|
|
99
|
-
$(document).on('mousedown mouseup mouseleave', '.jog-btn', function(event) {
|
|
100
|
-
const slave = $(this).data('slave');
|
|
101
|
-
const direction = $(this).data('direction');
|
|
102
|
-
jog(slave, direction === 'plus', event.type === 'mousedown');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
$('#servo-on').click(() => servo(true));
|
|
106
|
-
$('#servo-off').click(() => servo(false));
|
|
107
|
-
$('#pause-on').click(() => pause(true));
|
|
108
|
-
$('#pause-off').click(() => pause(false));
|
|
109
|
-
$('#alarm-reset').click(alarmReset);
|
|
110
|
-
$('#home').click(home);
|
|
111
|
-
$('#current-position').click(currentPosition);
|
|
112
|
-
$('#move-to').click(moveTo);
|
|
113
|
-
$('#set-to').click(setTo);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function apiCall(endpoint, method, data) {
|
|
117
|
-
return $.ajax({
|
|
118
|
-
url: `/api/${endpoint}`,
|
|
119
|
-
method: method,
|
|
120
|
-
contentType: 'application/json',
|
|
121
|
-
data: JSON.stringify(data)
|
|
122
|
-
}).then(response => {
|
|
123
|
-
console.log(`${endpoint}:`, response);
|
|
124
|
-
return response;
|
|
125
|
-
}).catch(error => {
|
|
126
|
-
console.error(`Error in ${endpoint}:`, error);
|
|
127
|
-
$('#error_status').text(`Error in ${endpoint}: ${error.statusText}`);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function servo(on) {
|
|
132
|
-
apiCall('servo', 'POST', {on: on});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function alarmReset() {
|
|
136
|
-
apiCall('alarm_reset', 'POST');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function pause(pause) {
|
|
140
|
-
apiCall('pause', 'POST', {pause: pause});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function home() {
|
|
144
|
-
apiCall('home', 'POST');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function currentPosition() {
|
|
148
|
-
apiCall('current_position', 'GET').then(updatePositions);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function updatePositions(positions) {
|
|
152
|
-
if (positions && positions.status === 'success') {
|
|
153
|
-
for (let slave in positions.data) {
|
|
154
|
-
$(`#position${slave}`).text(`${positions.data[slave] / 100} mm`);
|
|
155
|
-
}
|
|
156
|
-
$('#status').text(JSON.stringify(positions, null, 2));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function jog(slave, positiveSide, move) {
|
|
161
|
-
apiCall('jog', 'POST', {
|
|
162
|
-
slave: slave,
|
|
163
|
-
positive_side: positiveSide,
|
|
164
|
-
move: move
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function moveTo() {
|
|
169
|
-
apiCall('move_to', 'POST', {row: parseInt($('#move-to-row').val())});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function setTo() {
|
|
173
|
-
apiCall('set_to', 'POST', {
|
|
174
|
-
slave: $('#set-to-slave').val(),
|
|
175
|
-
row: parseInt($('#set-to-row').val()),
|
|
176
|
-
position: parseFloat($('#set-to-position').val()),
|
|
177
|
-
speed: parseFloat($('#set-to-speed').val()),
|
|
178
|
-
acc: parseFloat($('#set-to-acc').val()),
|
|
179
|
-
dec: parseFloat($('#set-to-dec').val())
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
</script>
|
|
183
|
-
</body>
|
|
184
|
-
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|