KOS Device Model - Device Identity and Node Configuration Management

The Device model provides centralized management of device identity, node configuration, and hardware identification within KOS systems. It handles device serial numbers, names, and node topology information essential for system coordination and administration.

Key Features

Device Identity Management

  • Serial Number Tracking: Hardware-based device identification
  • Name Management: Human-readable device naming for administration
  • Node Configuration: Multi-node deployment topology handling

Real-time Synchronization

  • Critical Data Events: Automatic updates on system data changes
  • WebSocket Integration: Live device state synchronization
  • Lazy Loading: Efficient data retrieval when needed

Node Topology Support

  • Node Type/Name Parsing: Automatic node identifier decomposition
  • Multi-node Deployments: Support for complex system architectures
  • Role-based Configuration: Node-specific parameter management

Common Integration Patterns

System Administration Dashboards

const device = Device.factory({
serialNumber: 'KOS-DEV-001',
name: 'Production Dispenser Alpha',
nodeId: 'primary-main'
});

// Access device identity
console.log(`Device: ${device.name}`);
console.log(`Serial: ${device.serialNumber}`);
console.log(`Node: ${device.nodeType}-${device.nodeName}`);

Multi-node System Coordination

const primaryDevice = Device.factory({
nodeId: 'primary-controller'
});

const secondaryDevice = Device.factory({
nodeId: 'secondary-backup'
});

// Coordinate based on node roles
if (primaryDevice.nodeType === 'primary') {
// Handle primary node logic
}

Device Registration and Setup

const newDevice = Device.factory({
serialNumber: await getHardwareSerial(),
name: userProvidedName,
nodeId: deploymentConfiguration.nodeId
});

// Device automatically loads additional data
// from critical data events

Real-time Updates

The Device model automatically responds to critical data changes:

  • Monitors /kos/criticalData/changed and /kos/criticalData/available topics
  • Updates serial number and configuration when system data becomes available
  • Maintains consistency across device restarts and configuration changes

Singleton Behavior

Device models use singleton pattern - each device type has one instance:

  • Subsequent factory calls return the existing instance
  • Options are ignored after first creation
  • Ensures system-wide device identity consistency

This is an alias for the implementation DeviceModelImpl.

Use Declared Type

interface DeviceModel {
    updateModel(options): void;
    handleCriticalDataChanged(): Promise<void>;
}

Methods

  • Update the device model with new configuration options.

    Allows dynamic updating of device identity and node configuration. Any undefined values will be set to "unassigned". This method is typically called internally during device data loading or external configuration changes.

    Parameters

    Returns void

    Example

    const device = Device.factory({});

    // Update with new device information
    device.updateModel({
    serialNumber: 'KOS-DEVICE-12345',
    name: 'Updated Dispenser Name',
    nodeId: 'primary-main'
    });

    console.log(device.serialNumber); // "KOS-DEVICE-12345"
    console.log(device.name); // "Updated Dispenser Name"
    console.log(device.nodeId); // "primary-main"

    Example: Partial Updates

    // Only update specific fields
    device.updateModel({
    name: 'New Device Name'
    // serialNumber and nodeId remain unchanged
    });
  • Handle critical data changes to load the serial number at the appropriate time.

    Returns Promise<void>