News:

  • October 02, 2026, 10:01:47 AM

Login with username, password and session length

Author Topic: How to tell when running on a Simulator  (Read 8846 times)

Andrew S

  • Hero Member
  • *****
  • Posts: 144
How to tell when running on a Simulator
« 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.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: How to tell when running on a Simulator
« Reply #1 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
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Andrew S

  • Hero Member
  • *****
  • Posts: 144
Re: How to tell when running on a Simulator
« Reply #2 on: August 03, 2019, 04:24:48 PM »
That'll work for now. Thanks Bob.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: How to tell when running on a Simulator
« Reply #3 on: August 05, 2019, 03:45:18 PM »
Added. Will be in 2.7.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO