>I do have some custom codes that uses C++ syntax, does that count? I had tried to keep them to basic C++ codes, e.g. for(), switch(), etc.
Those are probably FlexScript functions. FlexScript uses a similar syntax, but it is built by FlexSim directly, not with a C++ compiler.
If you didn't explicitly set a node to be C++ data, you probably don't have any C++ code in your model.
If it is crashing at different times, the first step to debugging it is to make your model repeatable. You can do that by following these steps:
Debugging Non-Repeatable Models
If a model is not giving repeatable results, the best way to debug the model is by looking at the Event Log, which can be found under the Debug menu.
- Set up the model exactly how you want to test it:
- Event Log open, "Enable Logging" checkbox ticked
- Start Time and End Time values set
- Various interface windows open or closed (3D views, Global Tables, etc.)
- etc.
- Save the model.
- Close FlexSim.
- Double-click on the model to open FlexSim with the model open.
- Press Reset once and Run once.
- Once the run is complete, or has passed your desired Stop Time in the Event Log window, press Export to save the log as a CSV file.
- Press Reset once and Run once.
- When the second run is complete, Export the new Event Log using a different file name.
- Now that you have the two event logs, you can compare them using a text comparison tool such as WinMerge.
- Find the first event where the time differs between the two logs.
- Inspect the objects involved in that event, or the objects that created that event, to see what could be different between the two runs.
- Rerun the model to just before that point, then step through events leading up to the diverging event. Use the debug tools to step through your code where necessary.
For some models, it helps to click the Event header on the Event Log and filter out particular events. For instance, if you are sending messages that include a memory address as one of the message parameters, those addresses will be different for every simulation run and will make finding other differences in your exported log file hard to find. Sometimes this is expected and can be accounted for by removing these events from your log file.
You can close and reopen FlexSim each time just in case the model is doing something to the application's state or variables in the MAIN or VIEW trees that aren't reset when you just open a model. This helps ensure that even if subsequent runs aren't the same, the first run in each test will match the first run of each subsequent test. Steps 3-6 should produce identical runs even if the model isn't repeatable after a simple Reset/Run without closing FlexSim.
Phil BoBo
Sr. Manager, Software Development