Description
We take a pre-existing Statecharts model of a simple traffic light controller and reimplement it in Ptolemy II. This exercise reveals that Statecharts can be usefully onceptualized as a hierarchical combination of two distinct models of computation (MoCs), finite state machines (FSMs) and synchronous/reactive (SR). Once conceptualized this way, we can add additional MoCs to the mix. We illustrate this by adding a discrete-event (DE) model of the environment in which the traffic light operates. We then construct a second model of a deployment of the system on two microcontrollers communicating wirelessly, showing that we can effectively leverage both DE and an extension in Ptolemy II that supports modeling of wireless communication networks. This exercise reveals that even though the original model was intended to be a purely functional model, it in fact imposes constraints on the implementation. The model had to be refactored to get a distributed deployment model. Finally, we show that the portions of the models defining the control logic of the lights can be shared between the functional and deployment models using actor-oriented classes. This eases maintenance of the models.