Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to read from a VictoR device, once a connection has been established through a device manager, a service object the attribute in question is associated with must first be created. Once the service object has been created, calls to read data from the connected device can be made, given the device manager containing the device has been passed to the service object on creation.

Code Block
languagec#
public async Task<byte[]> Read(Guid id)
{
    var data = await m_deviceManager.Read(m_deviceName, id);
    return data;
}DeviceConfigurationService m_deviceConfigurationService = new DeviceConfigurationService(ref m_deviceManager);
DeviceInformationService m_deviceInformationService = new DeviceInformationService(ref m_deviceManager);

Deserialization of the data from the VictoR device is handled by the service objects, resulting in either a primitive data type or a custom made class defined in the SDK where appropriate. For example, when reading the serial number for the device through the DeviceInformationService class, the CompletableFuture Task returns a string.

Code Block
languagec#
public async Task<string> GetSerialNumber()
{
  return await m_deviceInformationService.GetSerialNumber(m_deviceName);
}

However, when reading the General System Parameters for the device through the DeviceConfigurationService class, the CompletableFutrue Task returns a GeneralSystemParameters object (defined in the SDK) that provides accessors for the various pieces of data inside of the General System Parameters attribute.

Code Block
languagec#
var generalSystemParameters = await m_deviceConfigurationService.GetGeneralSystemParameters(m_deviceName);
bool bluetoothEnabled = generalSystemParameters.isBluetoothLinkEnabled();
PowerProfileOption powerProfileOption = generalSystemParameters.getPowerProfile();
ushort minimumInactivityInterval = generalSystemParameters.getMinimumInactivityInterval();

NOTE: When reading from a device, please reference the supported ICD document specified above to ensure the attribute itself, as well as reading from the attribute, is supported.

...

Similar to reading from a VictoR device, writing to a VictoR device requires an established connection with a powered on device through a device manager and a service object that contains the data to be written. Serialization of data when writing to the VictoR device is handled by the service objects, converting the data into a byte array before being sent to the device.

Code Block
languagec#
public async Task<bool> Write(Guid id, byte[] data)
{
    returnVictorCore.Services.VideoParameters videoParameters = new VictorCore.Services.VideoParameters();

VictorCore.Services.FrameSize frameSize = new VictorCore.Services.FrameSize();
frameSize.Rows = (ushort)128;
frameSize.Columns = (ushort)64;

videoParameters.FrameSize = frameSize;
videoParameters.FrameRate = (ushort)24;
videoParameters.OpticalPath = videoParameters.OpticalPath = VictorCore.Services.VideoParameters.OpticalPathOptions.AutoRange;

await m_deviceManagerVictorController.Write(m_deviceName, vid, dataSetVideoParameters(videoParameters);
}

NOTE: When writing to a device, please reference the supported ICD document specified above to ensure the attribute itself, as well as writing to the attribute, is supported.

...

Attributes on the VictoR device, when supported, can be subscribed to through the usage of the EventHandler<VictorConnectionStateChangedEventArgs> and the service containing the data to be subscribed to.

Code Block
languagec#
public async Task<bool> SubscribeAttribute(Guid id)
{
    bool subscriptionStatus = await m_deviceManager.SubscribeAttributeChange(m_deviceName, id, AttributeChangedawait deviceInformationService.SubscribeToCurrentBatteryLevel(OnBatteryValueChanged);

    return subscriptionStatus;
}

public void AttributeChanged(object sender, VictorAttributeChangedEventArgs private async void OnBatteryValueChanged(DeviceInformationEventArgs args)
{
  string  onAttributeChanged.Invoke(args.Info.Address,batteryLevel = args.Attribute, args.DataCurrentBatteryLevel.ToString();
}