Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Andrew S on August 03, 2019, 03:37:34 PM

Title: How to tell when running on a Simulator
Post by: Andrew S on August 03, 2019, 03:37:34 PM
I'm loving the new simulator functionality that allows me to use programs for a 'real world' PLC model on the sim.

One thing I'm curious though, is how my programs can tell whether I'm actually running on a sim or a physical PLC. Since $PLCType and $PLCSubType now show the value of the physical PLC I wrote the program for, I've no longer got that visibility (or do I?). I know I can start the sim manually and connect, which would adjust those variables appropriately, but I'd really like to avoid that if possible.

It would be nice to have a $SimActive (or something) bit flag that I can query at runtime.

Andrew.
Title: Re: How to tell when running on a Simulator
Post by: BobO on August 03, 2019, 03:49:53 PM
I'm loving the new simulator functionality that allows me to use programs for a 'real world' PLC model on the sim.

One thing I'm curious though, is how my programs can tell whether I'm actually running on a sim or a physical PLC. Since $PLCType and $PLCSubType now show the value of the physical PLC I wrote the program for, I've no longer got that visibility (or do I?). I know I can start the sim manually and connect, which would adjust those variables appropriately, but I'd really like to avoid that if possible.

It would be nice to have a $SimActive (or something) bit flag that I can query at runtime.

Andrew.

That would be easy. In the meantime, check the serial number (SerialNum). Serial number of real hardware will always be 00:E0:62:XX:XX:XX
Title: Re: How to tell when running on a Simulator
Post by: Andrew S on August 03, 2019, 04:24:48 PM
That'll work for now. Thanks Bob.
Title: Re: How to tell when running on a Simulator
Post by: BobO on August 05, 2019, 03:45:18 PM
Added. Will be in 2.7.