generated from thinkode/modelRepository
renaming Finders and Peripherals to Providers and Endpoints
This commit is contained in:
@@ -2,87 +2,87 @@
|
||||
import DeviceCard from "./DeviceCard.svelte";
|
||||
import Input from "../General/Input.svelte";
|
||||
import { t, _ } from 'svelte-i18n'
|
||||
import { generateToast, needProjectSave, peripherals, colors } from "../../stores";
|
||||
import { generateToast, needProjectSave, endpoints, colors } from "../../stores";
|
||||
import { get } from "svelte/store"
|
||||
import { UpdatePeripheralSettings, GetPeripheralSettings, RemovePeripheral, AddPeripheral } from "../../../wailsjs/go/main/App";
|
||||
import { UpdateEndpointSettings, GetEndpointSettings, RemoveEndpoint, AddEndpoint } from "../../../wailsjs/go/main/App";
|
||||
import RoundedButton from "../General/RoundedButton.svelte";
|
||||
|
||||
// Create the peripheral to the project
|
||||
function createPeripheral(peripheral){
|
||||
// Create the peripheral to the project (backend)
|
||||
AddPeripheral(peripheral)
|
||||
// Create the endpoint to the project
|
||||
function createEndpoint(endpoint){
|
||||
// Create the endpoint to the project (backend)
|
||||
AddEndpoint(endpoint)
|
||||
.catch((error) => {
|
||||
console.log("Unable to create the peripheral: " + error)
|
||||
generateToast('danger', 'bx-error', $_("addPeripheralErrorToast"))
|
||||
console.log("Unable to create the endpoint: " + error)
|
||||
generateToast('danger', 'bx-error', $_("addEndpointErrorToast"))
|
||||
})
|
||||
}
|
||||
|
||||
// Add the peripheral to the project
|
||||
function addPeripheral(peripheral){
|
||||
// Add the peripheral to the project (backend)
|
||||
AddPeripheral(peripheral)
|
||||
// Add the endpoint to the project
|
||||
function addEndpoint(endpoint){
|
||||
// Add the endpoint to the project (backend)
|
||||
AddEndpoint(endpoint)
|
||||
.catch((error) => {
|
||||
console.log("Unable to add the peripheral to the project: " + error)
|
||||
generateToast('danger', 'bx-error', $_("addPeripheralErrorToast"))
|
||||
console.log("Unable to add the endpoint to the project: " + error)
|
||||
generateToast('danger', 'bx-error', $_("addEndpointErrorToast"))
|
||||
})
|
||||
}
|
||||
|
||||
// Remove the peripheral from the project
|
||||
function removePeripheral(peripheral) {
|
||||
// Delete the peripheral from the project (backend)
|
||||
RemovePeripheral(peripheral)
|
||||
// Remove the endpoint from the project
|
||||
function removeEndpoint(endpoint) {
|
||||
// Delete the endpoint from the project (backend)
|
||||
RemoveEndpoint(endpoint)
|
||||
.catch((error) => {
|
||||
console.log("Unable to remove the peripheral from the project: " + error)
|
||||
generateToast('danger', 'bx-error', $_("removePeripheralErrorToast"))
|
||||
console.log("Unable to remove the endpoint from the project: " + error)
|
||||
generateToast('danger', 'bx-error', $_("removeEndpointErrorToast"))
|
||||
})
|
||||
}
|
||||
|
||||
// Select the peripheral to edit its settings
|
||||
let selectedPeripheralSN = null
|
||||
let selectedPeripheralSettings = {}
|
||||
function selectPeripheral(peripheral){
|
||||
// Load the settings array if the peripheral is detected
|
||||
if (peripheral.isSaved){
|
||||
GetPeripheralSettings(peripheral.ProtocolName, peripheral.SerialNumber).then((peripheralSettings) => {
|
||||
selectedPeripheralSettings = peripheralSettings
|
||||
// Select the current peripheral
|
||||
selectedPeripheralSN = peripheral.SerialNumber
|
||||
// Select the endpoint to edit its settings
|
||||
let selectedEndpointSN = null
|
||||
let selectedEndpointSettings = {}
|
||||
function selectEndpoint(endpoint){
|
||||
// Load the settings array if the endpoint is detected
|
||||
if (endpoint.isSaved){
|
||||
GetEndpointSettings(endpoint.ProtocolName, endpoint.SerialNumber).then((endpointSettings) => {
|
||||
selectedEndpointSettings = endpointSettings
|
||||
// Select the current endpoint
|
||||
selectedEndpointSN = endpoint.SerialNumber
|
||||
}).catch((error) => {
|
||||
console.log("Unable to get the peripheral settings: " + error)
|
||||
generateToast('danger', 'bx-error', $_("getPeripheralSettingsErrorToast"))
|
||||
console.log("Unable to get the endpoint settings: " + error)
|
||||
generateToast('danger', 'bx-error', $_("getEndpointSettingsErrorToast"))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Unselect the peripheral if it is disconnected
|
||||
// Unselect the endpoint if it is disconnected
|
||||
$: {
|
||||
Object.entries($peripherals).filter(([serialNumber, peripheral]) => {
|
||||
if (!peripheral.isDetected && peripheral.isSaved && selectedPeripheralSN == serialNumber) {
|
||||
selectedPeripheralSN = null
|
||||
selectedPeripheralSettings = {}
|
||||
Object.entries($endpoints).filter(([serialNumber, endpoint]) => {
|
||||
if (!endpoint.isDetected && endpoint.isSaved && selectedEndpointSN == serialNumber) {
|
||||
selectedEndpointSN = null
|
||||
selectedEndpointSettings = {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get the number of saved peripherals
|
||||
$: savedPeripheralNumber = Object.values($peripherals).filter(peripheral => peripheral.isSaved).length;
|
||||
// Get the number of saved endpoints
|
||||
$: savedEndpointNumber = Object.values($endpoints).filter(endpoint => endpoint.isSaved).length;
|
||||
|
||||
// Validate the peripheral settings
|
||||
// Validate the endpoint settings
|
||||
function validate(settingName, settingValue){
|
||||
console.log("Peripheral setting '" + settingName + "' set to '" + settingValue + "'")
|
||||
console.log("Endpoint setting '" + settingName + "' set to '" + settingValue + "'")
|
||||
// Get the old setting type and convert the new setting to this type
|
||||
const convert = {
|
||||
number: Number,
|
||||
string: String,
|
||||
boolean: Boolean,
|
||||
}[typeof(selectedPeripheralSettings[settingName])] || (x => x)
|
||||
selectedPeripheralSettings[settingName] = convert(settingValue)
|
||||
let peripheralProtocolName = get(peripherals)[selectedPeripheralSN].ProtocolName
|
||||
UpdatePeripheralSettings(peripheralProtocolName, selectedPeripheralSN, selectedPeripheralSettings).then(()=> {
|
||||
}[typeof(selectedEndpointSettings[settingName])] || (x => x)
|
||||
selectedEndpointSettings[settingName] = convert(settingValue)
|
||||
let endpointProtocolName = get(endpoints)[selectedEndpointSN].ProtocolName
|
||||
UpdateEndpointSettings(endpointProtocolName, selectedEndpointSN, selectedEndpointSettings).then(()=> {
|
||||
$needProjectSave = true
|
||||
}).catch((error) => {
|
||||
console.log("Unable to save the peripheral setting: " + error)
|
||||
generateToast('danger', 'bx-error', $_("peripheralSettingSaveErrorToast"))
|
||||
console.log("Unable to save the endpoint setting: " + error)
|
||||
generateToast('danger', 'bx-error', $_("endpointSettingSaveErrorToast"))
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -92,31 +92,31 @@
|
||||
<div class="availableHardware">
|
||||
<p style="color: var(--white-color);"><i class='bx bxs-plug'></i> {$_("projectHardwareDetectedLabel")}</p>
|
||||
</div>
|
||||
{#each Object.entries($peripherals) as [serialNumber, peripheral]}
|
||||
{#if peripheral.isDetected}
|
||||
<DeviceCard on:add={() => addPeripheral(peripheral)} on:dblclick={() => {
|
||||
if(!peripheral.isSaved)
|
||||
addPeripheral(peripheral)
|
||||
{#each Object.entries($endpoints) as [serialNumber, endpoint]}
|
||||
{#if endpoint.isDetected}
|
||||
<DeviceCard on:add={() => addEndpoint(endpoint)} on:dblclick={() => {
|
||||
if(!endpoint.isSaved)
|
||||
addEndpoint(endpoint)
|
||||
}}
|
||||
status="PERIPHERAL_CONNECTED" title={peripheral.Name} type={peripheral.ProtocolName} location={peripheral.Location ? peripheral.Location : ""} line1={"S/N: " + peripheral.SerialNumber} addable={!peripheral.isSaved}/>
|
||||
status="PERIPHERAL_CONNECTED" title={endpoint.Name} type={endpoint.ProtocolName} location={endpoint.Location ? endpoint.Location : ""} line1={"S/N: " + endpoint.SerialNumber} addable={!endpoint.isSaved}/>
|
||||
{/if}
|
||||
{/each}
|
||||
<div class="availableHardware">
|
||||
<p style="color: var(--white-color);"><i class='bx bxs-network-chart' ></i> {$_("projectHardwareOthersLabel")}</p>
|
||||
</div>
|
||||
<DeviceCard on:add={() => createPeripheral({Name: "OS2L virtual device", ProtocolName: "OS2L", SerialNumber: ""})}
|
||||
on:dblclick={() => createPeripheral({Name: "OS2L virtual device", ProtocolName: "OS2L", SerialNumber: ""})}
|
||||
<DeviceCard on:add={() => createEndpoint({Name: "OS2L virtual device", ProtocolName: "OS2L", SerialNumber: ""})}
|
||||
on:dblclick={() => createEndpoint({Name: "OS2L virtual device", ProtocolName: "OS2L", SerialNumber: ""})}
|
||||
status="PERIPHERAL_CONNECTED" title={"OS2L virtual device"} type={"OS2L"} location={""} addable={true}/>
|
||||
</div>
|
||||
|
||||
<div style="padding: 0.5em; flex:2; width:100%;">
|
||||
<p style="margin-bottom: 1em;">{$_("projectHardwareSavedLabel")}</p>
|
||||
<div class="configuredHardware">
|
||||
{#if savedPeripheralNumber > 0}
|
||||
{#each Object.entries($peripherals) as [serialNumber, peripheral]}
|
||||
{#if peripheral.isSaved}
|
||||
<DeviceCard status="{peripheral.status}" on:delete={() => removePeripheral(peripheral)} on:dblclick={() => removePeripheral(peripheral)} on:click={() => selectPeripheral(peripheral)}
|
||||
title={peripheral.Name} type={peripheral.ProtocolName} location={peripheral.Location ? peripheral.Location : ""} line1={peripheral.SerialNumber ? "S/N: " + peripheral.SerialNumber : ""} selected={serialNumber == selectedPeripheralSN} removable signalizable signalized={peripheral.eventEmitted}/>
|
||||
{#if savedEndpointNumber > 0}
|
||||
{#each Object.entries($endpoints) as [serialNumber, endpoint]}
|
||||
{#if endpoint.isSaved}
|
||||
<DeviceCard status="{endpoint.status}" on:delete={() => removeEndpoint(endpoint)} on:dblclick={() => removeEndpoint(endpoint)} on:click={() => selectEndpoint(endpoint)}
|
||||
title={endpoint.Name} type={endpoint.ProtocolName} location={endpoint.Location ? endpoint.Location : ""} line1={endpoint.SerialNumber ? "S/N: " + endpoint.SerialNumber : ""} selected={serialNumber == selectedEndpointSN} removable signalizable signalized={endpoint.eventEmitted}/>
|
||||
{/if}
|
||||
{/each}
|
||||
{:else}
|
||||
@@ -124,9 +124,9 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class='flexSettings'>
|
||||
{#if Object.keys(selectedPeripheralSettings).length > 0}
|
||||
{#each Object.entries(selectedPeripheralSettings) as [settingName, settingValue]}
|
||||
<div class="peripheralSetting">
|
||||
{#if Object.keys(selectedEndpointSettings).length > 0}
|
||||
{#each Object.entries(selectedEndpointSettings) as [settingName, settingValue]}
|
||||
<div class="endpointSetting">
|
||||
<Input on:blur={(event) => validate(settingName, event.detail.target.value)} label={$t(settingName)} type="{typeof(settingValue)}" width='100%' value="{settingValue}"/>
|
||||
</div>
|
||||
{/each}
|
||||
@@ -136,7 +136,7 @@
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.peripheralSetting{
|
||||
.endpointSetting{
|
||||
margin: 0.5em;
|
||||
}
|
||||
.flexSettings{
|
||||
|
||||
@@ -43,22 +43,22 @@
|
||||
"projectHardwareOthersLabel": "Others",
|
||||
"projectHardwareEmptyLabel": "No hardware saved for this project",
|
||||
|
||||
"peripheralArrivalToast": "Peripheral inserted:",
|
||||
"peripheralRemovalToast": "Peripheral removed:",
|
||||
"endpointArrivalToast": "Endpoint inserted:",
|
||||
"endpointRemovalToast": "Endpoint removed:",
|
||||
"projectSavedToast": "The project has been saved",
|
||||
"projectSaveErrorToast": "Unable to save the project:",
|
||||
"addPeripheralErrorToast": "Unable to add this peripheral to project",
|
||||
"createPeripheralErrorToast": "Unable to create this peripheral",
|
||||
"removePeripheralErrorToast": "Unable to remove this peripheral from project",
|
||||
"os2lPeripheralCreatedToast": "Your OS2L peripheral has been created",
|
||||
"os2lPeripheralCreateErrorToast": "Unable to create the OS2L peripheral",
|
||||
"getPeripheralSettingsErrorToast": "Unable to get the peripheral settings",
|
||||
"addEndpointErrorToast": "Unable to add this endpoint to project",
|
||||
"createEndpointErrorToast": "Unable to create this endpoint",
|
||||
"removeEndpointErrorToast": "Unable to remove this endpoint from project",
|
||||
"os2lEndpointCreatedToast": "Your OS2L endpoint has been created",
|
||||
"os2lEndpointCreateErrorToast": "Unable to create the OS2L endpoint",
|
||||
"getEndpointSettingsErrorToast": "Unable to get the endpoint settings",
|
||||
"projectsLoadErrorToast": "Unable to get the projects list",
|
||||
"projectOpenedToast": "The project was opened:",
|
||||
"projectOpenErrorToast": "Unable to open the project",
|
||||
"projectCreatedToast": "The project was created",
|
||||
"projectCreateErrorToast": "Unable to create the project",
|
||||
"peripheralSettingSaveErrorToast": "Unable to save the peripheral settings",
|
||||
"endpointSettingSaveErrorToast": "Unable to save the endpoint settings",
|
||||
|
||||
"os2lIp": "OS2L server IP",
|
||||
"os2lPort": "OS2L server port"
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
import { EventsOn, EventsOff } from "../wailsjs/runtime/runtime.js"
|
||||
import { peripherals, generateToast, needProjectSave, showInformation } from './stores'
|
||||
import { endpoints, generateToast, needProjectSave, showInformation } from './stores'
|
||||
import { get } from "svelte/store"
|
||||
import { _ } from 'svelte-i18n'
|
||||
|
||||
// New peripheral has been added to the system
|
||||
function peripheralArrival (peripheralInfo){
|
||||
// New endpoint has been added to the system
|
||||
function endpointArrival (endpointInfo){
|
||||
// If not exists, add it to the map
|
||||
// isDetected key to true
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[peripheralInfo.SerialNumber]: {
|
||||
...storedPeripherals[peripheralInfo.SerialNumber],
|
||||
Name: peripheralInfo.Name,
|
||||
ProtocolName: peripheralInfo.ProtocolName,
|
||||
SerialNumber: peripheralInfo.SerialNumber,
|
||||
Settings: peripheralInfo.Settings,
|
||||
...storedEndpoints,
|
||||
[endpointInfo.SerialNumber]: {
|
||||
...storedEndpoints[endpointInfo.SerialNumber],
|
||||
Name: endpointInfo.Name,
|
||||
ProtocolName: endpointInfo.ProtocolName,
|
||||
SerialNumber: endpointInfo.SerialNumber,
|
||||
Settings: endpointInfo.Settings,
|
||||
isDetected: true,
|
||||
},
|
||||
}})
|
||||
console.log("Hardware has been added to the system");
|
||||
generateToast('info', 'bxs-hdd', get(_)("peripheralArrivalToast") + ' <b>' + peripheralInfo.Name + '</b>')
|
||||
generateToast('info', 'bxs-hdd', get(_)("endpointArrivalToast") + ' <b>' + endpointInfo.Name + '</b>')
|
||||
}
|
||||
|
||||
// Peripheral is removed from the system
|
||||
function peripheralRemoval (peripheralInfo){
|
||||
// Endpoint is removed from the system
|
||||
function endpointRemoval (endpointInfo){
|
||||
// If not exists, add it to the map
|
||||
// isDetected key to false
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[peripheralInfo.SerialNumber]: {
|
||||
...storedPeripherals[peripheralInfo.SerialNumber],
|
||||
Name: peripheralInfo.Name,
|
||||
ProtocolName: peripheralInfo.ProtocolName,
|
||||
SerialNumber: peripheralInfo.SerialNumber,
|
||||
Settings: peripheralInfo.Settings,
|
||||
...storedEndpoints,
|
||||
[endpointInfo.SerialNumber]: {
|
||||
...storedEndpoints[endpointInfo.SerialNumber],
|
||||
Name: endpointInfo.Name,
|
||||
ProtocolName: endpointInfo.ProtocolName,
|
||||
SerialNumber: endpointInfo.SerialNumber,
|
||||
Settings: endpointInfo.Settings,
|
||||
isDetected: false,
|
||||
status: "PERIPHERAL_DISCONNECTED",
|
||||
},
|
||||
}})
|
||||
console.log("Hardware has been removed from the system");
|
||||
generateToast('warning', 'bxs-hdd', get(_)("peripheralRemovalToast") + ' <b>' + peripheralInfo.Name + '</b>')
|
||||
generateToast('warning', 'bxs-hdd', get(_)("endpointRemovalToast") + ' <b>' + endpointInfo.Name + '</b>')
|
||||
}
|
||||
|
||||
// Update peripheral status
|
||||
function peripheralUpdateStatus(peripheralInfo, status){
|
||||
// Update endpoint status
|
||||
function endpointUpdateStatus(endpointInfo, status){
|
||||
// If not exists, add it to the map
|
||||
// change status key
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
console.log(status)
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[peripheralInfo.SerialNumber]: {
|
||||
...storedPeripherals[peripheralInfo.SerialNumber],
|
||||
Name: peripheralInfo.Name,
|
||||
ProtocolName: peripheralInfo.ProtocolName,
|
||||
SerialNumber: peripheralInfo.SerialNumber,
|
||||
Settings: peripheralInfo.Settings,
|
||||
...storedEndpoints,
|
||||
[endpointInfo.SerialNumber]: {
|
||||
...storedEndpoints[endpointInfo.SerialNumber],
|
||||
Name: endpointInfo.Name,
|
||||
ProtocolName: endpointInfo.ProtocolName,
|
||||
SerialNumber: endpointInfo.SerialNumber,
|
||||
Settings: endpointInfo.Settings,
|
||||
status: status,
|
||||
},
|
||||
}})
|
||||
@@ -68,20 +68,20 @@ function peripheralUpdateStatus(peripheralInfo, status){
|
||||
console.log("Hardware status has been updated to " + status);
|
||||
}
|
||||
|
||||
// Load the peripheral in the project
|
||||
function loadPeripheral (peripheralInfo) {
|
||||
// Load the endpoint in the project
|
||||
function loadEndpoint (endpointInfo) {
|
||||
// If not exists, add it to the map
|
||||
// isSaved key to true
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[peripheralInfo.SerialNumber]: {
|
||||
...storedPeripherals[peripheralInfo.SerialNumber],
|
||||
Name: peripheralInfo.Name,
|
||||
ProtocolName: peripheralInfo.ProtocolName,
|
||||
SerialNumber: peripheralInfo.SerialNumber,
|
||||
Settings: peripheralInfo.Settings,
|
||||
...storedEndpoints,
|
||||
[endpointInfo.SerialNumber]: {
|
||||
...storedEndpoints[endpointInfo.SerialNumber],
|
||||
Name: endpointInfo.Name,
|
||||
ProtocolName: endpointInfo.ProtocolName,
|
||||
SerialNumber: endpointInfo.SerialNumber,
|
||||
Settings: endpointInfo.Settings,
|
||||
isSaved: true,
|
||||
},
|
||||
}})
|
||||
@@ -99,19 +99,19 @@ function loadProject (showInfo){
|
||||
}
|
||||
|
||||
// Unload the hardware from the project
|
||||
function unloadPeripheral (peripheralInfo) {
|
||||
function unloadEndpoint (endpointInfo) {
|
||||
// If not exists, add it to the map
|
||||
// isSaved key to false
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
[peripheralInfo.SerialNumber]: {
|
||||
...storedPeripherals[peripheralInfo.SerialNumber],
|
||||
Name: peripheralInfo.Name,
|
||||
ProtocolName: peripheralInfo.ProtocolName,
|
||||
SerialNumber: peripheralInfo.SerialNumber,
|
||||
Settings: peripheralInfo.Settings,
|
||||
...storedEndpoints,
|
||||
[endpointInfo.SerialNumber]: {
|
||||
...storedEndpoints[endpointInfo.SerialNumber],
|
||||
Name: endpointInfo.Name,
|
||||
ProtocolName: endpointInfo.ProtocolName,
|
||||
SerialNumber: endpointInfo.SerialNumber,
|
||||
Settings: endpointInfo.Settings,
|
||||
isSaved: false,
|
||||
},
|
||||
}})
|
||||
@@ -120,26 +120,26 @@ function unloadPeripheral (peripheralInfo) {
|
||||
needProjectSave.set(true)
|
||||
}
|
||||
|
||||
// A peripheral event has been emitted
|
||||
function onPeripheralEvent(sn, event) {
|
||||
// A endpoint event has been emitted
|
||||
function onEndpointEvent(sn, event) {
|
||||
// If not exists, add it to the map
|
||||
// eventEmitted key to true for 0.2 sec
|
||||
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
...storedEndpoints,
|
||||
[sn]: {
|
||||
...storedPeripherals[sn],
|
||||
...storedEndpoints[sn],
|
||||
eventEmitted: true
|
||||
},
|
||||
}})
|
||||
|
||||
setTimeout(() => {
|
||||
peripherals.update((storedPeripherals) => {
|
||||
endpoints.update((storedEndpoints) => {
|
||||
return {
|
||||
...storedPeripherals,
|
||||
...storedEndpoints,
|
||||
[sn]: {
|
||||
...storedPeripherals[sn],
|
||||
...storedEndpoints[sn],
|
||||
eventEmitted: false
|
||||
},
|
||||
}})
|
||||
@@ -152,50 +152,50 @@ export function initRuntimeEvents(){
|
||||
if (initialized) return
|
||||
initialized = true
|
||||
|
||||
// Handle the event when a new peripheral is detected
|
||||
EventsOn('PERIPHERAL_ARRIVAL', peripheralArrival)
|
||||
// Handle the event when a new endpoint is detected
|
||||
EventsOn('PERIPHERAL_ARRIVAL', endpointArrival)
|
||||
|
||||
// Handle the event when a peripheral is removed from the system
|
||||
EventsOn('PERIPHERAL_REMOVAL', peripheralRemoval)
|
||||
// Handle the event when a endpoint is removed from the system
|
||||
EventsOn('PERIPHERAL_REMOVAL', endpointRemoval)
|
||||
|
||||
// Handle the event when a peripheral status is updated
|
||||
EventsOn('PERIPHERAL_STATUS', peripheralUpdateStatus)
|
||||
// Handle the event when a endpoint status is updated
|
||||
EventsOn('PERIPHERAL_STATUS', endpointUpdateStatus)
|
||||
|
||||
// Handle the event when a new project need to be loaded
|
||||
EventsOn('LOAD_PROJECT', loadProject)
|
||||
|
||||
// Handle a peripheral loaded in the project
|
||||
EventsOn('PERIPHERAL_LOAD', loadPeripheral)
|
||||
// Handle a endpoint loaded in the project
|
||||
EventsOn('PERIPHERAL_LOAD', loadEndpoint)
|
||||
|
||||
// Handle a peripheral unloaded from the project
|
||||
EventsOn('PERIPHERAL_UNLOAD', unloadPeripheral)
|
||||
// Handle a endpoint unloaded from the project
|
||||
EventsOn('PERIPHERAL_UNLOAD', unloadEndpoint)
|
||||
|
||||
// Handle a peripheral event
|
||||
EventsOn('PERIPHERAL_EVENT_EMITTED', onPeripheralEvent)
|
||||
// Handle a endpoint event
|
||||
EventsOn('PERIPHERAL_EVENT_EMITTED', onEndpointEvent)
|
||||
}
|
||||
|
||||
export function destroyRuntimeEvents(){
|
||||
if (!initialized) return
|
||||
initialized = false
|
||||
|
||||
// Handle the event when a new peripheral is detected
|
||||
// Handle the event when a new endpoint is detected
|
||||
EventsOff('PERIPHERAL_ARRIVAL')
|
||||
|
||||
// Handle the event when a peripheral is removed from the system
|
||||
// Handle the event when a endpoint is removed from the system
|
||||
EventsOff('PERIPHERAL_REMOVAL')
|
||||
|
||||
// Handle the event when a peripheral status is updated
|
||||
// Handle the event when a endpoint status is updated
|
||||
EventsOff('PERIPHERAL_STATUS')
|
||||
|
||||
// Handle the event when a new project need to be loaded
|
||||
EventsOff('LOAD_PROJECT')
|
||||
|
||||
// Handle a peripheral loaded in the project
|
||||
// Handle a endpoint loaded in the project
|
||||
EventsOff('PERIPHERAL_LOAD')
|
||||
|
||||
// Handle a peripheral unloaded from the project
|
||||
// Handle a endpoint unloaded from the project
|
||||
EventsOff('PERIPHERAL_UNLOAD')
|
||||
|
||||
// Handle a peripheral event
|
||||
// Handle a endpoint event
|
||||
EventsOff('PERIPHERAL_EVENT_EMITTED')
|
||||
}
|
||||
@@ -34,16 +34,16 @@ export const secondSize = writable("14px")
|
||||
export const thirdSize = writable("20px")
|
||||
|
||||
// List of current hardware
|
||||
export let peripherals = writable({})
|
||||
export let endpoints = writable({})
|
||||
|
||||
// Peripheral structure :
|
||||
// Endpoint structure :
|
||||
|
||||
// Name string `yaml:"name"` // Name of the peripheral
|
||||
// SerialNumber string `yaml:"sn"` // S/N of the peripheral
|
||||
// ProtocolName string `yaml:"protocol"` // Protocol name of the peripheral
|
||||
// Settings map[string]interface{} `yaml:"settings"` // Peripheral settings
|
||||
// Name string `yaml:"name"` // Name of the endpoint
|
||||
// SerialNumber string `yaml:"sn"` // S/N of the endpoint
|
||||
// ProtocolName string `yaml:"protocol"` // Protocol name of the endpoint
|
||||
// Settings map[string]interface{} `yaml:"settings"` // Endpoint settings
|
||||
|
||||
// isSaved // if the peripheral is saved in the project
|
||||
// isDetected // if the peripheral is detected by the system
|
||||
// isSaved // if the endpoint is saved in the project
|
||||
// isDetected // if the endpoint is detected by the system
|
||||
// status // the status of connection
|
||||
// eventEmitted // if an event has been emitted for this peripheral (disappear after a delay)
|
||||
// eventEmitted // if an event has been emitted for this endpoint (disappear after a delay)
|
||||
Reference in New Issue
Block a user