Move all relevant code into comments

This commit is contained in:
mmcwilliams 2019-03-20 15:33:51 -04:00
parent fe85cc1b37
commit 4236651a09
6 changed files with 933 additions and 3 deletions

View File

@ -263,7 +263,317 @@ seq.step = function () {
};
// FROM SERVER SIDE
proj.state = {
dir : true, //default dir
digital : false
}
proj.init = function () {
proj.listen()
}
proj.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.proj_forward
} else {
cmd = mcopy.cfg.arduino.cmd.proj_backward
}
proj.state.dir = dir
if (proj.state.digital) {
dig.set(dir)
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(cmd, id, ms)
}
proj.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.projector
let ms
if (proj.digital) {
try {
ms = await dig.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(mcopy.cfg.arduino.cmd.projector, id, ms)
}
proj.listen = function () {
ipcMain.on('proj', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await proj.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await proj.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.val !== 'undefined') {
dig.state.frame = arg.val
}
event.returnValue = true
})
ipcMain.on('digital', proj.connectDigital)
}
proj.end = async function (cmd, id, ms) {
let message = ''
if (cmd === mcopy.cfg.arduino.cmd.proj_forward) {
message = 'Projector set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.proj_backward) {
message = 'Projector set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.projector) {
message = 'Projector '
if (proj.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'PROJECTOR', true, true)
return await mainWindow.webContents.send('proj', {cmd: cmd, id : id, ms: ms})
}
proj.connectDigital = async function (evt, arg) {
let info;
let frames = 0;
try {
info = await ffprobe.info(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
try {
frames = await ffprobe.frames(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
dig.state.frame = 0;
dig.state.path = arg.path;
dig.state.fileName = arg.fileName;
dig.state.frames = frames;
dig.state.info = info;
//console.dir(dig.state);
log.info(`Opened ${dig.state.fileName}`, 'DIGITAL', true, true);
log.info(`Frames : ${frames}`, 'DIGITAL', true, true);
proj.digital = true;
return await mainWindow.webContents.send('digital', { valid : true, state : JSON.stringify(dig.state) });
}
const dig = {};
dig.state = {
frame : 0,
frames : 0,
path : null,
fileName : null,
info : {},
dir : true
};
dig.set = function (dir) {
dig.state.dir = dir;
}
dig.move = async function () {
let start = +new Date()
let last = dig.state.dir + 0;
if (dig.state.dir) {
dig.state.frame++
} else {
dig.state.frame--
}
if (dig.state.frame < 1) {
dig.state.frame = 1
}
return (+new Date()) - start
}
dig.start = async function () {
try {
await ffmpeg.clearAll()
} catch (err) {
console.error(err)
}
try {
await ffmpeg.frame(dig.state, light.state)
} catch (err) {
console.error(err)
}
display.start(dig.state.frame)
await delay(20)
}
dig.end = async function () {
await delay(20)
display.end()
}
cam.intval = null
cam.state = {
dir : true //default dir
}
cam.init = function () {
cam.listen()
}
cam.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.cam_forward
} else {
cmd = mcopy.cfg.arduino.cmd.cam_backward
}
cam.state.dir = dir
if (cam.intval) {
try {
ms = await cam.intval.setDir(dir)
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
return await cam.end(cmd, id, ms)
}
cam.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.camera
let ms
if (proj.digital) {
await dig.start()
}
if (cam.intval) {
try {
ms = await cam.intval.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
if (proj.digital) {
await dig.end()
}
log.info('Camera move time', { ms })
return cam.end(cmd, id, ms)
}
cam.exposure = function (exposure, id) {
let cmd = 'E'
cam.intval.setExposure('camera', exposure, ms => {
cam.end(cmd, id, ms)
})
}
cam.connectIntval = async function (event, arg) {
return new Promise((resolve, reject) => {
if (arg.connect) {
cam.intval = new Intval(arg.url)
cam.intval.connect((err, ms, state) => {
if (err) {
mainWindow.webContents.send('intval', { connected : false })
log.info(`Cannot connect to ${arg.url}`, 'INTVAL', true, true)
cam.intval = null
delete cam.intval
} else {
mainWindow.webContents.send('intval', { connected : true, url : arg.url, state : state })
log.info(`Connected to INTVAL3 @ ${arg.url}`, 'INTVAL', true, true)
settings.update('camera', { intval : arg.url })
settings.save()
dev.remember('intval', arg.url, 'camera')
}
return resolve(true)
})
} else if (arg.disconnect) {
cam.intval = null
return resolve(false)
}
})
}
cam.listen = function () {
ipcMain.on('cam', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await cam.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await cam.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
}
event.returnValue = true
})
ipcMain.on('intval', cam.connectIntval)
}
cam.end = async function (cmd, id, ms) {
var message = ''
if (cmd === mcopy.cfg.arduino.cmd.cam_forward) {
message = 'Camera set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.cam_backward) {
message = 'Camera set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.camera) {
message = 'Camera '
if (cam.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'CAMERA', true, true)
mainWindow.webContents.send('cam', {cmd: cmd, id : id, ms: ms})
};
const seq = {};
seq.init = function () {
seq.listen();
}
seq.listen = function () {
ipcMain.on('seq', async (evt, arg) => {
if (arg.action === 'stop' && proj.digital) {
display.end()
}
})
}
*/
class Sequence {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,eAAe;AAEf;;;;;;;;;;;;;;QAcQ;AAER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwPG;AACH,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD;;QAEI;IACG,IAAI;IAEX,CAAC;IAEM,IAAI;IAEX,CAAC;IAEM,QAAQ;IAEf,CAAC;IAED,SAAS;IACD,GAAG;IAEX,CAAC;IACO,IAAI;IAEZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY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AE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}

View File

@ -263,7 +263,317 @@ seq.step = function () {
};
// FROM SERVER SIDE
proj.state = {
dir : true, //default dir
digital : false
}
proj.init = function () {
proj.listen()
}
proj.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.proj_forward
} else {
cmd = mcopy.cfg.arduino.cmd.proj_backward
}
proj.state.dir = dir
if (proj.state.digital) {
dig.set(dir)
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(cmd, id, ms)
}
proj.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.projector
let ms
if (proj.digital) {
try {
ms = await dig.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(mcopy.cfg.arduino.cmd.projector, id, ms)
}
proj.listen = function () {
ipcMain.on('proj', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await proj.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await proj.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.val !== 'undefined') {
dig.state.frame = arg.val
}
event.returnValue = true
})
ipcMain.on('digital', proj.connectDigital)
}
proj.end = async function (cmd, id, ms) {
let message = ''
if (cmd === mcopy.cfg.arduino.cmd.proj_forward) {
message = 'Projector set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.proj_backward) {
message = 'Projector set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.projector) {
message = 'Projector '
if (proj.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'PROJECTOR', true, true)
return await mainWindow.webContents.send('proj', {cmd: cmd, id : id, ms: ms})
}
proj.connectDigital = async function (evt, arg) {
let info;
let frames = 0;
try {
info = await ffprobe.info(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
try {
frames = await ffprobe.frames(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
dig.state.frame = 0;
dig.state.path = arg.path;
dig.state.fileName = arg.fileName;
dig.state.frames = frames;
dig.state.info = info;
//console.dir(dig.state);
log.info(`Opened ${dig.state.fileName}`, 'DIGITAL', true, true);
log.info(`Frames : ${frames}`, 'DIGITAL', true, true);
proj.digital = true;
return await mainWindow.webContents.send('digital', { valid : true, state : JSON.stringify(dig.state) });
}
const dig = {};
dig.state = {
frame : 0,
frames : 0,
path : null,
fileName : null,
info : {},
dir : true
};
dig.set = function (dir) {
dig.state.dir = dir;
}
dig.move = async function () {
let start = +new Date()
let last = dig.state.dir + 0;
if (dig.state.dir) {
dig.state.frame++
} else {
dig.state.frame--
}
if (dig.state.frame < 1) {
dig.state.frame = 1
}
return (+new Date()) - start
}
dig.start = async function () {
try {
await ffmpeg.clearAll()
} catch (err) {
console.error(err)
}
try {
await ffmpeg.frame(dig.state, light.state)
} catch (err) {
console.error(err)
}
display.start(dig.state.frame)
await delay(20)
}
dig.end = async function () {
await delay(20)
display.end()
}
cam.intval = null
cam.state = {
dir : true //default dir
}
cam.init = function () {
cam.listen()
}
cam.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.cam_forward
} else {
cmd = mcopy.cfg.arduino.cmd.cam_backward
}
cam.state.dir = dir
if (cam.intval) {
try {
ms = await cam.intval.setDir(dir)
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
return await cam.end(cmd, id, ms)
}
cam.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.camera
let ms
if (proj.digital) {
await dig.start()
}
if (cam.intval) {
try {
ms = await cam.intval.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
if (proj.digital) {
await dig.end()
}
log.info('Camera move time', { ms })
return cam.end(cmd, id, ms)
}
cam.exposure = function (exposure, id) {
let cmd = 'E'
cam.intval.setExposure('camera', exposure, ms => {
cam.end(cmd, id, ms)
})
}
cam.connectIntval = async function (event, arg) {
return new Promise((resolve, reject) => {
if (arg.connect) {
cam.intval = new Intval(arg.url)
cam.intval.connect((err, ms, state) => {
if (err) {
mainWindow.webContents.send('intval', { connected : false })
log.info(`Cannot connect to ${arg.url}`, 'INTVAL', true, true)
cam.intval = null
delete cam.intval
} else {
mainWindow.webContents.send('intval', { connected : true, url : arg.url, state : state })
log.info(`Connected to INTVAL3 @ ${arg.url}`, 'INTVAL', true, true)
settings.update('camera', { intval : arg.url })
settings.save()
dev.remember('intval', arg.url, 'camera')
}
return resolve(true)
})
} else if (arg.disconnect) {
cam.intval = null
return resolve(false)
}
})
}
cam.listen = function () {
ipcMain.on('cam', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await cam.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await cam.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
}
event.returnValue = true
})
ipcMain.on('intval', cam.connectIntval)
}
cam.end = async function (cmd, id, ms) {
var message = ''
if (cmd === mcopy.cfg.arduino.cmd.cam_forward) {
message = 'Camera set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.cam_backward) {
message = 'Camera set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.camera) {
message = 'Camera '
if (cam.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'CAMERA', true, true)
mainWindow.webContents.send('cam', {cmd: cmd, id : id, ms: ms})
};
const seq = {};
seq.init = function () {
seq.listen();
}
seq.listen = function () {
ipcMain.on('seq', async (evt, arg) => {
if (arg.action === 'stop' && proj.digital) {
display.end()
}
})
}
*/
class Sequence {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,eAAe;AAEf;;;;;;;;;;;;;;QAcQ;AAER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwPG;AACH,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD;;QAEI;IACG,IAAI;IAEX,CAAC;IAEM,IAAI;IAEX,CAAC;IAEM,QAAQ;IAEf,CAAC;IAED,SAAS;IACD,GAAG;IAEX,CAAC;IACO,IAAI;IAEZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"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AAU,GAAS,EAAE,GAAS,EAAE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}

View File

@ -263,7 +263,317 @@ seq.step = function () {
};
// FROM SERVER SIDE
proj.state = {
dir : true, //default dir
digital : false
}
proj.init = function () {
proj.listen()
}
proj.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.proj_forward
} else {
cmd = mcopy.cfg.arduino.cmd.proj_backward
}
proj.state.dir = dir
if (proj.state.digital) {
dig.set(dir)
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(cmd, id, ms)
}
proj.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.projector
let ms
if (proj.digital) {
try {
ms = await dig.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(mcopy.cfg.arduino.cmd.projector, id, ms)
}
proj.listen = function () {
ipcMain.on('proj', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await proj.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await proj.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.val !== 'undefined') {
dig.state.frame = arg.val
}
event.returnValue = true
})
ipcMain.on('digital', proj.connectDigital)
}
proj.end = async function (cmd, id, ms) {
let message = ''
if (cmd === mcopy.cfg.arduino.cmd.proj_forward) {
message = 'Projector set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.proj_backward) {
message = 'Projector set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.projector) {
message = 'Projector '
if (proj.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'PROJECTOR', true, true)
return await mainWindow.webContents.send('proj', {cmd: cmd, id : id, ms: ms})
}
proj.connectDigital = async function (evt, arg) {
let info;
let frames = 0;
try {
info = await ffprobe.info(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
try {
frames = await ffprobe.frames(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
dig.state.frame = 0;
dig.state.path = arg.path;
dig.state.fileName = arg.fileName;
dig.state.frames = frames;
dig.state.info = info;
//console.dir(dig.state);
log.info(`Opened ${dig.state.fileName}`, 'DIGITAL', true, true);
log.info(`Frames : ${frames}`, 'DIGITAL', true, true);
proj.digital = true;
return await mainWindow.webContents.send('digital', { valid : true, state : JSON.stringify(dig.state) });
}
const dig = {};
dig.state = {
frame : 0,
frames : 0,
path : null,
fileName : null,
info : {},
dir : true
};
dig.set = function (dir) {
dig.state.dir = dir;
}
dig.move = async function () {
let start = +new Date()
let last = dig.state.dir + 0;
if (dig.state.dir) {
dig.state.frame++
} else {
dig.state.frame--
}
if (dig.state.frame < 1) {
dig.state.frame = 1
}
return (+new Date()) - start
}
dig.start = async function () {
try {
await ffmpeg.clearAll()
} catch (err) {
console.error(err)
}
try {
await ffmpeg.frame(dig.state, light.state)
} catch (err) {
console.error(err)
}
display.start(dig.state.frame)
await delay(20)
}
dig.end = async function () {
await delay(20)
display.end()
}
cam.intval = null
cam.state = {
dir : true //default dir
}
cam.init = function () {
cam.listen()
}
cam.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.cam_forward
} else {
cmd = mcopy.cfg.arduino.cmd.cam_backward
}
cam.state.dir = dir
if (cam.intval) {
try {
ms = await cam.intval.setDir(dir)
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
return await cam.end(cmd, id, ms)
}
cam.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.camera
let ms
if (proj.digital) {
await dig.start()
}
if (cam.intval) {
try {
ms = await cam.intval.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
if (proj.digital) {
await dig.end()
}
log.info('Camera move time', { ms })
return cam.end(cmd, id, ms)
}
cam.exposure = function (exposure, id) {
let cmd = 'E'
cam.intval.setExposure('camera', exposure, ms => {
cam.end(cmd, id, ms)
})
}
cam.connectIntval = async function (event, arg) {
return new Promise((resolve, reject) => {
if (arg.connect) {
cam.intval = new Intval(arg.url)
cam.intval.connect((err, ms, state) => {
if (err) {
mainWindow.webContents.send('intval', { connected : false })
log.info(`Cannot connect to ${arg.url}`, 'INTVAL', true, true)
cam.intval = null
delete cam.intval
} else {
mainWindow.webContents.send('intval', { connected : true, url : arg.url, state : state })
log.info(`Connected to INTVAL3 @ ${arg.url}`, 'INTVAL', true, true)
settings.update('camera', { intval : arg.url })
settings.save()
dev.remember('intval', arg.url, 'camera')
}
return resolve(true)
})
} else if (arg.disconnect) {
cam.intval = null
return resolve(false)
}
})
}
cam.listen = function () {
ipcMain.on('cam', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await cam.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await cam.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
}
event.returnValue = true
})
ipcMain.on('intval', cam.connectIntval)
}
cam.end = async function (cmd, id, ms) {
var message = ''
if (cmd === mcopy.cfg.arduino.cmd.cam_forward) {
message = 'Camera set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.cam_backward) {
message = 'Camera set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.camera) {
message = 'Camera '
if (cam.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'CAMERA', true, true)
mainWindow.webContents.send('cam', {cmd: cmd, id : id, ms: ms})
};
const seq = {};
seq.init = function () {
seq.listen();
}
seq.listen = function () {
ipcMain.on('seq', async (evt, arg) => {
if (arg.action === 'stop' && proj.digital) {
display.end()
}
})
}
*/
class Sequence {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,eAAe;AAEf;;;;;;;;;;;;;;QAcQ;AAER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwPG;AACH,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD;;QAEI;IACG,IAAI;IAEX,CAAC;IAEM,IAAI;IAEX,CAAC;IAEM,QAAQ;IAEf,CAAC;IAED,SAAS;IACD,GAAG;IAEX,CAAC;IACO,IAAI;IAEZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
{"version":3,"file":"index.js","sourceRo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