Co-Processing API

class ApplicationManager

Interface for managing applications and their lifecycle on a device.

The ApplicationManager provides methods for deploying, launching, stopping, and removing applications, as well as device connect and disconnect oeprations.

Subclassed by ApplicationManagerImpl

Public Functions

virtual ~ApplicationManager() = default

Virtual destructor for the ApplicationManager interface.

virtual std::string getVersion() = 0

Get the Application Version Information.

Returns:

std::string

virtual SiMaErrorCode connect(std::unique_ptr<Device> &device) = 0

Connect to a specific device.

Establishes a connection with a given device.

Parameters:

device – The Device object representing the device to connect to.

Returns:

SiMaErrorCode if the connection is successful, otherwise an appropriate error code.

virtual std::future<SiMaErrorCode> installApplication(const std::unique_ptr<Device> &device, const std::string &mpkBundlePath, ApplicationInfo &appInfo, std::function<void(const ProgressInfo)> progressCallback) = 0

Install an application to the specified device.

Parameters:
  • device – The device where the application should be installed.

  • mpkBundlePath – The path to the MPK bundle containing the application.

  • appInfo – Reference to an ApplicationInfo object to store the intalled application instance info.

  • progressCallback – Reference to a callback function to get progress event updates.

Returns:

SiMaErrorCode indicating success or failure of deployment.

virtual std::future<SiMaErrorCode> deployApplication(const std::unique_ptr<Device> &device, const std::string &mpkBundlePath, bool setupDefault, ApplicationInfo &appInfo, std::function<void(const ProgressInfo)> progressCallback) = 0

Deploy an application to the specified device.

Parameters:
  • device – The device where the application should be deployed.

  • mpkBundlePath – The path to the MPK bundle containing the application.

  • appInfo – Reference to an ApplicationInfo object to store the deployed application instance info.

  • setupDefault – Boolean flag to set the application to automatic start on device startup.

  • progressCallback – Reference to a callback function to get progress event updates.

Returns:

SiMaErrorCode indicating success or failure of deployment.

virtual std::future<SiMaErrorCode> deviceFirmwareUpgrade(const std::unique_ptr<Device> &device, const std::string &fwBundlePath, bool reboot_on_upgrade, std::function<void(const ProgressInfo)> progressCallback) = 0

Upgrade firmware of the specified device.

Parameters:
  • device – The device where the application should be deployed.

  • fwBundlePath – The path to the firmware bundle containing the application.

  • reboot_on_upgrade – User input whether to reboot the device automatically post Successful Firmware Upgrade Type bool :: true : automatically reboot the device on Successful Upgrade :: false : do not automatically reboot the device on Successful Upgrade

  • progressCallback – Reference to a callback function to get progress event updates.

Returns:

SiMaErrorCode indicating success or failure of deployment.

virtual SiMaErrorCode launchApplication(const std::unique_ptr<Device> &device, const std::string &applicationName, const std::string &archiveId, ApplicationInfo &appInfo) = 0

Launch an application instance on the specified device.

Parameters:
  • device – The device instance.

  • appicationName – The application name of the required application to launch.

  • archiveId – The application archive id of the required application to launch.

  • appInfo – Reference to an ApplicationInfo object to store the launched application instance info.

Returns:

SiMaErrorCode indicating success or failure.

virtual SiMaErrorCode stopApplication(const std::unique_ptr<Device> &device, const std::string &mpkId, const pid_t pid, ApplicationInfo &appInfo) = 0

Stop particular instance of application on the specified device.

Parameters:
  • device – The device instance.

  • mpkId – The application id represented by mpkid of the application to stop.

  • pid – The process id of the running instance of the application id.

  • appInfo – Reference to an ApplicationInfo object to store the stopped application instance info of the specified application id(mpkId).

Returns:

SiMaErrorCode indicating success or failure.

virtual SiMaErrorCode stopApplication(const std::unique_ptr<Device> &device, const std::string &mpkId, std::vector<ApplicationInfo> &appInfoList) = 0

Stop all instances of application on the specified device.

Parameters:
  • device – The device instance.

  • mpkId – The application id represented by mpkid of the application to stop.

  • appInfoList – Reference to list of ApplicationInfo objects to store all the stopped instances of the specified application id(mpkId).

Returns:

SiMaErrorCode indicating success or failure.

virtual SiMaErrorCode listApplication(const std::unique_ptr<Device> &device, std::vector<ApplicationInfo> &appInfoList) = 0

List all instances of deployed application on the specified device.

Parameters:
  • device – The device instance.

  • mpkId – The application id represented by mpkid of the application to stop.

  • appInfoList – Reference to list of ApplicationInfo objects of all fecthed Application instances on the specified device.

Returns:

SiMaErrorCode indicating success or failure.

virtual SiMaErrorCode removeApplication(const std::unique_ptr<Device> &device, const std::string &applicationName, const std::string &archiveId) = 0

Remove an application on the specified device.

Parameters:
  • device – The device instance.

  • archiveId – The application archive Id that is to be removed.

Returns:

SiMaErrorCode indicating success or failure.

virtual SiMaErrorCode disconnect(std::unique_ptr<Device> &device) = 0

Disconnect from a specific device.

Disconnects a connection with a given device.

Parameters:

device – The Device object representing the device to disconnect to.

Returns:

SiMaErrorCode if the disconnect is successful, otherwise an appropriate error code.

class DeviceConnection

Interface for managing device connections and operations.

This class provides a standard interface for discovering, connecting to, and managing devices, as well as performing operations such as upgrade, reset, and reboot on connected devices.

Subclassed by LinuxDeviceConnection

Public Functions

virtual ~DeviceConnection() = default

Virtual destructor for the DeviceConnection interface.

virtual SiMaErrorCode discoverDevices(std::vector<std::unique_ptr<Device>> &devices) = 0

Discover devices available for connection.

Scans the system or network to find devices that are available for connection.

Parameters:

devices – A reference to a vector of Device objects that will be populated with discovered devices.

Returns:

SiMaErrorCode::Success if discovery is successful, otherwise an appropriate error code.

virtual SiMaErrorCode discoverEthernetDevices(std::vector<std::unique_ptr<Device>> &devices, const std::string &baseIPAddress, const std::string &subnetMask) = 0

Discover Ethernet devices available for connection.

Scans the system or network to find devices that are available for connection.

Parameters:
  • devices – A reference to a vector of Device objects that will be populated with discovered devices.

  • baseIPAddress – An ip address value which will be used to query similar combinations of ip addresses over network.

  • subnetMask – A subnet mask value using which the combination of ip addresses will be queried.

Returns:

SiMaErrorCode::Success if discovery is successful, otherwise an appropriate error code.

virtual SiMaErrorCode listDevices(std::vector<std::unique_ptr<Device>> &devices) = 0

List all connected devices with their information.

Returns detailed information about all devices currently connected.

Parameters:

devices – A reference to a vector of Device objects that will be populated with connected devices.

Returns:

SiMaErrorCode::Success if listing is successful, otherwise an appropriate error code.

virtual SiMaErrorCode connect(std::unique_ptr<Device> &device) = 0

Connect to a specific device.

Establishes a connection with a given device.

Parameters:

device – The Device object representing the device to connect to.

Returns:

SiMaErrorCode::Success if the connection is successful, otherwise an appropriate error code.

virtual SiMaErrorCode disconnect(std::unique_ptr<Device> &device) = 0

Disconnect from a specific device.

Terminates the connection with the given device.

Parameters:

device – The Device object representing the device to disconnect from.

Returns:

SiMaErrorCode::Success if the disconnection is successful, otherwise an appropriate error code.

virtual SiMaErrorCode upgrade(std::unique_ptr<Device> &device) = 0

Upgrade the software or firmware of a specific device.

Initiates an upgrade process for the device to update its firmware or software.

Parameters:

device – The Device object representing the device to upgrade.

Returns:

SiMaErrorCode::Success if the upgrade is successful, otherwise an appropriate error code.

virtual SiMaErrorCode reset(std::unique_ptr<Device> &device) = 0

Reset a specific device to its default state.

Resets the specified device to its factory or initial state.

Parameters:

device – The Device object representing the device to reset.

Returns:

SiMaErrorCode::Success if the reset is successful, otherwise an appropriate error code.

virtual SiMaErrorCode reboot(std::unique_ptr<Device> &device) = 0

Reboot a specific device.

Restarts the specified device, typically to apply changes or recover from an error.

Parameters:

device – The Device object representing the device to reboot.

Returns:

SiMaErrorCode::Success if the reboot is successful, otherwise an appropriate error code.

class DeviceConnectionFactory

Public Static Functions

static std::unique_ptr<DeviceConnection> createDeviceConnection(OSType osType)

Creates a DeviceConnection instance of the give OS type.

Parameters:

osType – The OS platform for which the Device connection is required ex: OS_LINUX.

Returns:

Unique pointer to the created DeviceConnection instance.

class DeviceFactory

Public Static Functions

static std::unique_ptr<Device> createEthernetDevice(DeviceModel model, const std::string &ipAddressFormat)

Creates a Ethernet Device instance. Constructs the Ethernet Device with specified IPAddress with default User and Password.

Parameters:
  • model – The mode of the device ex: DAVINCI, MODALIX.

  • ipAddress – The ethernet address of the Device.

Returns:

Unique pointer to the created Device instance.

static std::unique_ptr<Device> createEthernetDevice(DeviceModel model, const std::string &ipAddressFormat, const std::string &userNamePasswd)

Creates a Ethernet Device instance. Constructs the Ethernet Device with specified IPAddress, User, and default Password.

Parameters:
  • model – The mode of the device ex: DAVINCI, MODALIX.

  • ipAddress – The ethernet address of the Device.

  • userName – The user name used to connect to Device.

Returns:

Unique pointer to the created Device instance.

static std::unique_ptr<Device> createEthernetDevice(DeviceModel model, const std::string &ipAddressFormat, const std::string &user, const std::string &passwd)

Creates a Ethernet Device instance. Constructs the Ethernet Device with specified IPAddress, User, Password.

Parameters:
  • model – The mode of the device ex: DAVINCI, MODALIX.

  • ipAddress – The ethernet address of the Device.

  • userName – The user name used to connect to Device.

  • password – The password used to connect the Device.

Returns:

Unique pointer to the created Device instance.

class Device

Represents a generic device with attributes specific to its connection type.

Public Functions

Device(DeviceModel model, const std::string &guid, DeviceConnectionMode connectMode)

Constructor for Device.

Parameters:
  • model – The model of the device (e.g., Davinci, Modalix).

  • guid – The globally unique identifier for the device.

  • connectMode – The connection mode (Ethernet, PCIe, Serial).

virtual ~Device() = default
DeviceModel getModel() const
std::string getGuid() const
DeviceConnectionMode getConnectionMode() const
bool isConnected() const
std::string getCurrentConnectionStatusStr() const
bool isLocal() const
void setConnected(bool flag)
void setLocal(bool flag)
void setGuid(const std::string &newGuid)
void associateCommunicationChannel(std::unique_ptr<CommunicationChannel> commChannel)
void disAssociateCommunicationChannel()
CommunicationChannel *getCommunicationChannel()
virtual std::string getTarget() const
virtual std::string getUserName() const
virtual std::string getPassword() const
virtual DeviceConnectionStatus getCurrentConnectionStatus() const
virtual void setUserName(const std::string &user)
virtual void setPassword(const std::string &passwd)
virtual std::string toString() const

Provides a string representation of the device.

Returns:

A formatted string containing device details.

class BaseSiMaErrorCode

Subclassed by SiMaCoProcessingAPIErrorCode

Public Functions

virtual int getCode() const = 0
virtual const std::string ToString() const = 0
virtual const std::string getType() const = 0
virtual bool isError() const = 0
virtual const std::unique_ptr<BaseSiMaErrorCode> clone() const = 0
class SiMaCoProcessingAPIErrorCode : public BaseSiMaErrorCode

Public Types

enum ErrorCode

Values:

enumerator CP_ERR_SUCCESS
enumerator CP_ERR_FAILURE
enumerator CP_ERR_INVALID_ARGUMENT
enumerator CP_ERR_NOT_IMPLEMENTED
enumerator CP_ERR_NOT_EXISTS
enumerator CP_ERR_ALREADY_EXISTS
enumerator CP_ERR_NULL_OBJECT
enumerator CP_ERR_INVALID_DEVICE
enumerator CP_ERR_DEVICE_ALREADY_MAPPED
enumerator CP_ERR_EXCEPTION
enumerator CP_ERR_NOT_CONNECTED
enumerator CP_ERR_SOCKET_ERROR
enumerator CP_ERR_FILE_ERROR
enumerator CP_ERR_INVALID_JSON

Public Functions

template<typename ...Args>
inline SiMaCoProcessingAPIErrorCode(const ErrorCode &errCode, Args... args)
SiMaCoProcessingAPIErrorCode(const SiMaCoProcessingAPIErrorCode &src)
inline ~SiMaCoProcessingAPIErrorCode()
inline int getCode() const
inline const std::string getType() const
bool isError() const
const std::string ToString() const
const std::unique_ptr<BaseSiMaErrorCode> clone() const
class SiMaLog

Public Functions

SiMaLog(const SiMaLog&) = delete
SiMaLog &operator=(const SiMaLog&) = delete
template<typename ...Args>
inline void log(SiMaLogLevel level, Args... args)
inline std::string getLogFilePath() const

Public Static Functions

static SiMaLog &getInstance(const std::string &baseFilename = BASE_FILENAME, size_t maxFileSize = MAX_FILE_SIZE, int maxFiles = MAX_FILES)