Add all work on filmout manager from laptop
This commit is contained in:
parent
8fc6bd43b9
commit
f0b49874f6
|
@ -6,4 +6,5 @@ WIDTH=2560
|
||||||
HEIGHT=1600
|
HEIGHT=1600
|
||||||
FD=../filmout_display/build/bin/fd
|
FD=../filmout_display/build/bin/fd
|
||||||
FD_HOST=localhost
|
FD_HOST=localhost
|
||||||
FD_PORT=8081
|
FD_PORT=8081
|
||||||
|
SEQUENCES=/home/user/SEQUENCES
|
|
@ -0,0 +1 @@
|
||||||
|
export declare function delay(ms: number): Promise<unknown>;
|
|
@ -0,0 +1,52 @@
|
||||||
|
declare enum Action {
|
||||||
|
NONE = 0,
|
||||||
|
LOAD = 1,
|
||||||
|
DISPLAY = 2,
|
||||||
|
STOP = 3
|
||||||
|
}
|
||||||
|
declare enum Mode {
|
||||||
|
RGB = 0,
|
||||||
|
BW = 1,
|
||||||
|
INVERT = 2,
|
||||||
|
BW_INVERT = 3,
|
||||||
|
RGB_CHANNELS = 4,
|
||||||
|
INVERT_CHANNELS = 5
|
||||||
|
}
|
||||||
|
export interface fdOutgoingMessage {
|
||||||
|
action: Action;
|
||||||
|
image: string;
|
||||||
|
mode?: Mode;
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
|
w?: number;
|
||||||
|
h?: number;
|
||||||
|
exposure?: number[];
|
||||||
|
}
|
||||||
|
export interface fdIncomingMessage {
|
||||||
|
action: Action;
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
export declare class FD {
|
||||||
|
private bin;
|
||||||
|
private width;
|
||||||
|
private height;
|
||||||
|
private host;
|
||||||
|
private port;
|
||||||
|
private shell;
|
||||||
|
private log;
|
||||||
|
private client;
|
||||||
|
private socketAvailable;
|
||||||
|
private socketConnected;
|
||||||
|
constructor(bin: string, width: number, height: number, host: string, port: number);
|
||||||
|
private startDisplay;
|
||||||
|
private startClient;
|
||||||
|
private logstd;
|
||||||
|
private logsterr;
|
||||||
|
private test;
|
||||||
|
private send;
|
||||||
|
private receive;
|
||||||
|
load(image: string, x: number, y: number, w: number, h: number): Promise<boolean>;
|
||||||
|
display(image: string, exposure: number[]): Promise<boolean>;
|
||||||
|
stop(image: string): Promise<boolean>;
|
||||||
|
}
|
||||||
|
export {};
|
|
@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.FD = exports.Mode = exports.Action = void 0;
|
exports.FD = void 0;
|
||||||
const net_1 = __importDefault(require("net"));
|
const net_1 = __importDefault(require("net"));
|
||||||
const log_1 = require("../log");
|
const log_1 = require("../log");
|
||||||
const shell_1 = require("../shell");
|
const shell_1 = require("../shell");
|
||||||
|
@ -14,8 +14,7 @@ var Action;
|
||||||
Action[Action["LOAD"] = 1] = "LOAD";
|
Action[Action["LOAD"] = 1] = "LOAD";
|
||||||
Action[Action["DISPLAY"] = 2] = "DISPLAY";
|
Action[Action["DISPLAY"] = 2] = "DISPLAY";
|
||||||
Action[Action["STOP"] = 3] = "STOP";
|
Action[Action["STOP"] = 3] = "STOP";
|
||||||
})(Action || (exports.Action = Action = {}));
|
})(Action || (Action = {}));
|
||||||
;
|
|
||||||
var Mode;
|
var Mode;
|
||||||
(function (Mode) {
|
(function (Mode) {
|
||||||
Mode[Mode["RGB"] = 0] = "RGB";
|
Mode[Mode["RGB"] = 0] = "RGB";
|
||||||
|
@ -24,8 +23,7 @@ var Mode;
|
||||||
Mode[Mode["BW_INVERT"] = 3] = "BW_INVERT";
|
Mode[Mode["BW_INVERT"] = 3] = "BW_INVERT";
|
||||||
Mode[Mode["RGB_CHANNELS"] = 4] = "RGB_CHANNELS";
|
Mode[Mode["RGB_CHANNELS"] = 4] = "RGB_CHANNELS";
|
||||||
Mode[Mode["INVERT_CHANNELS"] = 5] = "INVERT_CHANNELS";
|
Mode[Mode["INVERT_CHANNELS"] = 5] = "INVERT_CHANNELS";
|
||||||
})(Mode || (exports.Mode = Mode = {}));
|
})(Mode || (Mode = {}));
|
||||||
;
|
|
||||||
class FD {
|
class FD {
|
||||||
constructor(bin, width, height, host, port) {
|
constructor(bin, width, height, host, port) {
|
||||||
this.socketAvailable = false;
|
this.socketAvailable = false;
|
||||||
|
@ -95,7 +93,7 @@ class FD {
|
||||||
this.log.info(msg);
|
this.log.info(msg);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
load(image, x, y, w, h) {
|
async load(image, x, y, w, h) {
|
||||||
const msg = {
|
const msg = {
|
||||||
action: Action.LOAD,
|
action: Action.LOAD,
|
||||||
image,
|
image,
|
||||||
|
@ -107,7 +105,7 @@ class FD {
|
||||||
this.send(msg);
|
this.send(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
display(image, exposure) {
|
async display(image, exposure) {
|
||||||
const msg = {
|
const msg = {
|
||||||
action: Action.DISPLAY,
|
action: Action.DISPLAY,
|
||||||
image,
|
image,
|
||||||
|
@ -116,6 +114,14 @@ class FD {
|
||||||
this.send(msg);
|
this.send(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
async stop(image) {
|
||||||
|
const msg = {
|
||||||
|
action: Action.STOP,
|
||||||
|
image
|
||||||
|
};
|
||||||
|
this.send(msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.FD = FD;
|
exports.FD = FD;
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fd/index.ts"],"names":[],"mappings":";;;;;;AACA,8CAAsB;AAEtB,gCAAkC;AAClC,oCAAiC;AACjC,oCAAiC;AAEjC,IAAY,MAKX;AALD,WAAY,MAAM;IACjB,mCAAI,CAAA;IACJ,mCAAI,CAAA;IACJ,yCAAO,CA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AAK;YACL,QAAQ;SACR,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,IAAI,CAAE,KAAc;QAChC,MAAM,GAAG,GAAuB;YAC/B,MAAM,EAAG,MAAM,CAAC,IAAI;YACpB,KAAK;SACL,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAxHD,gBAwHC"}
|
|
@ -0,0 +1,10 @@
|
||||||
|
interface SequenceObject {
|
||||||
|
path: string;
|
||||||
|
hash: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export declare class Files {
|
||||||
|
static exists(path: string): Promise<boolean>;
|
||||||
|
static enumerateSequences(path: string): Promise<SequenceObject[]>;
|
||||||
|
}
|
||||||
|
export type { SequenceObject };
|
|
@ -0,0 +1,50 @@
|
||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Files = void 0;
|
||||||
|
const promises_1 = __importDefault(require("fs/promises"));
|
||||||
|
const hash_1 = require("../hash");
|
||||||
|
const path_1 = require("path");
|
||||||
|
class Files {
|
||||||
|
static async exists(path) {
|
||||||
|
try {
|
||||||
|
await promises_1.default.access(path);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async enumerateSequences(path) {
|
||||||
|
const dirs = [];
|
||||||
|
let all;
|
||||||
|
let stats;
|
||||||
|
try {
|
||||||
|
all = await promises_1.default.readdir(path);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
for (let elem of all) {
|
||||||
|
try {
|
||||||
|
stats = await promises_1.default.lstat(elem);
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
dirs.push({
|
||||||
|
path: elem,
|
||||||
|
hash: hash_1.Hashes.stringHash(elem),
|
||||||
|
name: (0, path_1.basename)(elem)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Files = Files;
|
||||||
|
module.exports = { Files };
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAE7B,kCAAiC;AACjC,+BAAgC;AAQhC,MAAa,KAAK;IACV,MAAM,CAAC,KAAK,CAAC,MAAM,CAAE,IAAa;QACxC,IAAI,CAAC;YACJ,MAAM,kBAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAE,IAAa;QACpD,MAAM,IAAI,GAAsB,EAAE,CAAC;QACnC,IAAI,GAAc,CAAC;QACnB,IAAI,KAAa,CAAC;QAClB,IAAI,CAAC;YACJ,GAAG,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,GAAG,CAAC;QACX,CAAC;QAED,KAAK,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC;gBACJ,KAAK,GAAG,MAAM,kBAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC1B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBACzB,IAAI,CAAC,IAAI,CAAC;wBACT,IAAI,EAAG,IAAI;wBACX,IAAI,EAAG,aAAM,CAAC,UAAU,CAAC,IAAI,CAAC;wBAC9B,IAAI,EAAG,IAAA,eAAQ,EAAC,IAAI,CAAC;qBACrB,CAAC,CAAC;gBACJ,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,EAAE;YACH,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AArCD,sBAqCC;AAGD,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC"}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export declare class Hashes {
|
||||||
|
static fileHash(path: string): Promise<string>;
|
||||||
|
static stringHash(str: string): string;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Hashes = void 0;
|
||||||
|
const crypto_1 = require("crypto");
|
||||||
|
const fs_1 = require("fs");
|
||||||
|
class Hashes {
|
||||||
|
static async fileHash(path) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const hashSum = (0, crypto_1.createHash)('sha256');
|
||||||
|
const stream = (0, fs_1.createReadStream)(path);
|
||||||
|
stream.on('error', (err) => reject(err));
|
||||||
|
stream.on('data', (chunk) => hashSum.update(chunk));
|
||||||
|
stream.on('end', () => resolve(hashSum.digest('hex')));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static stringHash(str) {
|
||||||
|
const sha = (0, crypto_1.createHash)('sha256').update(str);
|
||||||
|
return sha.digest('hex');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Hashes = Hashes;
|
||||||
|
module.exports = { Hashes };
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hash/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAC1C,2BAAsC;AAEtC,MAAa,MAAM;IAClB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAE,IAAa;QACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAkB,EAAE,MAAiB,EAAE,EAAE;YAC5D,MAAM,OAAO,GAAU,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAS,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,UAAU,CAAE,GAAY;QAC9B,MAAM,GAAG,GAAU,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpD,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD;AAfD,wBAeC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,CAAC"}
|
|
@ -0,0 +1 @@
|
||||||
|
import 'dotenv/config';
|
|
@ -1,12 +1,62 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("dotenv/config");
|
require("dotenv/config");
|
||||||
|
const express_1 = __importDefault(require("express"));
|
||||||
|
const promises_1 = __importDefault(require("fs/promises"));
|
||||||
|
const body_parser_1 = __importDefault(require("body-parser"));
|
||||||
|
const Handlebars = __importStar(require("handlebars"));
|
||||||
const log_1 = require("./log");
|
const log_1 = require("./log");
|
||||||
const fd_1 = require("./fd");
|
const files_1 = require("./files");
|
||||||
|
const log = (0, log_1.createLog)('fm');
|
||||||
|
const app = (0, express_1.default)();
|
||||||
let fd;
|
let fd;
|
||||||
let log = (0, log_1.createLog)('fm');
|
let index;
|
||||||
log.info('Starting filmout_manager');
|
let port;
|
||||||
function settings() {
|
let sequences;
|
||||||
|
let width;
|
||||||
|
let height;
|
||||||
|
log.info('Starting filmout_manager...');
|
||||||
|
app.use(body_parser_1.default.json());
|
||||||
|
app.use(body_parser_1.default.urlencoded({ extended: true }));
|
||||||
|
async function createTemplate(filePath) {
|
||||||
|
let tmpl;
|
||||||
|
try {
|
||||||
|
tmpl = await promises_1.default.readFile(filePath, 'utf8');
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
log.error(err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Handlebars.compile(tmpl);
|
||||||
|
}
|
||||||
|
async function settings() {
|
||||||
|
let sequencesExists = false;
|
||||||
if (typeof process.env['FD'] === 'undefined') {
|
if (typeof process.env['FD'] === 'undefined') {
|
||||||
log.error('Please include an FD value containing the path to your fd binary in .env');
|
log.error('Please include an FD value containing the path to your fd binary in .env');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -19,14 +69,16 @@ function settings() {
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.info(`WIDTH=${process.env['WIDTH']}`);
|
width = parseInt(process.env['WIDTH']);
|
||||||
|
log.info(`WIDTH=${width}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['HEIGHT'] === 'undefined') {
|
if (typeof process.env['HEIGHT'] === 'undefined') {
|
||||||
log.error('Please include a HEIGHT value containing the height of the screen you are using in .env');
|
log.error('Please include a HEIGHT value containing the height of the screen you are using in .env');
|
||||||
process.exit(3);
|
process.exit(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.info(`HEIGHT=${process.env['HEIGHT']}`);
|
height = parseInt(process.env['HEIGHT']);
|
||||||
|
log.info(`HEIGHT=${height}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['FD_HOST'] === 'undefined') {
|
if (typeof process.env['FD_HOST'] === 'undefined') {
|
||||||
log.error('Please include a FD_HOST value with the host that the fd socket server is hosted on in .env');
|
log.error('Please include a FD_HOST value with the host that the fd socket server is hosted on in .env');
|
||||||
|
@ -36,16 +88,46 @@ function settings() {
|
||||||
log.info(`FD_HOST=${process.env['FD_HOST']}`);
|
log.info(`FD_HOST=${process.env['FD_HOST']}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['FD_PORT'] === 'undefined') {
|
if (typeof process.env['FD_PORT'] === 'undefined') {
|
||||||
log.error('Please include a FD_PORT value with the port that the fd socket server is hosted in in .env');
|
log.error('Please include a FD_PORT value with the port that the fd socket server is hosted on in .env');
|
||||||
process.exit(5);
|
process.exit(5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.info(`FD_PORT=${process.env['FD_PORT']}`);
|
log.info(`FD_PORT=${process.env['FD_PORT']}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['PORT'] === 'undefined') {
|
||||||
|
log.error('Please include a PORT value with the port that the HTTP web process is hosted on in .env');
|
||||||
|
process.exit(6);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
port = parseInt(process.env['PORT']);
|
||||||
|
log.info(`PORT=${port}`);
|
||||||
|
}
|
||||||
|
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
||||||
|
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
||||||
|
process.exit(7);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sequences = process.env['SEQUENCES'];
|
||||||
|
sequencesExists = await files_1.Files.exists(sequences);
|
||||||
|
if (!sequencesExists) {
|
||||||
|
log.error(`The SEQUENCES directory in .env, ${sequences}, does not exist`);
|
||||||
|
process.exit(8);
|
||||||
|
}
|
||||||
|
log.info(`SEQUENCES=${sequences}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
app.get('/', async (req, res, next) => {
|
||||||
|
const dirs = await files_1.Files.enumerateSequences(sequences);
|
||||||
|
const html = index({ dirs, width, height });
|
||||||
|
res.send(html);
|
||||||
|
});
|
||||||
async function main() {
|
async function main() {
|
||||||
settings();
|
await settings();
|
||||||
fd = new fd_1.FD(process.env['FD'], parseInt(process.env['WIDTH']), parseInt(process.env['HEIGHT']), process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
index = await createTemplate('./views/index.hbs');
|
||||||
|
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
||||||
|
app.listen(port, async () => {
|
||||||
|
log.info(`filmout_manager HTTP server running on port ${port}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
main();
|
main();
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AAgBtB,+BAAiC;AAIjC,6BAA0B;AAG1B,IAAI,EAAO,CAAC;AAEZ,IAAI,GAAG,GAAY,IAAA,eAAS,EAAC,IAAI,CAAC,CAAC;AAEnC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;AAErC,SAAS,QAAQ;IAChB,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE,CAAC;QAC9C,GAAG,CAAC,KAAK,CAAC,0EAA0E,CAAC,CAAC;QACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;SAAM,CAAC;QACP,GAAG,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,WAAW,EAAE,CAAC;QACjD,GAAG,CAAC,KAAK,CAAC,uFAAuF,CAAC,CAAC;QACnG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;SAAM,CAAC;QACP,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,WAAW,EAAE,CAAC;QAClD,GAAG,CAAC,KAAK,CAAC,yFAAyF,CAAC,CAAC;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AI,GAAsB,MAAM,aAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAY,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI;IAClB,MAAM,QAAQ,EAAE,CAAC;IACjB,KAAK,GAAG,MAAM,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAClD,6GAA6G;IAC7G,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;QAC3B,GAAG,CAAC,IAAI,CAAC,+CAA+C,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@ -0,0 +1,9 @@
|
||||||
|
/**
|
||||||
|
* Returns a winston logger configured to service
|
||||||
|
*
|
||||||
|
* @param {string} label Label appearing on logger
|
||||||
|
* @param {string} filename Optional file to write log to
|
||||||
|
*
|
||||||
|
* @returns {object} Winston logger
|
||||||
|
*/
|
||||||
|
export declare function createLog(label: string, filename?: string): import("winston").Logger;
|
|
@ -0,0 +1 @@
|
||||||
|
export declare function sendMail(to: string, subject: string, body: string): Promise<boolean>;
|
|
@ -0,0 +1,14 @@
|
||||||
|
export declare class Shell {
|
||||||
|
private child;
|
||||||
|
private log;
|
||||||
|
private bin;
|
||||||
|
private args;
|
||||||
|
private lines;
|
||||||
|
private stdio;
|
||||||
|
private stderr;
|
||||||
|
private after;
|
||||||
|
private silent;
|
||||||
|
constructor(args: any[], stdio?: Function, stderr?: Function, after?: Function, silent?: boolean);
|
||||||
|
execute(): Promise<number>;
|
||||||
|
kill(): void;
|
||||||
|
}
|
|
@ -5,21 +5,21 @@ import { createLog } from '../log'
|
||||||
import { Shell } from '../shell';
|
import { Shell } from '../shell';
|
||||||
import { delay } from '../delay';
|
import { delay } from '../delay';
|
||||||
|
|
||||||
export enum Action {
|
enum Action {
|
||||||
NONE,
|
NONE,
|
||||||
LOAD,
|
LOAD,
|
||||||
DISPLAY,
|
DISPLAY,
|
||||||
STOP
|
STOP
|
||||||
};
|
}
|
||||||
|
|
||||||
export enum Mode {
|
enum Mode {
|
||||||
RGB,
|
RGB,
|
||||||
BW,
|
BW,
|
||||||
INVERT,
|
INVERT,
|
||||||
BW_INVERT,
|
BW_INVERT,
|
||||||
RGB_CHANNELS,
|
RGB_CHANNELS,
|
||||||
INVERT_CHANNELS
|
INVERT_CHANNELS
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface fdOutgoingMessage {
|
export interface fdOutgoingMessage {
|
||||||
action : Action,
|
action : Action,
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
import fs from 'fs/promises';
|
||||||
|
import type { Stats } from 'fs';
|
||||||
|
import { Hashes } from '../hash';
|
||||||
|
import { basename } from 'path';
|
||||||
|
|
||||||
|
interface SequenceObject {
|
||||||
|
path : string,
|
||||||
|
hash : string,
|
||||||
|
name : string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Files {
|
||||||
|
public static async exists (path : string) : Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await fs.access(path);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async enumerateSequences (path : string) : Promise<SequenceObject[]> {
|
||||||
|
const dirs : SequenceObject[] = [];
|
||||||
|
let all : string[];
|
||||||
|
let stats : Stats;
|
||||||
|
try {
|
||||||
|
all = await fs.readdir(path)
|
||||||
|
} catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let elem of all) {
|
||||||
|
try {
|
||||||
|
stats = await fs.lstat(elem);
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
dirs.push({
|
||||||
|
path : elem,
|
||||||
|
hash : Hashes.stringHash(elem),
|
||||||
|
name : basename(elem)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { SequenceObject };
|
||||||
|
module.exports = { Files };
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { createHash, Hash } from 'crypto';
|
||||||
|
import { createReadStream } from 'fs';
|
||||||
|
|
||||||
|
export class Hashes {
|
||||||
|
static async fileHash (path : string) : Promise<string> {
|
||||||
|
return new Promise((resolve : Function, reject : Function) => {
|
||||||
|
const hashSum : Hash = createHash('sha256');
|
||||||
|
const stream : any = createReadStream(path);
|
||||||
|
stream.on('error', (err : Error) => reject(err));
|
||||||
|
stream.on('data', (chunk : Buffer) => hashSum.update(chunk));
|
||||||
|
stream.on('end', () => resolve(hashSum.digest('hex')));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static stringHash (str : string) : string {
|
||||||
|
const sha : Hash = createHash('sha256').update(str);
|
||||||
|
return sha.digest('hex');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { Hashes };
|
73
src/index.ts
73
src/index.ts
|
@ -2,10 +2,8 @@ import 'dotenv/config'
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Express, Request, Response, NextFunction } from 'express'
|
import { Express, Request, Response, NextFunction } from 'express'
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { createReadStream } from 'fs';
|
|
||||||
import { tmpdir } from 'os';
|
import { tmpdir } from 'os';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { createHash, Hash } from 'crypto';
|
|
||||||
import { Database } from 'sqlite3';
|
import { Database } from 'sqlite3';
|
||||||
import bodyParser from 'body-parser';
|
import bodyParser from 'body-parser';
|
||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
|
@ -16,18 +14,40 @@ import * as Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { createLog } from './log'
|
import { createLog } from './log'
|
||||||
import { sendMail } from './mail';
|
import { sendMail } from './mail';
|
||||||
|
import { Files } from './files';
|
||||||
|
import type { SequenceObject } from './files';
|
||||||
import { Shell } from './shell';
|
import { Shell } from './shell';
|
||||||
import { delay } from './delay';
|
import { delay } from './delay';
|
||||||
import { FD } from './fd';
|
import { FD } from './fd';
|
||||||
|
|
||||||
|
const log : Logger = createLog('fm');
|
||||||
|
const app : Express = express();
|
||||||
let fd : FD;
|
let fd : FD;
|
||||||
|
let index : HandlebarsTemplateDelegate<any>;
|
||||||
|
|
||||||
let log : Logger = createLog('fm');
|
let port : number;
|
||||||
|
let sequences : string;
|
||||||
|
let width : number;
|
||||||
|
let height : number;
|
||||||
|
|
||||||
log.info('Starting filmout_manager');
|
log.info('Starting filmout_manager...');
|
||||||
|
|
||||||
function settings () {
|
app.use(bodyParser.json());
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
async function createTemplate (filePath : string) : Promise<HandlebarsTemplateDelegate<any>> {
|
||||||
|
let tmpl : string;
|
||||||
|
try {
|
||||||
|
tmpl = await fs.readFile(filePath, 'utf8');
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err);
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return Handlebars.compile(tmpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function settings () {
|
||||||
|
let sequencesExists : boolean = false;
|
||||||
if (typeof process.env['FD'] === 'undefined') {
|
if (typeof process.env['FD'] === 'undefined') {
|
||||||
log.error('Please include an FD value containing the path to your fd binary in .env');
|
log.error('Please include an FD value containing the path to your fd binary in .env');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -38,13 +58,15 @@ function settings () {
|
||||||
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
} else {
|
} else {
|
||||||
log.info(`WIDTH=${process.env['WIDTH']}`);
|
width = parseInt(process.env['WIDTH']);
|
||||||
|
log.info(`WIDTH=${width}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['HEIGHT'] === 'undefined') {
|
if (typeof process.env['HEIGHT'] === 'undefined') {
|
||||||
log.error('Please include a HEIGHT value containing the height of the screen you are using in .env');
|
log.error('Please include a HEIGHT value containing the height of the screen you are using in .env');
|
||||||
process.exit(3);
|
process.exit(3);
|
||||||
} else {
|
} else {
|
||||||
log.info(`HEIGHT=${process.env['HEIGHT']}`);
|
height = parseInt(process.env['HEIGHT'])
|
||||||
|
log.info(`HEIGHT=${height}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['FD_HOST'] === 'undefined') {
|
if (typeof process.env['FD_HOST'] === 'undefined') {
|
||||||
log.error('Please include a FD_HOST value with the host that the fd socket server is hosted on in .env');
|
log.error('Please include a FD_HOST value with the host that the fd socket server is hosted on in .env');
|
||||||
|
@ -53,16 +75,45 @@ function settings () {
|
||||||
log.info(`FD_HOST=${process.env['FD_HOST']}`);
|
log.info(`FD_HOST=${process.env['FD_HOST']}`);
|
||||||
}
|
}
|
||||||
if (typeof process.env['FD_PORT'] === 'undefined') {
|
if (typeof process.env['FD_PORT'] === 'undefined') {
|
||||||
log.error('Please include a FD_PORT value with the port that the fd socket server is hosted in in .env')
|
log.error('Please include a FD_PORT value with the port that the fd socket server is hosted on in .env')
|
||||||
process.exit(5);
|
process.exit(5);
|
||||||
} else {
|
} else {
|
||||||
log.info(`FD_PORT=${process.env['FD_PORT']}`);
|
log.info(`FD_PORT=${process.env['FD_PORT']}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['PORT'] === 'undefined') {
|
||||||
|
log.error('Please include a PORT value with the port that the HTTP web process is hosted on in .env');
|
||||||
|
process.exit(6);
|
||||||
|
} else {
|
||||||
|
port = parseInt(process.env['PORT']);
|
||||||
|
log.info(`PORT=${port}`);
|
||||||
|
}
|
||||||
|
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
||||||
|
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
||||||
|
process.exit(7);
|
||||||
|
} else {
|
||||||
|
sequences = process.env['SEQUENCES'];
|
||||||
|
sequencesExists = await Files.exists(sequences);
|
||||||
|
if (!sequencesExists) {
|
||||||
|
log.error(`The SEQUENCES directory in .env, ${sequences}, does not exist`);
|
||||||
|
process.exit(8);
|
||||||
|
}
|
||||||
|
log.info(`SEQUENCES=${sequences}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.get('/', async (req : Request, res : Response, next : NextFunction) => {
|
||||||
|
const dirs : SequenceObject[] = await Files.enumerateSequences(sequences);
|
||||||
|
const html : string = index({ dirs, width, height });
|
||||||
|
res.send(html);
|
||||||
|
});
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
settings();
|
await settings();
|
||||||
fd = new FD(process.env['FD'], parseInt(process.env['WIDTH']), parseInt(process.env['HEIGHT']), process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
index = await createTemplate('./views/index.hbs');
|
||||||
|
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
||||||
|
app.listen(port, async () => {
|
||||||
|
log.info(`filmout_manager HTTP server running on port ${port}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
|
@ -10,6 +10,7 @@
|
||||||
"baseUrl" : "dist",
|
"baseUrl" : "dist",
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"rootDir" : "./src/",
|
"rootDir" : "./src/",
|
||||||
|
"declaration": true,
|
||||||
"paths" : {
|
"paths" : {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Filmout Manager</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Screen Resolution : {{width}}x{{height}}</div>
|
||||||
|
<select>
|
||||||
|
<option> - Select Image Sequence - </option>
|
||||||
|
{{#each dirs}}
|
||||||
|
<option value="{{this.hash}}">{{this.name}}</option>
|
||||||
|
{{/each}}
|
||||||
|
</select>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue