// Create a new remote tray instance
const remoteTray = RemoteTray.instance('tray-1')
.options({
name: 'Remote Tray 1',
holderPath: '/holders/holder-1',
configPath: '/config/trays/tray-1'
})
.build();
// Check if tray is active
if (remoteTray.active) {
console.log(`${remoteTray.name} is enabled`);
}
// Access associated holder
const holder = remoteTray.holder;
console.log(`Holder status: ${holder?.status}`);
// Monitor trouble states
const TrayStatus = ({ tray }: { tray: RemoteTrayModel }) => {
const troubles = tray.troubles;
const isEnabled = tray.remoteTrayEnabled.value;
return (
<div>
<h3>{tray.name}</h3>
<p>Status: {isEnabled ? 'Enabled' : 'Disabled'}</p>
{troubles.length > 0 && (
<Alert severity="warning">
{troubles.length} issue(s) detected
</Alert>
)}
</div>
);
};
// Programmatically enable/disable tray
async function toggleRemoteTray(tray: RemoteTrayModel) {
const currentState = tray.remoteTrayEnabled.value;
await tray.remoteTrayEnabled.setValue(!currentState);
console.log(`Tray ${tray.name} is now ${!currentState ? 'enabled' : 'disabled'}`);
}
Freestyle Models
Model for managing remote tray configurations in the KOS Freestyle system.
A remote tray represents a physical or virtual tray that can be enabled/disabled remotely and is associated with a holder in the dispensing system. This model manages the tray's configuration, activation state, and trouble propagation from its associated holder.
Key Features
Properties
id- Unique identifier for the remote trayname- Display name of the trayholderPath- Path reference to the associated holder modelconfigPath- Configuration path for tray settingsremoteTrayEnabled- Configuration property controlling tray activationactive- Computed property indicating if the tray is currently activeholder- Reference to the associated holder modeltroubles- Propagated troubles from the associated holderMethods
updateModel(options)- Updates the model with new configuration optionsinit()- Initializes the remote tray modelload()- Loads the remote tray configuration and data