Community Tip - You can change your system assigned username to something more personal in your community settings. X
Hi,
I am creating an application with the .net sdk that will run virtual things in a process. But I would also like to connect some virtual thing at any moment in the process.
Example: I start my application with thing1 and thing2. Then a few hours later I want to add thing3.
How would I be able to do so? Is it possible?
Regards,
François Lévesque
Solved! Go to Solution.
I think the question is related to the creation of a new instance - in context of the SteamSensor Example - of a new SteamThing in the already running application.
SteamSensorClient client = createClient(host, appKey);
/* (done in createClient call)
// Create two Virtual Things
SteamThing sensor1 = new SteamThing("SteamSensor1", "1st Floor Steam Sensor", null, client);
SteamThing sensor2 = new SteamThing("SteamSensor2", "2nd Floor Steam Sensor", "SN0002", client);
// Bind the Virtual Things
client.bindThing(sensor1);
client.bindThing(sensor2);
*/
// Wait for the SteamSensorClient to connect, then process its associated things.
// As long as the client has not been shutdown, continue
while (!client.isShutdown())
{
// Only process the Virtual Things if the client is connected
if (client.isConnected())
{
ThreadPool.QueueUserWorkItem(client.runClient);
}
// Question: Can we here also create new SteamThings and bind it to the client?
// Suspend processing at the scan rate interval
Thread.Sleep(scanRate);
}
I did not yet do it like this. I cannot answer this question.
You have a full set of services available that you could invoke after connection. So it is certainly possible to do things like auto create based on a trigger, or 'self-registration' there have been several threads on this, quite a long time ago, hopefully you can find it using a search.
I've been searching all day for a post that would give me what I am looking for and I found nothing. Would it be possible to point me in the right direction please. Since I am new to the sdk and ThingWorx.
Regards
Hope these articles, have some content that can help you along.
https://community.ptc.com/t5/ThingWorx-Developers/Create-missing-Things-via-404-s/m-p/771301
https://community.ptc.com/t5/ThingWorx-Developers/how-to-check-if-a-remotething-is-bound/m-p/529896
So I've read the content and I think I did not explain my self clearly. I will try to do so.
I do not need to create things with the sdk.
I need to bindThings after I started a process with some Things in it.
What I've tried to do so is create a Thing that will manage the insertion of other Things.
But when I bind things they do not connect in ThingWorx web platform.
Can I bind things after I have started my process and what do I need to do?
Regards,
Frank
When you say bind, you are using devices and RemoteThings?
I think your explanation lacks a lot of context unfortunately.
But I would say that if something needs to be bound, as something is in progress, and that process needs the bound items,
you will likely run into a lot of latency/timing issues.
You probably want to carefully outline each step that is being taken and then create some sort of asynchronous approach that allows it to work.
I think the question is related to the creation of a new instance - in context of the SteamSensor Example - of a new SteamThing in the already running application.
SteamSensorClient client = createClient(host, appKey);
/* (done in createClient call)
// Create two Virtual Things
SteamThing sensor1 = new SteamThing("SteamSensor1", "1st Floor Steam Sensor", null, client);
SteamThing sensor2 = new SteamThing("SteamSensor2", "2nd Floor Steam Sensor", "SN0002", client);
// Bind the Virtual Things
client.bindThing(sensor1);
client.bindThing(sensor2);
*/
// Wait for the SteamSensorClient to connect, then process its associated things.
// As long as the client has not been shutdown, continue
while (!client.isShutdown())
{
// Only process the Virtual Things if the client is connected
if (client.isConnected())
{
ThreadPool.QueueUserWorkItem(client.runClient);
}
// Question: Can we here also create new SteamThings and bind it to the client?
// Suspend processing at the scan rate interval
Thread.Sleep(scanRate);
}
I did not yet do it like this. I cannot answer this question.
Hi,
thanks for this answer it was actually what we were about to try.
The real reason it was not working was because I was assigning Identifiers to my things and those remotethings did not have an identifier.