public OWLOSThingWrapper CreateThingWrapper() { OWLOSThingConfig _OWLOSThingConfig = CreateThingConnection(); OWLOSThingWrapper ThingWrapper = new OWLOSThingWrapper(this) { Thing = new OWLOSThing(_OWLOSThingConfig) }; OWLOSThingWrappers.Add(ThingWrapper); NewThing(new OWLOSThingWrapperEventArgs(ThingWrapper)); return(ThingWrapper); }
public OWLOSThingConfig CreateThingConnection() { OWLOSThingConfig _OWLOSThingConfig = new OWLOSThingConfig { Name = "OWLOS Thing" }; OWLOSConnection _RESTfulClientConnection = new OWLOSConnection { connectionType = ConnectionType.RESTfulClient, name = "rest" }; RESTfulClientConnectionDTO _RESTfulClientConnectionDTO = new RESTfulClientConnectionDTO { host = "http://192.168.1.101:80/" }; // _RESTfulClientConnectionDTO.port = 80; _RESTfulClientConnection.connectionString = JsonConvert.SerializeObject(_RESTfulClientConnectionDTO); _OWLOSThingConfig.connections.Add(_RESTfulClientConnection); OWLOSConnection _UARTClientConnection = new OWLOSConnection(); _UARTClientConnection = new OWLOSConnection { connectionType = ConnectionType.UART, name = "UART" }; UARTClientConnectionDTO _UARTClientConnectionDTO = new UARTClientConnectionDTO { port = "COM7", baudRate = 115200, parity = Parity.None, stopBits = StopBits.One, dataBits = 8, handshake = Handshake.None, RTSEnable = false }; _UARTClientConnection.connectionString = JsonConvert.SerializeObject(_UARTClientConnectionDTO); _OWLOSThingConfig.connections.Add(_UARTClientConnection); _OWLOSThingConfig.APIQueryIntervals = new List <APIQueryInterval>() { new APIQueryInterval() { APIType = APINameType.GetAllDriverProperties, Interval = 1 }, new APIQueryInterval() { APIType = APINameType.GetAllFiles, Interval = 10 }, new APIQueryInterval() { APIType = APINameType.GetAllScripts, Interval = 20 } }; config.ThingsConfig.Add(_OWLOSThingConfig); return(_OWLOSThingConfig); }