(This feature is not available in version 1.0.0)
With Scripted Components it is possible to define the behaviour of the device in a script.
Scripted components are a type of Modular Components, with an extra file containing the script.
Creating an Scripted component involves these steps:
This file describes which kind of component it is and the parts or modules it contains.
For example, in the file below we can see that core is set to "scripted" , so this is an Scripted component, and the script is in "file.as" :
<iou name="comp_name" core="scripted" script="file.as" >
<properties name="group name">
<property name="prop1" type="double" />
<property name="prop2" type="uint" />
</properties>
<ioport name="PORTA" pins="A,B,C,D,E,F" />
</iou>
We can also see That there is a property group with 2 properties and an IO Port with 4 pins.
Script must implement property getters and setters:
void setProp1( double val )
double getProp1()
void setProp2( uint val )
uint getProp2()
This is a program written in The script language describing the behavior of the component.
Script files must have extension .as and use the name defined in the definition file.
These are functions you can implement in the script.
void setup()
void reset()
void voltChanged()
void updateStep()
void runEvent()
void extClock( bool clkState )
int getCpuReg( string name )
string getStrReg( string name )
void command( string c )
void setLinkedValue( int val, int i )
void setLinkedString( string str, int i )
void INTERRUPT( uint vector )
void print( string &msg )
IoPort@ getPort( string port )
IoPin@ getPin( string pin )
McuPort@ getMcuPort( string port )
McuPin@ getMcuPin( string pin )
void addCpuReg( string name, string type )
void addCpuVar( string name, string type )
void toConsole( string msg ) // To Delete
void showValue( string val )
void addEvent( uint time_ps )
void cancelEvents()
uint64 circTime()
int readPGM( uint addr )
void writePGM( uint addr, int val )
int readRAM( uint addr )
void writeRAM( uint addr, int val )
int readROM( uint addr )
void writeROM( uint addr, int val )
void INTERRUPT( uint vector )
string getPropStr( int index, string name )
void setLinkedValue( int index, int val, int i )
void setLinkedString( int index, string val, int i )
void setPinMode( uint mode )
uint getInpState()
void setOutState( uint state )
void changeCallBack( eElement@ e, bool en )
void setPinMode( uint mode )
void setOutState( bool state )
bool getInpState()
double getVoltage()
void setVoltage( double volt )
void changeCallBack( eElement@ e, bool en )
void controlPort( bool outCtrl, bool dirCtrl )
void setDirection( uint dir )
uint getInpState()
void setOutState( uint state )
void setDirection( bool dir )
void setPortState( bool state )
void controlPin( bool outCtrl, bool dirCtrl )
void setExtInt( uint mode )
void setPinMode( uint mode )
bool getInpState()
void setOutState( bool state )
double getVoltage()
void setVoltage( double volt )
void changeCallBack( eElement@ e, bool en )