API Reference v9.2.0

DeviceStorageclass

Module: ZaberMotionAscii

Class providing access to device storage. Requires at least Firmware 7.30.

The following example illustrates how you can obtain an instance of this type:

import ZaberMotionAscii

let connection = try await Connection.openSerialPort(portName: "COM3")
let device = try connection.getDevice(deviceAddress: 1)
let deviceStorage = device.storage

Methods

m

eraseKey()

asyncthrows
try await deviceStorage.eraseKey(key)
Erases the device value stored at the provided key.
Arguments
NameTypeDescription
keyStringKey to erase.
Return Value
Bool A boolean indicating if the key existed.
m

getBool()

asyncthrows
try await deviceStorage.getBool(key)
Gets the value at the provided key interpreted as a boolean.
Arguments
NameTypeDescription
keyStringKey to get the value at.
Return Value
Bool Stored value.
m

getNumber()

asyncthrows
try await deviceStorage.getNumber(key)
Gets the value at the provided key interpreted as a number.
Arguments
NameTypeDescription
keyStringKey to get the value at.
Return Value
Double Stored value.
m

getString()

asyncthrows
try await deviceStorage.getString(key, decode = false)
Gets the device value stored with the provided key.
Arguments
NameTypeDescription
keyStringKey to read the value of.
decodeBoolWhether the stored value should be decoded. Only use this when reading values set by storage.set with "encode" true.
Return Value
String Stored value.
m

keyExists()

asyncthrows
try await deviceStorage.keyExists(key)
Determines whether a given key exists in device storage.
Arguments
NameTypeDescription
keyStringKey which existence to determine.
Return Value
Bool True indicating that the key exists, false otherwise.
m

listKeys()

asyncthrows
try await deviceStorage.listKeys(prefix = nil)
Lists the device storage keys matching a given prefix. Omit the prefix to list all the keys.
Arguments
NameTypeDescription
prefixString?Optional key prefix.
Return Value
[String] Storage keys matching the given prefix.
m

setBool()

asyncthrows
try await deviceStorage.setBool(key, value)
Sets the value at the provided key to the provided boolean.
Arguments
NameTypeDescription
keyStringKey to set the value at.
valueBoolValue to set.
m

setNumber()

asyncthrows
try await deviceStorage.setNumber(key, value)
Sets the value at the provided key to the provided number.
Arguments
NameTypeDescription
keyStringKey to set the value at.
valueDoubleValue to set.
m

setString()

asyncthrows
try await deviceStorage.setString(key, value, encode = false)
Sets the device value stored at the provided key.
Arguments
NameTypeDescription
keyStringKey to set the value at.
valueStringValue to set.
encodeBoolWhether the stored value should be base64 encoded before being stored. This makes the string unreadable to humans using the ASCII protocol, however, values stored this way can be of any length and use non-ASCII and protocol reserved characters.