Param device questions

Is there a way to know, other than checking for an immediate activate call, whether or not an instance of my device is actually being instantiated in the world or is the preview for placing instances in the world?

I’m looking to store the values out now in my activate function. Where should I be getting a ParamPacket from? Do I need to grab it from the targetted device? Do I create a new one?

And another question - calling falsify toggles all the icons beside the items to red, but doesn’t actually trigger a build of those items. Any further suggestions for triggering the update of them?

EDIT: I’m ignoring thread safety for now (I know, it’s bad), and mainly looking for anything that will cause a re-trigger of the graph preview without any user input. PreviewWorld also doesn’t seem to update the display properly; I have to manually enable/disable the device to get the changes propagated through the graph.

2.3 Final is imminent – planning on releasing it later today – so there is no possibility of getting a callback handler implemented in that. Looking further along, there are a few things that I want to do that will require an asynchronous mechanism – so this is something that will be on the table soon.

How to tell if your device is actually in the world: Check your GetWorld() member function return; if its null, the device has not actually been placed into the world. Note that all devices are first created then placed into a world.

To send a parameter packet you’ll have to create one:

Both ScalarPacket and ParamPacket are defined in ParamPacket.h.

To create one call:

ParamPointer val = PARAM(WMGetPacket(WMP_parameter));

And store it just like any other packet in your output function.

Finally, regarding falsify/preview:

Typically, the WM graph changes only from either world events or device UI changes. When a device UI is showing, WM will generate single-device previews as you change parameters – this is done by calling Device::Preview(). If your changes are accepted, the framework then falsifies the network from that device, then rebuilds the whole world.

To replicate this at other times, do the same: 1) Call Falsify() to mark this and all following devices as needing a rebuild, then 2) call WorldMachine::core->app->PreviewWorld(world) where world is the world returned from your device’s GetWorld().

Thank you so much Stephen! Hopefully I haven’t annoyed you too much with all these questions. The Falsify + PreviewWorld works a dream (for now, I’m ignoring thread safety and will be telling my users that they can only update values in WM when they’re not doing something in its UI/building). My project is working great, so I’m very thankful for all your help.