Skip to content

Latest commit

 

History

History
79 lines (69 loc) · 4.01 KB

13_Source_TemplateDevice_TemplateQuantities_Properties.md

File metadata and controls

79 lines (69 loc) · 4.01 KB

Example 13 - Source, TemplateDevice, TemplateQuantities properties

The following properties can be queried from the OnboardTask application:

  • Source
  • TemplateDevice
  • TemplateDevice Quanities

Object overview:

 ┌─────────────────────────┐
 │       Source 1          │
 │                         │
 │                         │
 │                         │
 │                         ├─────────┐
 │                         │         │
 └─────────────────────────┘         │
                                     │
 ┌─────────────────────────┐         │
 │       Source 2          │         │
 │                         │         │
 │                         ├───────┐ │
 │                         │       │ │
 │                         │       │ │
 │                         │      ┌┴─┴───────────────────┐
 └─────────────────────────┘      │   Template Device 1  │
                                  │                      │
                                  │       defines        │
                                  │   the device type    │
                                  │ inherits templatedevi│
                                  └─────────────┬────────┘
                                                │
                                                │
                                                │   ┌───────────────────────────┐
                                                │   │    Template Quaintities   │
                                                └───┤                           │
                                                    │                           │
                                                    │      Quantity 1           │
                                                    │                           │
                                                    │      Quantity 2           │
                                                    │                           │
                                                    │      ..                   │
                                                    └───────────────────────────┘

Example:

Realtime FieldDevices = new Realtime();

//Login to Xserver.IoT Service (User settings can be set with IoT Explorer)
var res = await Authentication.Login("onboardtask", "onboardtask");
if (res.Success == false)
{
    EventLogging.AddLogMessage(MessageType.Error, this.GetType().Name + " - " + ServiceDisplayName + " - Authentication error! " + res.ErrorMessage);
}

//Get Sources and Quantities list
var result = await FieldDevices.GetSourcesQuantities();
        
foreach (var item in FieldDevices.ListOfSources)
{
    //Gets Source properties
    var tempdev = await FieldDevices.GetSourceProperties(item.SourceId);
    if (tempdev !=null)
    {
        //Gets TemplateDevice properties
        var tempdevprop = await FieldDevices.GetTemplateDeviceProperties(tempdev.TemplateDeviceId);
       
        //Gets TemplateDevice Quantities properties
        var tempdevquans = await FieldDevices.GetTemplateDeviceQuantitiesProperties(tempdev.TemplateDeviceId);
        if (tempdevquans !=null)
        {
            foreach (var tempq in tempdevquans)
            {
                //my code.........
            }
        }
    }
}