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