<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Tsmart-BIPEX: An Integrated Graphical Design Toolkit for Software Systems</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Huafeng Zhang</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yu Jiang</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Han Liu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ming Gu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jiaguang Sun</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of Software, Tsinghua University</institution>
          ,
          <country country="CN">China</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>To help build reliable software systems e ciently, the component based model-driven design approach is widely used, and lots of modeling languages have been designed. In this paper, we propose an integrated graphical development toolkit Tsmart-BIPEX 1 in support of building complex systems in the BIP modeling language, which features a rich semantics for composing sub-systems. First, we build a graphical interface for model construction and simulation, which is more intuitive than the command-line based toolchain. Furthermore, to enhance the original BIP veri cation tool RTD-Finder, we translate the graphical model to a labeled transition system for a thorough veri cation in verier VCS. Finally, we can generate executable C++ code directly from the graphical model. Tsmart-BIPEX has been successfully applied in the development of a real-world train network controller.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        As embedded devices gain more and more computing power, the systems on
these platforms are expected to accomplish much more sophisticated tasks, which
brings new challenges to ensure the correctness of embedded softwares in the
traditional development approaches [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. According to the report from National
Institute of Standards and Technology, 70% of faults are introduced in the forepart
of the life-cycle, and 80% of them are not discovered until integration and system
test or later, which leads to 10X or higher repair cost [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>
        A promising way to alleviate the pain of detecting design defects in later
phases is the component-based model-driven design approach [
        <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
        ]. The key
idea is to build a structural model that decompose a complex system into
subsystems with independent functions, then provide coordination semantics to
assemble these sub-systems together, and nally synthesize executable code from
the veri ed model. During the last decades, lots of component based modeling
languages such as safety state machine[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], state ow[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], and BIP[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] have
been proposed and widely used with their corresponding supporting toolkits.
      </p>
      <p>
        Among them, BIP features its semantics with the support of complex
interaction and dynamic priorities which can be further used to express complex
scheduling policies. It brings BIP strong expressiveness that cannot be matched
by other modeling languages, but also results in the limited veri cation support
of the tool RTD-Finder [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], where lots of temporal properties can not be
veri ed. More complex semantics is harder to be formalized for a comprehensive
veri cation. Furthermore, during the real engineering practice, we found that
BIP is a textual modeling language based on a command-line based toolchain
for model simulation and synthesis, which is inconvenient for model construction
and interactive debugging.
      </p>
      <p>In this paper, we improve the convenience and veri cation e ciency of BIP
by developing an integrated graphical design toolkit Tsmart-BIPEX. The
overall structure of the toolkit is shown in Fig. 1. First, graphical model editor and
simulator are implemented to assist the engineers according to the BIP
syntax and semantics. Then, a translator is developed to translate the model to an
equivalent labeled transition system, which can be directly veri ed by the VCS
model checker. Finally, the original code generator is seamlessly integrated for
C++ code generation. While the original supported compiler and engine are only
provided on Linux with a command-line interface for textual model construction,
Tsmart-BIPEX can be installed on Mac-OSX, Linux, and Windows.</p>
      <p>Graphical</p>
      <p>Models
Graphical Model</p>
      <p>Editor</p>
      <p>Simulation
Visualization
Interactive
Simulator</p>
      <p>Safety Critical</p>
      <p>Properties</p>
      <p>Executable Code</p>
      <p>on Devices
Model Checker</p>
      <p>Code Generator</p>
      <p>Tsmart-BIPEX Platform</p>
      <p>Related work is presented in Section 2. Some backgrounds on the
computation model BIP are presented in Section 3. The implementation of
TsmartBIPEX is introduced in Section 4. A case study of a real-world system design
is presented in Section 5, and we conclude with Section 6.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        During the last decades, lots of component based modeling languages such as
safety state machine, statechart, state ow, and BIP have been proposed
for the modeling of complex systems. Based on those modeling languages, many
design toolkits have been implemented, such as SCADE[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], Statemate[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ],
Simulink State ow[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] and RTD-Finder. These toolkits have been
successfully applied in both academic and industrial applications.
      </p>
      <p>For example, SCADE is a development suite for building safety-critical
embedded systems based on the synchronous modeling language safe state
machine, and is widely used in safety-critical applications such as avionics and train
control. Simulink State ow is a modeling and simulation platform based on
the event-driven modeling language State ow, which highlights its tight
integration with Matlab computing environment. It also provides numerous
toolboxes such as Design Veri er and Polyspace for model construction and
synthesized code analysis. Statemate developed by IBM is a working environment
for the development of complex reactive software based on the reactive modeling
language Statechart, where the software can be modeled and synthesized from
a set of parallel and synchronized automata.</p>
      <p>Except for those famous but expensive industrial tools, there are also many
academical prototypes for system design such as Ptolemy, LabView, BIP and
ForSys. They add new modeling and analysis features to the original industrial
tools. For example, Ptolemy supports the design of heterogenous systems. BIP
features its semantics with the support of complex interaction and dynamic
priorities which can be further used to express complex scheduling policies, which
cannot be matched by other modeling languages. In our work, we try to improve
the convenience and veri cation e ciency of BIP by developing an integrated
graphical design toolkit Tsmart-BIPEX.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Background</title>
      <p>In BIP, a system is speci ed in textual description with the composition of
components and the interaction between components. There are two types of
components, where the atomic components are a class of components which specify
the behavior of independent sub-systems in labeled transition graphs, and the
compound components schedule the communication between atomic components
by de ning interactions connecting atomic components and priorities of the
interactions. The textual model can be compiled, validated and synthesized with
command-line support on Linux system.</p>
      <p>User</p>
      <p>press
Press Interaction</p>
      <p>pressed</p>
      <p>Lamp Controller
Time Sync synctime reset
Interaction</p>
      <p>Reset Interaction</p>
      <p>Off
true
{time = 0;}
press Low
true
sync{}time Wait
time &gt;=5
{}
press
time &lt;5
{}
press</p>
      <p>High true
{}
press
true
{}
reset</p>
      <p>Rest
synctime reset eexxppoorrtt ienPtPoortrt rseysnectt(i)me(int time)</p>
      <p>Clock ienxtptoimrtee=Po0rt press()
Fig. 2. A visual example of BIP model, including the compound and atomic
component, interactions, ports, states, transitions with actions and guards, local variables.</p>
      <p>
        We depict the main features by an example constructed in the graphical
interface of Tsmart-BIPEX in Fig. 2. This model represents how a user controls
the brightness of a lamp. The left part shows the top-level model with three
components: User, Lamp Controller, and Clock. Components communicate with
each other through interactions. The interaction between User and Lamp
Controller is Press Interaction. The interactions between Lamp Controller and Clock
are Time Sync Interaction and Reset Interaction. Interactions and components
are connected via ports (the black dots attached to components). When an
interaction is red, it triggers the computation of its connected components via
related ports. The right part shows the detailed behavior of the Lamp Controller
by an automaton. To obtain a full description for BIP, please refer to [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
    </sec>
    <sec id="sec-4">
      <title>Tsmart-BIPEX Implementation</title>
      <p>
        The overall structure of Tsmart-BIPEX is presented in Fig.1, and is
implemented on the Eclipse Rich Client Platform. The whole project contains 74,719
lines of Java codes and 2,358 lines of Clojure code, where 36,278 lines are
inherited from Tsmart-GalsBlock[
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] which contributes to the common graphical
user interface and pure hardware design. The four components contained in the
toolkit are described as follow.
      </p>
      <p>
        Graphical Model Editor. The graphical model editor is based on Eclipse
RCP and Eclipse Graphical Modeling Framework which implements the BIP
syntax de ned in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. The editor supports the graphical creation and editing of
compound &amp; atomic components and interactions and its graphical interface is
shown in Fig. 3. The editor's four views exhibits how the sub-components and
interactions in a compound component are created. (1) The project view lists
the models contained in the current project. (2) The editor view shows a canvas
where the selected model's diagram can be edited. (3) The palette view provides
a bundle of prede ned components and interactions which can be dragged into
the editor view as a template for the creation of a new model element. (4) The
model structure view displays the hierarchical structure of the current model
in editing. The interface for editing atomic components provides similar view
layout with elements for automata construction, as presented in Fig.2.
      </p>
      <p>Graphical Model Simulator. The graphical simulator is based on the
execution semantics of BIP and provides interactive simulation of the constructed
graphical model. In each step, an interaction or component is selected according
to their state and execution priority, and the computation inside this candidate
is executed. The graphical simulator helps users explore the system's behavior
in a through way. Some basic functions are provided by the simulator, including
model states traversal and execution traces recording, etc.</p>
      <p>
        The simulation interface includes ve main views. (1) The simulation action
toolbar includes initialization, step-forward, step-backward and reset actions.
(2) The canvas view visualizes the simulated model in the same layout as the
editor, with the enabled components or interactions highlighted for choice. (3)
The candidate view displays all candidates (enabled components or interactions)
with the highest priority in the model's current state, whose inner computation
will be triggered if this element is selected. Users can manually select one
candidate to trigger by double-clicking the corresponding item or let the simulation
engine selects one randomly. (4) The data view lists values of local variables of
every component in the current state. (5) The model structure view shows the
hierarchical structure of the simulated model.
Model Checker. The model checker is VCS [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], which takes the labeled
transition system and corresponding properties written in computation tree logic
formula as input, and export the veri cation output with optional
counterexamples. Although RTD-Finder supports the veri cation of BIP, its computation
e ciency for global invariant is not as good as VCS. For integration, we develop
an engine to translate the graphical BIP model to a semantics equivalent labeled
transition system, which can be veri ed by VCS directly. The formal veri cation
complements the simulation to provide stronger support for correctness.
      </p>
      <p>
        Code Generator. The code generator for BIP is integrated based on the
source-to-source transformation architecture introduced in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], which allows the
generation of C++ code from BIP models. The generated source code can be
executed on an embedded platform consisting of a BIP engine to schedule the
computation of components and interactions. The original code generator engine
is very good, and we integrate it into the graphical design environment. The user
just needs to click the code generation button, and the code would be generated.
5
      </p>
    </sec>
    <sec id="sec-5">
      <title>Experimental Results</title>
      <p>
        We have applied Tsmart-BIPEX in the component-based model driven
development of a network interface controller to evaluate the e ectiveness of the
graphical toolkit. Network interface controller is an embedded device widely used
for the communication in several kinds of vehicle buses. The key component
of the network interface controller is the multi-function vehicle bus controller
(MVBC), which con rms with the protocol de ned in IEC 61375 [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
      </p>
      <p>First, strictly following the description of the standard IEC 61375, we build
a top-level model for the network layer of an MVBC device in Tsmart-BIPEX
as shown in Fig. 3. The top-level model of the network layer contains three
components: the producer of a message, the consumer of a message, and the
router which transmits a message from the source device to its destination device.
The router is modeled as an atomic component abstracted in Fig. 5, which
extracts the source device address and the destination device address from the
processed message and composes a new message to send.</p>
      <p>After several rounds of graphical model simulation, the MVBC model is
automatically translated to an equivalent labeled transition system for VCS
verication. We check several key requirements on the model, such as\the message
should not be sent to the link-layer if the source device address equals the
destination device address ". For the violated property, we need to check and revise
the constructed model manually based on the counter example. This veri cation
process strengthens the con dence in the constructed BIP model of MVBC.</p>
      <p>When all properties pass the veri cation, we can automatically generate C++
code from the veri ed BIP model. The generated C++ source les contain
2,537 lines of code, including 623 lines of the BIP engine code to coordinate the
components and interactions. Also, we write 146 lines of interface code to handle
the embedded device's I/O communications. All codes are compiled by the
armgcc-3.8 compiler to get an executable le running on the ARM processor of the
MVBC device. Then, we connect the automatically synthesized MVBC device
with the existing well-tested hand-written MVBC device, the communication
between the two devices functions well.
6</p>
    </sec>
    <sec id="sec-6">
      <title>Conclusion</title>
      <p>In this paper, we present an integrated graphical development toolkit
TsmartBIPEX to support the widely used BIP modeling language. With the
integration of the graphical model editor interface and the model simulation interface,
the convenience is greatly raised compared to the original textual model
construction and command-line based simulation. By translating the BIP model to
an equivalent labeled transition system, the veri cation e ciency is increased
compared to the original RTD-Finder. Our future work may focus on the
development and integration of more e cient code generation algorithms.
7</p>
    </sec>
    <sec id="sec-7">
      <title>Acknowledgment</title>
      <p>This research is sponsored in part by NSFC Program (No. 91218302, No. 61527812),
National Science and Technology Major Project (No. 2016ZX01038101),
Tsinghua University Initiative Scienti c Research Program (20131089331), MIIT
IT funds (Research and application of TCN key technologies ) of China, and
The National Key Technology R&amp;D Program (No. 2015BAG14B01-02).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Andre</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Semantics of safe state machine</article-title>
          .
          <source>I3S Laboratory</source>
          <volume>6070</volume>
          (
          <year>2003</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Basu</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bozga</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sifakis</surname>
          </string-name>
          , J.:
          <article-title>Modeling heterogeneous real-time components in bip</article-title>
          .
          <source>In: Fourth IEEE International Conference on Software Engineering and Formal Methods (SEFM'06)</source>
          . pp.
          <volume>3</volume>
          {
          <fpage>12</fpage>
          .
          <string-name>
            <surname>Ieee</surname>
          </string-name>
          (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Bensalem</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bozga</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nguyen</surname>
            ,
            <given-names>T.H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sifakis</surname>
          </string-name>
          , J.:
          <article-title>D- nder: A tool for compositional deadlock detection and veri cation</article-title>
          . In: International Conference on Computer Aided Veri cation. pp.
          <volume>614</volume>
          {
          <fpage>619</fpage>
          . Springer (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Dabney</surname>
            ,
            <given-names>J.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Harman</surname>
            ,
            <given-names>T.L.</given-names>
          </string-name>
          :
          <article-title>Mastering simulink</article-title>
          . Pearson/Prentice Hall (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Dormoy</surname>
            ,
            <given-names>F.X.</given-names>
          </string-name>
          :
          <article-title>Scade 6: a model based solution for safety critical software development</article-title>
          .
          <source>In: Proceedings of the 4th European Congress on Embedded Real Time Software</source>
          . pp.
          <volume>1</volume>
          {
          <issue>9</issue>
          (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Hamon</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rushby</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>An operational semantics for state ow</article-title>
          . In: International Conference on Fundamental Approaches to Software Engineering. pp.
          <volume>229</volume>
          {
          <fpage>243</fpage>
          . Springer (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Harel</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lachover</surname>
          </string-name>
          , Hagi, e.:
          <article-title>Statemate: A working environment for the development of complex reactive systems</article-title>
          .
          <source>IEEE transactions on software engineering 16(4)</source>
          ,
          <volume>403</volume>
          {
          <fpage>414</fpage>
          (
          <year>1990</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>He</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yin</surname>
          </string-name>
          , L.e.:
          <article-title>Vcs: A veri er for component-based systems</article-title>
          .
          <source>In: Automated Technology for Veri cation and Analysis</source>
          . pp.
          <volume>478</volume>
          {
          <issue>481</issue>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Jiang</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Li</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <article-title>etc: Design and optimization of multiclocked embedded systems using formal techniques</article-title>
          .
          <source>IEEE Transactions on Industrial Electronics</source>
          <volume>62</volume>
          (
          <issue>2</issue>
          ),
          <volume>1270</volume>
          {
          <fpage>1278</fpage>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Jiang</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Liu</surname>
          </string-name>
          , H.,
          <article-title>etc: Design of mixed synchronous/asynchronous systems with multiple clocks</article-title>
          .
          <source>IEEE Transaction on Parallel and Distributed</source>
          Systems pp.
          <volume>2220</volume>
          {
          <issue>2232</issue>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Jiang</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Song</surname>
          </string-name>
          , H.,
          <article-title>etc: Data-centered runtime veri cation of wireless medical cyber-physical system</article-title>
          .
          <source>IEEE Transactions on Industry Informatics</source>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Jiang</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
          </string-name>
          , H.e.:
          <article-title>Tsmart-galsblock: a toolkit for modeling, validation, and synthesis of multi-clocked embedded systems</article-title>
          .
          <source>In: Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering</source>
          . pp.
          <volume>711</volume>
          {
          <fpage>714</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Schifers</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hans</surname>
          </string-name>
          , G.:
          <article-title>Iec 61375-1 and uic 556-international standards for train communication</article-title>
          .
          <source>In: Vehicular Technology Conference Proceedings</source>
          ,
          <year>2000</year>
          . VTC 2000-Spring Tokyo.
          <source>2000 IEEE 51st. vol. 2</source>
          , pp.
          <volume>1581</volume>
          {
          <fpage>1585</fpage>
          .
          <string-name>
            <surname>IEEE</surname>
          </string-name>
          (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Tassey</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          :
          <article-title>The economic impacts of inadequate infrastructure for software testing (</article-title>
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>