More work on UI
This commit is contained in:
@@ -78,7 +78,14 @@ export class Timer {
|
||||
this._Main.UnityRunner.startOrigin === StartOrigin.Timer
|
||||
) {
|
||||
console.log(PREFIX, 'Stopping Unity');
|
||||
this._Main.UnityRunner.stop();
|
||||
|
||||
this._Main.UnityWebSocket.quitApplication();
|
||||
this._Main.UnityRunner.startOrigin = null;
|
||||
this._Main.UnityRunner.state = 'STOPPED';
|
||||
|
||||
setTimeout(() => {
|
||||
this._Main.UnityRunner.requestStop();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
@@ -2,6 +2,8 @@ import { RawData, WebSocket } from 'ws';
|
||||
import { Main } from '../Main';
|
||||
import { delay, ServiceState } from '../Utils';
|
||||
import { State, StatusType } from '../Status';
|
||||
import { join } from 'path';
|
||||
import { writeFileSync } from 'fs-extra';
|
||||
|
||||
const PREFIX = '[Unity]';
|
||||
export class UnityWebSocket {
|
||||
@@ -189,6 +191,14 @@ export class UnityWebSocket {
|
||||
return;
|
||||
}
|
||||
|
||||
// writeFileSync(
|
||||
// join(
|
||||
// this._Main.dataPath,
|
||||
// `tempdebug-${message.type}-${new Date().getTime()}.json`,
|
||||
// ),
|
||||
// JSON.stringify(message, null, 4),
|
||||
// );
|
||||
|
||||
switch (message.type) {
|
||||
case 'heartbeat_data':
|
||||
this.parameters.timelineWatching =
|
||||
@@ -232,6 +242,16 @@ export class UnityWebSocket {
|
||||
this.broadcastState();
|
||||
break;
|
||||
|
||||
case 'timeline_update':
|
||||
const playbackReady = message.value == 1;
|
||||
this._Main.Status.update(
|
||||
StatusType.ReplayFunction,
|
||||
playbackReady ? State.Green : State.Yellow,
|
||||
playbackReady ? 'Playback ready' : 'Playback not ready',
|
||||
);
|
||||
console.log('timeline_update', message);
|
||||
break;
|
||||
|
||||
case 'response_camera_frame':
|
||||
this._Main.WebServer.Calibration.writeCalibrationImage(
|
||||
message.imageBase64,
|
||||
@@ -286,7 +306,11 @@ export class UnityWebSocket {
|
||||
|
||||
this.stopFetchClocks();
|
||||
|
||||
this.setInfo('Connecting...', null, 'CONNECTING');
|
||||
this.setInfo(
|
||||
`Connecting to ${this._Main.Config.unity.webSocket.ip}:${this._Main.Config.unity.webSocket.port}...`,
|
||||
null,
|
||||
'CONNECTING',
|
||||
);
|
||||
|
||||
await delay(1000);
|
||||
|
||||
@@ -397,7 +421,8 @@ interface UnityParameterSlider extends UnityHeartbeatSlider {
|
||||
|
||||
type UnitySocketMessage =
|
||||
| UnitySocketMessageHeartbeat
|
||||
| UnitySocketMessageCameraFrame;
|
||||
| UnitySocketMessageCameraFrame
|
||||
| UnitySocketMessageTimelineUpdate;
|
||||
|
||||
interface UnitySocketMessageBase {
|
||||
type: string;
|
||||
@@ -453,3 +478,8 @@ interface UnitySocketMessageCameraFrame extends UnitySocketMessageBase {
|
||||
type: 'response_camera_frame';
|
||||
imageBase64: string;
|
||||
}
|
||||
|
||||
interface UnitySocketMessageTimelineUpdate extends UnitySocketMessageBase {
|
||||
type: 'timeline_update';
|
||||
value: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user