If a developer wishes to specify high-level properties, these take the form of nesC components providing the SimProperty interface, which has two commands: safetyPropertyCheck and livenessPropertyCheck, currently, T-Check can check multiple properties simultaneously. And the auxiliary "preprocessing" perl script can be applied to automatically wire property components into the application.
./preprocessing [Application symbol] [A file containing the pairs of non-generic configuration and module]
Taking MultihopOscilloscope as example, users can use following command to automatically instrument code.
./preprocessing CTPPROPERTY propertyWiring.txt
It is better to express the symbol name in a large case way, and the number of configuration and module pairs in the propertyWiring.txt specifies the number of properties users want to provide
At the beginning, the script asks users to choose one from three options
After running this command
#ifdef CTPPROPERTY components CtpP; SimPropertyCheckP.Property1 -> CtpP.Property1; SimPropertyCheckP.Property2 -> CtpP.Property2; #endif
The following code will be added as uses parts, n denotes the number of property.
uses interface SimProperty as Property1; ... uses interface SimProperty as Propertyn;
The relatively complex code will be added into implementation part of SimPropertyCheckP.nc, and we will not show the concrete code here
#ifdef CTPPROPERTY interface SimProperty as Property1; interface SimProperty as Property2; #endif
#ifdef CTPPROPERTY Property1 = Router.Property1; //"Router" is the alias of generic module "CtpRoutingEngineP.nc" Property2 = Router.Property2; #endif
#ifdef CTPPROPERTY interface SimProperty as Property1; interface SimProperty as Property2; #endif
#ifdef CTPPROPERTY command bool Property1.safetyPropertyCheck() { return TRUE; } command bool Property1.livenessPropertyCheck() { return TRUE; } command bool Property2.safetyPropertyCheck() { return TRUE; } command bool Property2.livenessPropertyCheck() { return TRUE; } #endif
Users may refer to property examples which were all expressed in executable manner and checked by T-Check.
The property for single node application should be expressed like below:
command bool SimProperty.livenessPropertyCheck() { return !receiveState.bufZeroLocked && !receiveState.bufOneLocked; }
The property for multiple nodes application can be written via following two modes:
(1). Sample liveness property for multi-nodes CTP with all motes' number starting from 0 and continuous
command bool SimProperty.livenessPropertyCheck() { int tmpMote = sim_node(), mote; for (mote = 0; mote < sim_simulated_mote_num(); mote++) { sim_set_node (mote); //change to mote¡¯s context if (sim_mote_forms_loop (mote)) { sim_set_node (tmpMote); return FALSE; } } sim_set_node (tmpMote); return TRUE; }
(2). Sample liveness property for multi-nodes CTP with all mote's number starting from 0 but non-continuous
command bool SimProperty.livenessPropertyCheck() { int tmpMote = sim_node(), mote; for (mote = 0; mote < sim_max_mote_num(); mote++) { if(sim_mote_status(mote) == ON) { sim_set_node (mote); //change to mote¡¯s context if(sim_mote_forms_loop (mote)) { sim_set_node (tmpMote); return FALSE; } } } sim_set_node (tmpMote); return TRUE; }
The main difference between above two modes concentrates on whether the mote's number is continuous or not. Note that sim_set_node(mote) function is critical for changing current context to specific mote's context.