//////////////////////////////////////////////////////////////////////////////////////////////     http://pengzhe1113.googlepages.com/
//     SciSCADA Toolbox
//     Developed by Zhe.Peng & Longhua.Ma
//     Email:pengzhe1113@gmail.com
//     Hangzhou, China
//     Sep.2006
///////////////////////////////////////////////////////////////////////////////////////////////////

mode(-1)

//get the directory of file
DIR=get_absolute_file_path('main.sci');  
                                                                                                                       //Set Tcl variable DIRE    
DIR_temp=DIR+'tcl'                       
TCL_SetVar('DIRE',DIR_temp);     

//Set Tcl variable DIRE_main      
TCL_SetVar('DIRE_main',DIR);

//run the Main TCL
TCL_EvalFile(DIR+'tcl\main.tcl');   
 
//Link modbus Dll                                                         
link(DIR+'dll\modbus.dll','send_ascii_1','C')
link(DIR+'dll\modbus.dll','send_ascii_2','C')
link(DIR+'dll\modbus.dll','send_ascii_3','C')
link(DIR+'dll\modbus.dll','send_ascii_4','C')
link(DIR+'dll\modbus.dll','send_ascii_5','C')
link(DIR+'dll\modbus.dll','send_ascii_6','C')
link(DIR+'dll\modbus.dll','ascii_anlys','C')

//Link serial Dll
addinter(DIR+'dll\serial.dll','serial',[ 'opencom';'closecom'; 'writecom'; 'writebincom';'readbincom';'resetcom';'getcomhandles']); 

//Link Ethernet Dll
link(DIR+'dll\socket_dll.dll','modbus_tcp','C')
link(DIR+'dll\socket_dll.dll','modbus_construct','C')

//Link Mysql Dll
link(DIR+'dll\scilab_mysql.dll','sql_connect','C');
link(DIR+'dll\scilab_mysql.dll','sql_query','C')
link(DIR+'dll\scilab_mysql.dll','sql_close','C')   

//Link OPC Dll
link(DIR+'dll\opc_client.dll','opc_connect','C');
link(DIR+'dll\opc_client.dll','opc_disconnect','C');
link(DIR+'dll\opc_client.dll','opc_read','C')
link(DIR+'dll\opc_client.dll','opc_write','C')
link(DIR+'dll\opc_client.dll','opc_add_group','C')    
link(DIR+'dll\opc_client.dll','opc_add_item','C')       
link(DIR+'dll\opc_client.dll','copy_item','C')    

//Add Helps 
%helps=[%helps; DIR+"man\opc", "OPC(OLE For Process Control)"]; 
%helps=[%helps; DIR+"man\modbus", "Modbus"];  
%helps=[%helps; DIR+"man\serial", "Serial"];  
%helps=[%helps; DIR+"man\ethernet", "Ethernet"];  
%helps=[%helps; DIR+"man\mysql", "Mysql"];  

// Add Demo to Scilab
add_demo("SciSCADA", DIR+'/main.sci')
clc;

