Api.getData()
Api.getData() is a function used to retrieve equipment data from the TORUS platform. This document introduces only the most basic usage. For detailed usage instructions, please refer to the TORUS manual. Below is a sample source code.
| using IntelligentApiCS; Guid appGuid = new Guid("68E8D436-0558-40C4-B4BA-AB0F54EFC697"); string appName = "TorusAppTest"; int initRet = Api.Initialize(appGuid, appName); Console.WriteLine("Initialize Result: " + initRet); int getRet = Api.getData("data://machine/channel/axis/machinePosition", "machine=1&channel=1&axis=1", out Item item); Console.WriteLine("getData Result: " + getRet); if (getRet == 0) { Console.WriteLine(item.ToString()); double value = item.GetValueDouble("value"); Console.WriteLine("value: " + value); } |
Api.getData() requires the address and filter of the Machine Data Model as parameters. In the example, the Machine Data Model is Machine Position. According to the filter, it retrieves the Machine Position value of the first axis of the first channel of the CNC with Machine ID = 1. The available Machine Data Model items can be found in the TORUS manual.

If the function returns 0, it means that the data has been successfully retrieved.
A value other than 0 indicates an error code. You can check the list of error codes in the TORUS manual.
Below is the debugging result. You can see that the item variable is in JSON format.
| Initialize Result: 0 getData Result: 0 { "value": [ 10 ], "status": 0, "datatype": "double", "time": "2024-09-16T00:27:59.649", "address": "data://machine/channel/axis/machineposition", "filter": "machine=1&channel=1&axis=1" } value: 10 |