Skip to main content
12-Amethyst
Jan 20, 2024 3:30 PM UTC
Question

Restart Industrial Things from service

HI, 

 

I would like to know how I can restart all industrial things after Tomcat reboot. 
I made service and it looks like that:

 

if (itemNumber <= (me.foundThings.rows.length - 1)) {
	var foundItem = me.foundThings.rows[itemNumber].Name;
	Things[me.foundThings.rows[itemNumber].Name].RestartThing();
	for (var x = 0; x < 3000; x++) {
		//sleeper
	}
	me.foundThings.rows[itemNumber].Status = 'Done';
	me.foundThings.rows[itemNumber].LastConnection = new Date();
	 me.RestartConnection({
	serverName: serverName /* THINGNAME */,
	NameThing: me.foundThings.rows[itemNumber].Name /* STRING */ 
});
	result = itemNumber + 1;
} else {
	result = 10000000;
}

 

RestartConnection service was created to re-append the Kepware server name to the Industrial Thing properties.

My problem is that what I created works very randomly. Of the 3, Industrial Things restarts 1 or 2 or does not add the server name to Industrial Thing.

How can I create a tool to restart all Industrial Things to avoid having to do it manually?

Thank you,

Jan

6 replies

Rocko
19-Tanzanite
Jan 22, 2024 8:12 AM UTC

Why would you want to restart the things when tomcat was just restarted? Then all things were already restarted.

 

On a side note: don't do the assignment to me.foundThings this way. Create a local variable for foundThings. do the loop assignments there. After the loop, assign me.foundThings to the local variable.

Translate
12-Amethyst
Jan 22, 2024 8:17 AM UTC

Hi 

Thank you for answer in middle of your night.

 

because in TWX 8.4 Industrial Things lose connection with Kepserwer or do not send the entire set of properties that are connected to Kepserwer.

 

They are waiting for the first change and I have such surprises that properties 1 is refreshed and properties 2 and 3 are saved as null.

After restartThing it works as it should

Translate
Rocko
19-Tanzanite
Jan 22, 2024 8:22 AM UTC

No worries, it's not the middle of the night where I am 🙂

I probably can't help with the resolution of this, but it might be helpful if you post some of your environment. Thingworx version, Kepware version, used protocols, etc. Is it really 8.4? Because this is out of support for many years,

Translate