@@ -4,24 +4,21 @@ import {
44 DDPConnectorOptions ,
55 PeripheralDevicePubSub ,
66 PeripheralDevicePubSubCollectionsNames ,
7+ StatusCode ,
8+ PeripheralDeviceId ,
9+ PeripheralDeviceAPI ,
10+ protectString ,
11+ unprotectString ,
12+ stringifyError ,
13+ PeripheralDeviceCommand ,
714} from '@sofie-automation/server-core-integration'
8- import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status '
15+ import { PeripheralDeviceCommandId } from '@sofie-automation/shared-lib/dist/core/model/Ids '
916import _ from 'underscore'
1017import * as Winston from 'winston'
1118import { DeviceConfig } from './inputManagerHandler'
1219import fs from 'fs'
1320import { INPUT_DEVICE_CONFIG } from './configManifest'
14- import { PeripheralDeviceCommandId , PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
15- import {
16- PeripheralDeviceCategory ,
17- PeripheralDeviceSubType ,
18- PeripheralDeviceType ,
19- PERIPHERAL_SUBTYPE_PROCESS ,
20- } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
21- import { protectString , unprotectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
22- import { PeripheralDeviceCommand } from '@sofie-automation/shared-lib/dist/core/model/PeripheralDeviceCommand'
2321import { Process } from './process'
24- import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
2522import path from 'path'
2623
2724export interface CoreConfig {
@@ -73,9 +70,7 @@ export class CoreHandler {
7370 this . _coreConfig = config
7471 this . _process = process
7572
76- this . core = new CoreConnection (
77- this . getCoreConnectionOptions ( 'Input Gateway' , 'InputGateway' , PERIPHERAL_SUBTYPE_PROCESS )
78- )
73+ this . core = new CoreConnection ( this . getCoreConnectionOptions ( ) )
7974
8075 this . core . onConnected ( ( ) => {
8176 this . logger . info ( 'Core Connected!' )
@@ -104,10 +99,10 @@ export class CoreHandler {
10499 }
105100 await this . core . init ( ddpConfig )
106101 this . logger . info ( 'Core id: ' + this . core . deviceId )
107- this . _statusInitialized = true
108- await this . updateCoreStatus ( )
109-
110102 await this . setupObserversAndSubscriptions ( )
103+ if ( this . _onConnected ) this . _onConnected ( )
104+
105+ this . _statusInitialized = true
111106
112107 await this . updateCoreStatus ( )
113108 }
@@ -140,20 +135,20 @@ export class CoreHandler {
140135 await this . core . destroy ( )
141136 }
142137 }
143- getCoreConnectionOptions ( name : string , subDeviceId : string , subDeviceType ?: PeripheralDeviceSubType ) : CoreOptions {
138+ private getCoreConnectionOptions ( ) : CoreOptions {
144139 if ( ! this . _deviceOptions . deviceId ) {
145140 // this.logger.warn('DeviceId not set, using a temporary random id!')
146141 throw new Error ( 'DeviceId is not set!' )
147142 }
148143
149144 const options : CoreOptions = {
150- deviceId : protectString ( this . _deviceOptions . deviceId + subDeviceId ) ,
145+ deviceId : protectString ( this . _deviceOptions . deviceId + 'InputGateway' ) ,
151146 deviceToken : this . _deviceOptions . deviceToken ,
152147
153- deviceCategory : PeripheralDeviceCategory . TRIGGER_INPUT ,
154- deviceType : PeripheralDeviceType . INPUT ,
148+ deviceCategory : PeripheralDeviceAPI . PeripheralDeviceCategory . TRIGGER_INPUT ,
149+ deviceType : PeripheralDeviceAPI . PeripheralDeviceType . INPUT ,
155150
156- deviceName : name ,
151+ deviceName : 'Input Gateway' ,
157152 watchDog : this . _coreConfig ? this . _coreConfig . watchdog : true ,
158153
159154 configManifest : {
@@ -169,7 +164,6 @@ export class CoreHandler {
169164 options . deviceToken = 'unsecureToken'
170165 }
171166
172- if ( subDeviceType === PERIPHERAL_SUBTYPE_PROCESS ) options . versions = this . _getVersions ( )
173167 return options
174168 }
175169 onConnected ( fcn : ( ) => any ) : void {
0 commit comments