Merge all work on server with filmout features #77
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Delay in an async/await function
|
||||
*
|
||||
* @param {integer} ms Milliseconds to delay for
|
||||
*
|
||||
* @returns {Promise} Promise to resolve after timeout
|
||||
**/
|
||||
declare function delay(ms: number): Promise<unknown>;
|
|
@ -425,9 +425,11 @@ class FilmOut {
|
|||
async focus(evt, arg) {
|
||||
this.log.info(`Showing focus screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('focus')) {
|
||||
return;
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.focus();
|
||||
await this.server.cmdAll('focus');
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
|
@ -440,9 +442,11 @@ class FilmOut {
|
|||
const ratio = arg.ratio;
|
||||
this.log.info(`Showing field guide screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('field', { ratio })) {
|
||||
return;
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.field(ratio);
|
||||
await this.server.cmdAll('field', { ratio });
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
|
@ -454,9 +458,11 @@ class FilmOut {
|
|||
async meter(evt, arg) {
|
||||
this.log.info(`Showing meter screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('meter')) {
|
||||
return;
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.meter();
|
||||
await this.server.cmdAll('meter');
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
|
@ -467,9 +473,11 @@ class FilmOut {
|
|||
**/
|
||||
async close(evt, arg) {
|
||||
try {
|
||||
if (await this.server.cmdAll('blank')) {
|
||||
return;
|
||||
}
|
||||
await this.display.hide();
|
||||
await this.display.close();
|
||||
await this.server.cmdAll('blank');
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -41,7 +41,6 @@ class Server {
|
|||
tmpl.data = await promises_1.readFile(tmpl.path, 'utf8');
|
||||
}
|
||||
this.http.get('/', this.index.bind(this));
|
||||
this.http.get('/client.js', this.script.bind(this));
|
||||
this.http.get('/image/:key', this.image.bind(this));
|
||||
this.log.info("Server assets loaded");
|
||||
}
|
||||
|
@ -110,16 +109,11 @@ class Server {
|
|||
this.isActive = false;
|
||||
}
|
||||
index(req, res, next) {
|
||||
const html = this.template('index', { PORT: `${this.port}` });
|
||||
const SCRIPT = this.template('script', { PORT: `${this.wsPort}` });
|
||||
const html = this.template('index', { SCRIPT });
|
||||
this.log.info('GET /');
|
||||
return res.send(html);
|
||||
}
|
||||
script(req, res, next) {
|
||||
const js = this.template('script', { PORT: `${this.wsPort}` });
|
||||
res.contentType('text/javascript');
|
||||
this.log.info('GET /script.js');
|
||||
return res.send(js);
|
||||
}
|
||||
async image(req, res, next) {
|
||||
let filePath;
|
||||
if (req.params && req.params.key) {
|
||||
|
@ -158,7 +152,8 @@ class Server {
|
|||
this.wss.clients.forEach(function (ws) {
|
||||
cmds.push(this.cmd(ws, action, options));
|
||||
}.bind(this));
|
||||
return await Promise.all(cmds);
|
||||
await Promise.all(cmds);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
</div>
|
||||
<canvas id="can">
|
||||
</canvas>
|
||||
<script src="http://localhost:{{PORT}}/client.js"></script>
|
||||
<script>
|
||||
{{SCRIPT}}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mcopy",
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"arduino": "file:app/lib/arduino",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"description": "Small gauge film optical printer platform",
|
||||
"main": "build.js",
|
||||
"directories": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.13",
|
||||
"version": "1.7.14",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -444,9 +444,11 @@ class FilmOut {
|
|||
async focus (evt : any, arg : any) {
|
||||
this.log.info(`Showing focus screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('focus')) {
|
||||
return
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.focus();
|
||||
await this.server.cmdAll('focus')
|
||||
} catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
}
|
||||
|
@ -458,9 +460,12 @@ class FilmOut {
|
|||
const ratio : number = arg.ratio;
|
||||
this.log.info(`Showing field guide screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('field', { ratio })) {
|
||||
return
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.field(ratio);
|
||||
await this.server.cmdAll('field', { ratio });
|
||||
|
||||
} catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
}
|
||||
|
@ -471,9 +476,11 @@ class FilmOut {
|
|||
async meter (evt : any, arg : any) {
|
||||
this.log.info(`Showing meter screen`);
|
||||
try {
|
||||
if (await this.server.cmdAll('meter')) {
|
||||
return
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.meter();
|
||||
await this.server.cmdAll('meter');
|
||||
} catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
}
|
||||
|
@ -483,9 +490,12 @@ class FilmOut {
|
|||
**/
|
||||
async close (evt : any, arg : any) {
|
||||
try {
|
||||
if (await this.server.cmdAll('blank')) {
|
||||
return
|
||||
}
|
||||
await this.display.hide();
|
||||
await this.display.close();
|
||||
await this.server.cmdAll('blank');
|
||||
|
||||
} catch (err) {
|
||||
this.log.error(err, 'FILMOUT', true, true);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import { delay } from 'delay';
|
|||
interface ServerData {
|
||||
[key: string]: string;
|
||||
PORT? : string;
|
||||
SCRIPT? : string;
|
||||
}
|
||||
|
||||
interface ServerTemplate {
|
||||
|
@ -71,7 +72,6 @@ class Server {
|
|||
}
|
||||
|
||||
this.http.get('/', this.index.bind(this))
|
||||
this.http.get('/client.js', this.script.bind(this))
|
||||
this.http.get('/image/:key', this.image.bind(this))
|
||||
|
||||
this.log.info("Server assets loaded")
|
||||
|
@ -150,16 +150,11 @@ class Server {
|
|||
}
|
||||
|
||||
index (req : Request, res : Response, next : Function) {
|
||||
const html : string = this.template('index', { PORT : `${this.port}` })
|
||||
const SCRIPT = this.template('script', { PORT : `${this.wsPort}` })
|
||||
const html : string = this.template('index', { SCRIPT })
|
||||
this.log.info('GET /')
|
||||
return res.send(html)
|
||||
}
|
||||
script (req : Request, res : Response, next : Function) {
|
||||
const js : string = this.template('script', { PORT : `${this.wsPort}` })
|
||||
res.contentType('text/javascript')
|
||||
this.log.info('GET /script.js')
|
||||
return res.send(js)
|
||||
}
|
||||
|
||||
async image (req : Request, res : Response, next : Function) {
|
||||
let filePath : string
|
||||
|
@ -199,7 +194,8 @@ class Server {
|
|||
this.wss.clients.forEach(function (ws : WebSocket) {
|
||||
cmds.push(this.cmd(ws, action, options))
|
||||
}.bind(this))
|
||||
return await Promise.all(cmds)
|
||||
await Promise.all(cmds)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue