Class MachinesLibraryHelper
Helper methods for ICamApiMachinesLibrary
Inherited Members
Namespace: CAMAPI.DotnetHelper
Assembly: CAMAPI.DotnetHelper.dll
Syntax
public static class MachinesLibraryHelper
Methods
AddScanFolder(ComWrapper<ICamApiMachinesLibrary>, string)
Add a user folder to scan for machine schemas (scanned immediately, persists across restarts)
Declaration
public static void AddScanFolder(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | path | Absolute path to the folder |
CurrentMachine(ComWrapper<ICamApiMachinesLibrary>)
Current project machine (read-only)
Declaration
public static ComWrapper<ICamApiMachineInfo> CurrentMachine(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
Returns
| Type | Description |
|---|---|
| ComWrapper<ICamApiMachineInfo> |
EnumerateMachines(ComWrapper<ICamApiMachinesLibrary>)
Enumerate all machines currently known to the library (indexed scan folders, registered files and machines of recently opened projects)
Declaration
public static IEnumerable<ComWrapper<ICamApiMachineInfo>> EnumerateMachines(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
Returns
| Type | Description |
|---|---|
| IEnumerable<ComWrapper<ICamApiMachineInfo>> |
FindMachine(ComWrapper<ICamApiMachinesLibrary>, Guid, string, string)
Try to find best matching machine by guid, optional filePath and typeName
Declaration
public static ComWrapper<ICamApiMachineInfo> FindMachine(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, Guid guid, string filePath, string typeName)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| Guid | guid | Machine schema GUID |
| string | filePath | Optional path to machine schema file |
| string | typeName | Optional machine type name |
Returns
| Type | Description |
|---|---|
| ComWrapper<ICamApiMachineInfo> |
LoadMachineFromFile(ComWrapper<ICamApiMachinesLibrary>, string, string)
Load machine info directly from a schema file, bypassing the machines search tree. Throws when the file has no matching machine type or cannot be loaded.
Declaration
public static ComWrapper<ICamApiMachineInfo> LoadMachineFromFile(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string schemaFilePath, string typeName)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | schemaFilePath | Absolute path to the machine schema file |
| string | typeName | Root machine type; "" picks the first machine type in the file |
Returns
| Type | Description |
|---|---|
| ComWrapper<ICamApiMachineInfo> |
RegisterCurrentMachineChangedHandler(ComWrapper<ICamApiMachinesLibrary>, string, Action<ComWrapper<ICamApiMachineInfo>>, bool)
Subscribe to the machine change of the active project. By default the callback fires asynchronously on a background thread (marshal to the UI thread before touching UI). Pass async=false to receive it on the thread that changed the machine. The wrapper handed to the callback is disposed right after it returns, and it is null-wrapped when the project is left without a machine
Declaration
public static object RegisterCurrentMachineChangedHandler(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string handlerIdent, Action<ComWrapper<ICamApiMachineInfo>> onChanged, bool async = true)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | handlerIdent | Identifier to unsubscribe with |
| Action<ComWrapper<ICamApiMachineInfo>> | onChanged | Callback receiving the new machine |
| bool | async | Whether the callback runs on a background thread |
Returns
| Type | Description |
|---|---|
| object | Handler object - keep the reference alive while subscribed |
RemoveScanFolder(ComWrapper<ICamApiMachinesLibrary>, string)
Remove a previously added user scan folder
Declaration
public static void RemoveScanFolder(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | path | Absolute path to the folder |
Rescan(ComWrapper<ICamApiMachinesLibrary>)
Re-index all scan folders from the file system without restarting ENCY
Declaration
public static void Rescan(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
ScanFolders(ComWrapper<ICamApiMachinesLibrary>)
Folders currently scanned for machine schemas. Not every machine of the library comes from them - see EnumerateMachines(ComWrapper<ICamApiMachinesLibrary>)
Declaration
public static ComWrapper<IListString> ScanFolders(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
Returns
| Type | Description |
|---|---|
| ComWrapper<IListString> |
TryLoadMachineFromFile(ComWrapper<ICamApiMachinesLibrary>, string, string, out TResultStatus)
Load machine info directly from a schema file, bypassing the machines search tree. Returns the status instead of throwing.
Declaration
public static ComWrapper<ICamApiMachineInfo> TryLoadMachineFromFile(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string schemaFilePath, string typeName, out TResultStatus status)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | schemaFilePath | Absolute path to the machine schema file |
| string | typeName | Root machine type; "" picks the first machine type in the file |
| TResultStatus | status | Result status of the operation |
Returns
| Type | Description |
|---|---|
| ComWrapper<ICamApiMachineInfo> |
UnregisterHandler(ComWrapper<ICamApiMachinesLibrary>, string)
Unsubscribe a previously registered handler of machines library events
Declaration
public static void UnregisterHandler(this ComWrapper<ICamApiMachinesLibrary> machinesLibraryCom, string handlerIdent)
Parameters
| Type | Name | Description |
|---|---|---|
| ComWrapper<ICamApiMachinesLibrary> | machinesLibraryCom | Machines library |
| string | handlerIdent | Identifier used on subscribing |