Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | import { Component, OnDestroy, OnInit } from '@angular/core'; import { LogService } from 'src/app/log/log.service'; import { TuioService } from 'src/shared/services/tuio.service'; import { SettingsService } from 'src/shared/services/settingsService'; import { Subscription } from 'rxjs'; import { DEFAULT_SETTINGS, ProtocolVersion, TransportProtocol, TuioConfiguration, TuioInterpretation } from '@reflex/shared-types'; import { PanelHeaderComponent, ValueSelectionComponent, ValueTextComponent } from '@reflex/angular-components/dist'; import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import { PackageDetailsComponent } from './package-details/package-details.component'; @Component({ selector: 'app-tuio', templateUrl: './tuio.component.html', imports: [ CommonModule, FormsModule, PanelHeaderComponent, ValueSelectionComponent, ValueTextComponent, PackageDetailsComponent ] }) export class TuioComponent implements OnInit, OnDestroy { public statusText = ''; public errorText = ''; public isBroadcasting = false; public transportProtocols: Array<string> = []; public transportProtocolIdx = -1; public tuioProtocolVersions: Array<string> = []; public tuioProtocolVersionIdx = -1; public tuioInterpretations: Array<string> = []; public tuioInterpretationIdx = -1; public config: TuioConfiguration = DEFAULT_SETTINGS.tuioSettingValues; public serverAddress = ''; public serverPort = 0; private statusTextSubscription?: Subscription; private settingsSubscription?: Subscription; public constructor(private readonly settingsService: SettingsService, private readonly tuioService: TuioService, private readonly logService: LogService) { } public ngOnInit(): void { this.settingsSubscription = this.settingsService.getSettings().subscribe((result) => { if (result.tuioSettingValues) { this.config = result.tuioSettingValues; this.transportProtocolIdx = this.config.transport; this.tuioProtocolVersionIdx = this.config.protocol; this.tuioInterpretationIdx = this.config.interpretation; this.serverAddress = this.config.serverAddress; this.serverPort = this.config.serverPort; } }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); this.settingsService.update(); this.fetchCurrentValues(); } public ngOnDestroy(): void { this.settingsSubscription?.unsubscribe(); this.statusTextSubscription?.unsubscribe(); } public fetchCurrentValues(): void { this.tuioService.getIsBroadcasting().subscribe((result) => { if (result.body?.name === 'IsBroadcasting') { this.isBroadcasting = result.body.value === true; } }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); this.tuioService.getTransportProtocols().subscribe((result) => { this.transportProtocols = result; if (this.config) { this.transportProtocolIdx = this.config.transport as number; } }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); this.tuioService.getTuioProtocolVersions().subscribe((result) => { this.tuioProtocolVersions = result; if (this.config) { this.tuioProtocolVersionIdx = this.config.protocol as number; } }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); this.tuioService.getTuioInterpretations().subscribe((result) => { this.tuioInterpretations = result; if (this.config) { this.tuioInterpretationIdx = this.config.interpretation as number; } }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); this.statusTextSubscription = this.tuioService.getStatus().subscribe((result) => { this.statusText = result; }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public setAddress(): void { this.config.serverAddress = this.serverAddress; this.tuioService.setAddress(this.config.serverAddress).subscribe((result) => { console.log(`response to change TUIO server address: ${result.status} - ${result.body?.value}`); }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public setPort(): void { this.config.serverPort = this.serverPort; this.tuioService.setPort(this.config.serverPort).subscribe((result) => { console.log(`response to change TUIO server port: ${result.status} - ${result.body?.value}`); }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public setTransportProtocol(): void { this.tuioService.setTransportProtocol(this.transportProtocols[this.transportProtocolIdx]).subscribe((result) => { console.log(`response to change TUIO transport protocol: ${result.status} - ${result.body?.value}`); }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public updateTransportProtocol(idx: number): void { this.transportProtocolIdx = idx; Iif (this.config) { this.config.transport = idx as TransportProtocol; } } public setTuioProtocolVersion(): void { this.tuioService.setTuioProtocolVersion(this.tuioProtocolVersions[this.tuioProtocolVersionIdx]).subscribe((result) => { console.log(`response to change TUIO protocol version: ${result.status} - ${result.body?.value}`); }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public updateTuioProtocolVersion(idx: number): void { this.tuioProtocolVersionIdx = idx; Iif (this.config) { this.config.protocol = idx as ProtocolVersion; } } public setTuioInterpretation(): void { this.tuioService.setTuioInterpretation(this.tuioInterpretations[this.tuioInterpretationIdx]).subscribe((result) => { console.log(`response to change TUIO interpretation: ${result.status} - ${result.body?.value}`); }, (error) => { this.logService.sendErrorLog(`${error}`); console.error(error); }); } public updateTuioInterpretation(idx: number): void { this.tuioInterpretationIdx = idx; Iif (this.config) { this.config.interpretation = idx as TuioInterpretation; } } public isBroadcastingChanged(): void { this.errorText = ''; this.tuioService.toggleBroadcasting() .subscribe((result) => { console.log(`Tuio Broadcast status toggle - result: ${result.status} - ${result.body?.value}`); this.isBroadcasting = result.body?.value as boolean; }, (error) => { this.isBroadcasting = false; this.errorText = `${error} - ${JSON.stringify(error, null, 3)}`; this.logService.sendErrorLog(this.errorText); }); } public saveTuioConfig(): void { this.tuioService.saveSettings() .subscribe(() => { }, (error) => { this.errorText = `Cannot save settings: ${error} - ${JSON.stringify(error, null, 3)}`; this.logService.sendErrorLog(this.errorText); }); } public isConfigValid(): boolean { return this.config != null && typeof this.config.serverAddress === 'string' && this.config.serverAddress.trim() !== '' && this.config.serverPort > 0 && this.transportProtocolIdx >= 0 && this.tuioInterpretationIdx >= 0 && this.tuioProtocolVersionIdx >= 0; } } |