Skip to content

Commit

Permalink
Implement CSV local file download
Browse files Browse the repository at this point in the history
  • Loading branch information
Finchiedev committed Aug 20, 2019
1 parent 3dda4c7 commit 9f1f697
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
33 changes: 33 additions & 0 deletions App/JS/Resources/Servos/ax18a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Address, Size(Byte), Data Name, Description, Access, InitialValue
0, 2, Model Number, Model Number, R, 18
2, 1, Firmware Version, Firmware Version, R, -
3, 1, ID, DYNAMIXEL ID, RW, 1
4, 1, Baud Rate, Communication Speed, RW, 1
5, 1, Return Delay Time, Response Delay Time, RW, 250
6, 2, CW Angle Limit, Clockwise Angle Limit, RW, 0
8, 2, CCW Angle Limit, Counter-Clockwise Angle Limit, RW, 1023
11, 1, Temperature Limit, Maximum Internal Temperature Limit, RW, 75
12, 1, Min Voltage Limit, Minimum Input Voltage Limit, RW, 60
13, 1, Max Voltage Limit, Maximum Input Voltage Limit, RW, 140
14, 2, Max Torque, Maximun Torque, RW, 983
16, 1, Status Return Level, Select Types of Status Return, RW, 2
17, 1, Alarm LED, LED for Alarm, RW, 36
18, 1, Shutdown, Shutdown Error Information, RW, 36
24, 1, Torque Enable, Motor Torque On/Off, RW, 0
25, 1, LED, Status LED On/Off, RW, 0
26, 1, CW Compliance Margin, CW Compliance Margin, RW, 1
27, 1, CCW Compliance Margin, CCW Compliance Margin, RW, 1
28, 1, CW Compliance Slope, CW Compliance Slope, RW, 32
29, 1, CCW Compliance Slope, CCW Compliance Slope, RW, 32
30, 2, Goal Position, Target Position, RW, -
32, 2, Moving Speed, Moving Speed, RW, -
34, 2, Torque Limit, Torque Limit(Goal Torque), RW, ADD 14&15
36, 2, Present Position, Present Position, R, -
38, 2, Present Speed, Present Speed, R, -
40, 2, Present Load, Present Load, R, -
42, 1, Present Voltage, Present Voltage, R, -
43, 1, Present Temperature, Present Temperature, R, -
44, 1, Registered, If Instruction is registered, R, 0
46, 1, Moving, Movement Status, R, 0
47, 1, Lock, Locking EEPROM, RW, 0
48, 2, Punch, Minimum Current Threshold, RW, 32
32 changes: 32 additions & 0 deletions App/JS/Resources/Servos/xl320.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Address, Size(Byte), Data Name, Description, Access, InitialValue, Min, Max
0, 2, Model Number, Model Number, R, 350, -, -
2, 1, Firmware Version, Firmware Version, R, -, -, -
3, 1, ID, DYNAMIXEL ID, RW, 1, 0, 252
4, 1, Baud Rate, Communication Speed, RW, 3, 0, 3
5, 1, Return Delay Time, Response Delay Time, RW, 250, 0, 254
6, 2, CW Angle Limit, Clockwise Angle Limit, RW, 0, 0, 1023
8, 2, CCW Angle Limit, Counter-Clockwise Angle Limit, RW, 1023, 0, 1023
11, 1, Control Mode, Control Mode, RW, 2, 1, 2
12, 1, Temperature Limit, Maximum Internal Temperature Limit, RW, 65, 0, 150
13, 1, Min Voltage Limit, Minimum Input Voltage Limit, RW, 60, 50, 250
14, 1, Max Voltage Limit, Maximum Input Voltage Limit, RW, 90, 50, 250
15, 2, Max Torque, Maximun Torque, RW, 1023, 0, 1023
17, 1, Status Return Level, Select Types of Status Return, RW, 2, 0, 2
18, 1, Shutdown, Shutdown Error Information, RW, 3, 0, 7
24, 1, Torque Enable, Motor Torque On/Off, RW, 0, 0, 1
25, 1, LED, Status LED On/Off, RW, 0, 0, 7
27, 1, D Gain, Derivative Gain, RW, 0, 0, 254
28, 1, I Gain, Integral Gain, RW, 0, 0, 254
29, 1, P Gain, Proportional Gain, RW, 32, 0, 254
30, 2, Goal Position, Desired Position, RW, -, 0, 1023
32, 2, Moving Speed, Moving Speed(Moving Velocity), RW, -, 0, 2047
35, 2, Torque Limit, Torque Limit(Goal Torque), RW, -, 0, 1023
37, 2, Present Position, Present Position, R, -, -, -
39, 2, Present Speed, Present Speed, R, -, -, -
41, 2, Present Load, Present Load, R, -, -, -
45, 1, Present Voltage, Present Voltage, R, -, -, -
46, 1, Present Temperature, Present Temperature, R, -, -, -
47, 1, Registered, If Instruction is registered, R, 0, -, -
49, 1, Moving, Movement Status, R, 0, -, -
50, 1, Hardware Error Status, Hardware Error Status, R, 0, -, -
51, 2, Punch, Minimum Current Threshold, RW, 32, 0, 1023
14 changes: 11 additions & 3 deletions App/JS/createServo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const rp = require('request-promise');
const cheerio = require('cheerio');
const cheerioTableparser = require('cheerio-tableparser');
Expand Down Expand Up @@ -88,16 +89,23 @@ function generateCSV(html, indexes) {
' Now scraping the data...');
fileData = generateCSV(html, [1, 2]);
console.log('Downloaded table!');

const linkPieces = link.split('/');
if (linkPieces[linkPieces.length - 1] == '') {
linkPieces.pop(linkPieces.length - 1);
}
filename = linkPieces[linkPieces.length - 1];
filename = linkPieces[linkPieces.length - 1].replace('-', '');

fs.writeFile(`App/JS/Resources/Servos/${filename}.csv`, fileData, function(err) {
if (err) {
console.error('Failed to write file! Do you have access?');
}
console.log(`Saved the file as ${filename}.csv`);
});

uploadButton = document.getElementById('upload')
uploadButton.innerHTML =
`Upload <strong>${filename.replace('-', '')}.csv</strong>`;
`Upload <strong>${filename}.csv</strong>`;
uploadButton.style.display = null;
})
.catch(function(err) {
Expand Down

0 comments on commit 9f1f697

Please sign in to comment.