PVI - C# Example of connecting and reading variables in simulator

Hello
I am not able to find an example of c# application to understand:

  • how to connect to a simulator instance (127.0.0.1)
  • how to read a variable
    with PVI 4.11

Is there someone that has an example or a snippet?
Thank you very much in advance

Marco Sartori

Hi, all official sample you can find in PVI installation folder. Default path is C:\BrAutomation\PVI\V4.11\Samples

Yes, but there is no example where ArSim is used…

Question is: which properties should be set on connection?

Thanks

Hi,

adapting the code to your needs requires looking at the generated documentation.

Going from the CPU object to the type of its’ Connection object and looking at DeviceType:

The example would get you something like this (I didn’t bother to change the style to that older line-by-line one):

cpu = new Cpu(service,  "Cpu") {
	Connection = {
		DeviceType = DeviceType.ANSLTcp,
		ANSLTcp = {
			DestinationIpAddress = "127.0.0.1"
		},
		ResponseTimeout = 5
	}
};
3 Likes

@mSartoriOptrel waiting patiently for a reply :slight_smile:

2 Likes

Ahahah.
Many thanks @michael_w
Sorry for the late reply. I had the chance only to test the connection and it worked perfectly.
Hope this help someone else that has basic knowledges on c# like me :joy:

Thanks again
Marco Sartori

1 Like