janwilmans / DezyneSamples

Simple examples of Dezyne models and their generated code
MIT License
1 stars 0 forks source link

Code generation problems #3

Open janwilmans opened 6 years ago

janwilmans commented 6 years ago

All tests were done on the version of Dezyne downloaded from the Dezyne website at Nov 2. 2017. image

Generated using dzn service version 2.5.3.

without TSS (thread-safe-shell)

dzn code -l c++ -s AlarmSystem Alarm.dzn

generated two files: Alarm.hh and Alarm.cc

In Alarm.hh:

////////////////////////////////////////////////////////////////////////////////
// #ifndef ALARMSYSTEM_HH
// #define ALARMSYSTEM_HH

//interface includes
#include "Alarm.hh"
#include "Alarm.hh"
#include "Alarm.hh"

While this does not actually cause any problems, it is a little weird to include the same files multiple times.

with TSS (thread-safe-shell)

dzn code -l c++ -s AlarmSystem Alarm.dzn

generated two files: Alarm.hh and Alarm.cc

However, Alarm.cc tried to:

#include "AlarmSystem.hh"

So this does not compile.

with TSS (thread-safe-shell), but providing the wrong component as System

dzn code -l c++ -s Alarm Alarm.dzn

generated two files: Alarm.hh and Alarm.cc

However, the thread-safe-shell is not actually generated at all!

janwilmans commented 6 years ago

6072f6b8f7a4bce98448f32d4919a0998547f343 is generated with TSS.

1632 is the main thread 1504 is a second worker thread that triggers the sensor.

Why are the Detected and siren on action not deferred to the pump thread?

<external>.console.arm -> .alarm.console.arm [enter] [Disarmed, false] (tid: 1632)
sensor enabled (tid: 1632)
<external>.console.arm <- .alarm.console.arm [leave] [Armed, false] (return) (tid: 1632)
<external>.sensor.triggered -> .alarm.sensor.triggered [deferred] [Armed, false] (tid: 1504)
Detected! (tid: 1504)
siren on! (tid: 1504) 
janwilmans commented 6 years ago

the problem is due to a user error where it was actually possible to call the non-threadsafe methods from outside the threadsafe shell (because those std::function's where public (part of a struct.) it would be good to make them private so this becomes hard to use incorrectly.