Skip to content

Commit

Permalink
Stricter tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
s0 committed Mar 20, 2019
1 parent 516bc38 commit 22e52b8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/behaviour/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class Display {
// Mapping form universe to buffers
private readonly buffers: {[id: number]: Int8Array} = {};
private readonly layout: Layout;
private playState: SimplePlayState | null;
private playState: SimplePlayState | null = null;

private readonly transitionInterval: Interval;
private readonly colorInterval: Interval;
Expand Down
8 changes: 3 additions & 5 deletions src/behaviour/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export class Interval {
private callee: () => void;
private intervalMs: number;
private enabled = true;
private timeout: NodeJS.Timer;
private next: number;
private timeout: NodeJS.Timer | null = null;

private lightDesk: {
group: lightDesk.Group;
Expand Down Expand Up @@ -39,16 +38,15 @@ export class Interval {
}

private trigger() {
clearTimeout(this.timeout);
if (this.timeout !== null) clearTimeout(this.timeout);
this.callee();
this.resetTimeout();
}

private resetTimeout() {
clearTimeout(this.timeout);
if (this.timeout !== null) clearTimeout(this.timeout);
if (this.enabled && this.intervalMs > 0) {
this.timeout = setTimeout(this.trigger, this.intervalMs);
this.next = new Date().getTime() + this.intervalMs;
}
}
}
66 changes: 33 additions & 33 deletions src/config/home.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import {Channel, Fixture, Config} from './';
import {Channel, Config} from './';

const fixtures: Fixture[] = [];
// const fixtures: Fixture[] = [];

const simpleRgbFixtureChannels: Channel[] = [
{kind: 'color', color: 'r'},
{kind: 'color', color: 'g'},
{kind: 'color', color: 'b'}
];

const simpleRgbFixtureChannels2: Channel[] = [
{kind: 'static', value: 255}, // dimmer
{kind: 'color', color: 'r'},
{kind: 'color', color: 'g'},
{kind: 'color', color: 'b'}
];
// const simpleRgbFixtureChannels2: Channel[] = [
// {kind: 'static', value: 255}, // dimmer
// {kind: 'color', color: 'r'},
// {kind: 'color', color: 'g'},
// {kind: 'color', color: 'b'}
// ];

const movingHeadOneFixtureChannels: Channel[] = [
{kind: 'movement', dimension: 'level'},
{kind: 'static', value: 0},
{kind: 'movement', dimension: 'vertical'},
{kind: 'static', value: 0},
{kind: 'speed'},
{kind: 'static', value: 255}, // dimmer
{kind: 'strobe'},
{kind: 'color', color: 'r'},
{kind: 'color', color: 'g'},
{kind: 'color', color: 'b'},
{kind: 'color', color: 'w'}
];
// const movingHeadOneFixtureChannels: Channel[] = [
// {kind: 'movement', dimension: 'level'},
// {kind: 'static', value: 0},
// {kind: 'movement', dimension: 'vertical'},
// {kind: 'static', value: 0},
// {kind: 'speed'},
// {kind: 'static', value: 255}, // dimmer
// {kind: 'strobe'},
// {kind: 'color', color: 'r'},
// {kind: 'color', color: 'g'},
// {kind: 'color', color: 'b'},
// {kind: 'color', color: 'w'}
// ];

const movingHeadTwoFixtureChannels: Channel[] = [
{kind: 'movement', dimension: 'level'},
{kind: 'static', value: 0},
{kind: 'movement', dimension: 'vertical'},
{kind: 'static', value: 0},
{kind: 'speed'},
{kind: 'static', value: 255}, // strobe / dimmer
{kind: 'color', color: 'r'},
{kind: 'color', color: 'g'},
{kind: 'color', color: 'b'},
{kind: 'color', color: 'w'}
];
// const movingHeadTwoFixtureChannels: Channel[] = [
// {kind: 'movement', dimension: 'level'},
// {kind: 'static', value: 0},
// {kind: 'movement', dimension: 'vertical'},
// {kind: 'static', value: 0},
// {kind: 'speed'},
// {kind: 'static', value: 255}, // strobe / dimmer
// {kind: 'color', color: 'r'},
// {kind: 'color', color: 'g'},
// {kind: 'color', color: 'b'},
// {kind: 'color', color: 'w'}
// ];

const config: Config = {
fixtures: [
Expand Down
18 changes: 10 additions & 8 deletions src/listener/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ export type StateListener = (state: messages.PlayStateData | null, getFile: (has
// }
// }

export class SynesthesiaConsumerClient {
export class SynesthesiaListener {

private readonly stateUpdated: StateListener;

public constructor(stateUpdated: StateListener) {
this.stateUpdated = stateUpdated;
}

public connectToServer() {
const ws = new WebSocket(`ws://localhost:${constants.DEFAULT_SYNESTHESIA_PORT}/listen`);
ws.addEventListener('open', () => {
const endpoint = new DownstreamEndpoint(
msg => ws.send(JSON.stringify(msg)),
state => {
console.log('new state', state);
stateUpdated(state, getFile);
this.stateUpdated(state, getFile);
}
);
const getFile = endpoint.getFile.bind(endpoint);
Expand All @@ -45,15 +52,10 @@ export class SynesthesiaConsumerClient {
// TODO
console.error(err);
});
ws.addEventListener('close', err => {
ws.addEventListener('close', _err => {
// TODO
});

}
}

export class SynesthesiaListener {
public constructor(stateUpdated: StateListener) {
const server = new SynesthesiaConsumerClient(stateUpdated);
}
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const proxy = new DmxProxy(PYTHON_PROXY);

const display = new Display(getConfig(), proxy);

const consumer = new SynesthesiaListener(display.newSynesthesiaPlayState);
new SynesthesiaListener(display.newSynesthesiaPlayState).connectToServer();

display.run();

Expand Down
5 changes: 3 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"isolatedModules": false,
"experimentalDecorators": false,
"declaration": true,
"noImplicitAny": true,
"noImplicitUseStrict": false,
"strictNullChecks": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
Expand Down

0 comments on commit 22e52b8

Please sign in to comment.