kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
File Association
rodzic
42be3768ea
commit
f9cda62f73
|
@ -57,6 +57,20 @@ $(document).ready(function() {
|
||||||
fileOpen.addEventListener('change', readFile, false);
|
fileOpen.addEventListener('change', readFile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$.get("/gcode").done(function(data) {
|
||||||
|
console.log(data.length)
|
||||||
|
editor.session.setValue(data);
|
||||||
|
$('#controlTab').click()
|
||||||
|
if (webgl) {
|
||||||
|
$('#gcodeviewertab').click();
|
||||||
|
} else {
|
||||||
|
$('#gcodeeditortab').click()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function readFile(evt) {
|
function readFile(evt) {
|
||||||
|
|
|
@ -100,8 +100,11 @@ function initSocket() {
|
||||||
printLog("Received new GCODE from API")
|
printLog("Received new GCODE from API")
|
||||||
editor.session.setValue(data);
|
editor.session.setValue(data);
|
||||||
$('#controlTab').click()
|
$('#controlTab').click()
|
||||||
$('#gcodeeditortab').click()
|
if (webgl) {
|
||||||
// gcodeeditortab
|
$('#gcodeviewertab').click();
|
||||||
|
} else {
|
||||||
|
$('#gcodeeditortab').click()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('gcodeupload', function(data) {
|
socket.on('gcodeupload', function(data) {
|
||||||
|
|
88
index.js
88
index.js
|
@ -184,6 +184,7 @@ if (isElectron()) {
|
||||||
} else {
|
} else {
|
||||||
var uploadsDir = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + 'Library/Preferences' : '/var/local')
|
var uploadsDir = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + 'Library/Preferences' : '/var/local')
|
||||||
}
|
}
|
||||||
|
var uploadedgcode = ""; // var to store uploaded gcode
|
||||||
|
|
||||||
// fs.existsSync(uploadsDir) || fs.mkdirSync(uploadsDir)
|
// fs.existsSync(uploadsDir) || fs.mkdirSync(uploadsDir)
|
||||||
mkdirp(uploadsDir, function(err) {
|
mkdirp(uploadsDir, function(err) {
|
||||||
|
@ -234,7 +235,7 @@ var re = new RegExp("^[a-f0-9]{32}");
|
||||||
var status = {
|
var status = {
|
||||||
driver: {
|
driver: {
|
||||||
version: require('./package').version,
|
version: require('./package').version,
|
||||||
ipaddress: ip.address()
|
ipaddress: ip.address(),
|
||||||
},
|
},
|
||||||
machine: {
|
machine: {
|
||||||
inputs: [],
|
inputs: [],
|
||||||
|
@ -500,6 +501,12 @@ app.get('/upload', (req, res) => {
|
||||||
res.sendFile(__dirname + '/app/upload.html');
|
res.sendFile(__dirname + '/app/upload.html');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.get('/gcode', (req, res) => {
|
||||||
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
|
res.send(uploadedgcode);
|
||||||
|
})
|
||||||
|
|
||||||
// File Post
|
// File Post
|
||||||
app.post('/upload', function(req, res) {
|
app.post('/upload', function(req, res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
@ -537,37 +544,7 @@ app.post('/upload', function(req, res) {
|
||||||
jogWindow.focus();
|
jogWindow.focus();
|
||||||
jogWindow.setAlwaysOnTop(false);
|
jogWindow.setAlwaysOnTop(false);
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
readFile(file.path)
|
||||||
|
|
||||||
fs.readFile(file.path, 'utf8',
|
|
||||||
function(err, data) {
|
|
||||||
if (err) {
|
|
||||||
console.log(err);
|
|
||||||
var output = {
|
|
||||||
'command': '',
|
|
||||||
'response': "ERROR: File Upload Failed"
|
|
||||||
}
|
|
||||||
io.sockets.emit('data', output);
|
|
||||||
if (jogWindow && !jogWindow.isFocused()) {
|
|
||||||
appIcon.displayBalloon({
|
|
||||||
icon: nativeImage.createFromPath(iconPath),
|
|
||||||
title: "ERROR: File Upload Failed",
|
|
||||||
content: "OpenBuilds Machine Driver ERROR: File Upload Failed"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (data) {
|
|
||||||
io.sockets.emit('gcodeupload', data);
|
|
||||||
if (jogWindow && !jogWindow.isFocused()) {
|
|
||||||
appIcon.displayBalloon({
|
|
||||||
icon: nativeImage.createFromPath(iconPath),
|
|
||||||
title: "GCODE Received",
|
|
||||||
content: "OpenBuilds Machine Driver received new GCODE"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
form.on('aborted', function() {
|
form.on('aborted', function() {
|
||||||
|
@ -890,7 +867,8 @@ io.on("connection", function(socket) {
|
||||||
|
|
||||||
|
|
||||||
socket.on('runJob', function(data) {
|
socket.on('runJob', function(data) {
|
||||||
// console.log(data)
|
console.log(data)
|
||||||
|
uploadedgcode = data;
|
||||||
console.log('Run Job (' + data.length + ')');
|
console.log('Run Job (' + data.length + ')');
|
||||||
if (status.comms.connectionStatus > 0) {
|
if (status.comms.connectionStatus > 0) {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -1512,6 +1490,28 @@ io.on("connection", function(socket) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function readFile(path) {
|
||||||
|
if (path.length > 1) {
|
||||||
|
console.log('readfile: ' + path)
|
||||||
|
fs.readFile(path, 'utf8',
|
||||||
|
function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
var output = {
|
||||||
|
'command': '',
|
||||||
|
'response': "ERROR: File Upload Failed"
|
||||||
|
}
|
||||||
|
uploadedgcode = "";
|
||||||
|
}
|
||||||
|
if (data) {
|
||||||
|
io.sockets.emit('gcodeupload', data);
|
||||||
|
uploadedgcode = data;
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function machineSend(gcode) {
|
function machineSend(gcode) {
|
||||||
// console.log("SENDING: " + gcode)
|
// console.log("SENDING: " + gcode)
|
||||||
if (port.isOpen) {
|
if (port.isOpen) {
|
||||||
|
@ -1917,6 +1917,13 @@ if (isElectron()) {
|
||||||
jogWindow.focus();
|
jogWindow.focus();
|
||||||
jogWindow.setAlwaysOnTop(false);
|
jogWindow.setAlwaysOnTop(false);
|
||||||
}
|
}
|
||||||
|
// console.log('SingleInstance')
|
||||||
|
// console.log(commandLine)
|
||||||
|
var openFilePath = commandLine[1];
|
||||||
|
if (openFilePath !== "") {
|
||||||
|
// console.log(openFilePath);
|
||||||
|
readFile(openFilePath);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (shouldQuit) {
|
if (shouldQuit) {
|
||||||
|
@ -1930,7 +1937,15 @@ if (isElectron()) {
|
||||||
|
|
||||||
function createApp() {
|
function createApp() {
|
||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'win32' && process.argv.length >= 2) {
|
||||||
|
var openFilePath = process.argv[1];
|
||||||
|
if (openFilePath !== "") {
|
||||||
|
console.log("path" + openFilePath);
|
||||||
|
readFile(openFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform == 'darwin' || uploadedgcode.length > 1) {
|
||||||
if (jogWindow === null) {
|
if (jogWindow === null) {
|
||||||
createJogWindow();
|
createJogWindow();
|
||||||
jogWindow.show()
|
jogWindow.show()
|
||||||
|
@ -1946,6 +1961,9 @@ if (isElectron()) {
|
||||||
}
|
}
|
||||||
// createWindow();
|
// createWindow();
|
||||||
// createJogWindow();
|
// createJogWindow();
|
||||||
|
// console.log("createoa")
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTrayIcon() {
|
function createTrayIcon() {
|
||||||
|
@ -2146,4 +2164,6 @@ if (isElectron()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process.on('exit', () => console.log('exit'))
|
process.on('exit', () => console.log('exit'))
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "OpenBuildsMachineDriver",
|
"name": "OpenBuildsMachineDriver",
|
||||||
"version": "1.0.80",
|
"version": "1.0.82",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"description": "Machine Interface Driver for OpenBuilds",
|
"description": "Machine Interface Driver for OpenBuilds",
|
||||||
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
||||||
|
@ -49,6 +49,13 @@
|
||||||
"installerSidebar": "build/installerSidebar.bmp",
|
"installerSidebar": "build/installerSidebar.bmp",
|
||||||
"artifactName": "${productName}-Setup-${version}.${ext}"
|
"artifactName": "${productName}-Setup-${version}.${ext}"
|
||||||
},
|
},
|
||||||
|
"fileAssociations": [
|
||||||
|
{
|
||||||
|
"ext": [".gcode", ".gc", ".tap", ".nc", ".cnc"],
|
||||||
|
"description": "GCODE File",
|
||||||
|
"role": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"**/*",
|
"**/*",
|
||||||
"ssl/**/*"
|
"ssl/**/*"
|
||||||
|
|
Ładowanie…
Reference in New Issue