Program a Mouse Capture Activity in SFC+
You can program a Mouse Capture activity in SFC+.
Open a device containing a Simulation Logic in the Live simulation environment
Click the Device Designer thumbnail to see the simulation logic tree. The Main block of the Simulation Logic must be a SFC+ block (see typical example below).

To open the SFC+ Editor, do one of the following: - Double-click Behavior
in the Main window.
- Right-click the Main block in the Reference Logic window and select Behavior Editor.
- Select Behavior Editor
in the Main window toolbar.
A 2D immersive window is opened to edit the block behavior. A toolbox at the right side of the window contains the SFC+ Editor commands.

Note:
In our example, the block behavior is undefined, so the window is empty.
If the 2D immersive window is in front of the 3D object, click in the 3D view.
The SFC+ Editor window becomes transparent.
Click Mouse Capture in the Activities toolbox.
Then, select the product/part being the target of the interaction in the 3D view.
The selected part is highlighted and a bubble attached to it appears.

Note:
If you want to change the selection, click another product in the 3D view.
Click the bubble to confirm the selection of the product.
Then, click in the background of 2D immersive window to set the position of the Mouse Capture activity.
 During a simulation, the step remains active until you click the target. The action displays the icon of the activity and the name of the target.
To modify the settings of the activity, double-click it. The buble attached to the activity appears.

If you want to change the target of the Mouse Capture activity, click another part in the 3D viewer.: The bubble is associated to the new part.

Click the buble.The Transition Properties dialog box appears:

- In the Condition tab, you can enter a boolean expression associated by an AND or a OR operation to the Mouse Capture condition (see a typical example below).

- In the Flags tab, the transition properties can be changed.

- Click Cancel.
Click the transition and re-loop it on the step S0 using drag and drop.
In this way, the activity is re-enabled as soon as you click the target.

Close the SFC+ Editor by clicking the red cross.
To test the behavior of the activity in simulation:
- Select the Main block in the Simulation Logic tree and click the Play of the compass
. The block is compiled and the simulation is initialized. The Simulation toolbar and the Signals Monitoring window appear.
- Expand the Instance node of the Signals Monitoring window.

- Click Show/Hide Logics Monitoring
in the Simulation toolbar. The Logics Monitoring window appear.
- Click Next
in the compass. The simulation is launched, the step S0 highlighted in blue is active.

- Click the button in the 3D view.

Note:
It is recommended to disable the Resource Selection and the Manipulation Handle Mode commands so as not to display the Selection Assistant and the Green Bounding Box when clicking the target product.
- Click Next
twice. The port Click is true and the transition Lighted Round Push Button Led is fired.

- Click the Play of the compass to close the simulation.
You have programmed a Mouse Capture activity in SFC+. You can now complete the logic by adding, for instance electrical inputs/outputs, to model the behavior of a real push button.

Program a Mouse Capture Activity in Dataflow
You can program a Mouse Capture activity in Dataflow.
Open a device containing a Simulation Logic in the Live Simulation environment.
Note:
To modify the kind of the block, select Edit Properties in the block contextual menu and select SFC+ or Dataflow in the Kind drop-down box.
Click the Device Designer thumbnail to see the simulation logic tree. The Main block of the Simulation Logic must be a Dataflow block (see typical example below).

Double-click the Main block in the simulation logic tree.
A 2D immersive window is opened to edit the block behavior. The Block Editor commands are in a toolbox at the right side of the screen.

Note:
In our example, the block behavior is undefined, so the window is empty.
Click Mouse capture in the Activities toolbox.
Then, select the product/part being the target of the interaction in the 3D view.
The selected part is highlighted.

Click the bubble to confirm the selection of the part.
Then, click in the background of 2D immersive window to set the position of the Mouse Capture action.
 During a simulation, the instance remains active until you click the target.
Note:
In Dataflow, the creation of a Mouse Capture activity is restricted to only one activity per target product. If the Interaction activity has to be activated more than once, the Reset port must be used to reinitialize the activity.
To re-enable the activity as soon as you click the target, create the block behavior as follows:
- Double-click the block in the 2D window.
The Activity instance properties dialog box appears.

- Check Use Reset Port and click OK.
The Reset port of the instance is displayed.

- Select Add Non-Initialized Delay
in the Predefined Blocks toolbar and click the 2D immersive window to position the instance.

- Arrange the layout of the block by resizing the instances, moving the ports and hiding their names.

- Use the command Add Mapping
in the Blocks Tools toolbar to map the instances as follows:

- Right-click the output port of the activity and select in its contextual menu.

Close the Block Editor by clicking the red cross.
To test the behavior of the activity in simulation:
- Select the Main block and click the Play of the compass
. The block is compiled and the simulation is initialized. The Simulation toolbar and the Signals Monitoring window appear.
- Expand the Ports node of theSignals Monitoring window.

- Click Next
in the compass.
- Click the button in the 3D view.

Note:
It is recommended to disable the Resource Selection and the Manipulation Handle Mode commands so as not to display the Selection Assistant and the Green Bounding Box when clicking the target product.
- Click Next
. The port Click becomes true.

- Click the Play of the compass to close the simulation.
You have programmed a Mouse Capture activity in Dataflow. You can now complete the logic by adding, for instance electrical inputs/outputs, to model the behavior of a real push button.
|