Friday, April 28, 2017

Tutorial: How to build the Host Request GoOnline

Overview

Host want to send the GoOnline Request to the semiconductor equipment. The scenario likes that:

Prerequisite

1. SecsDriver had been run in the VirtualBox: See last post how to install in virtualBox

2. Download or compile the HostExample. The binary and source code which can download from:


3. The SecsDriver Controler. Can be download source code and binary from here

Deployment

1. SecsDriver and SecsDriver (tool Simultor) run on VirtualBox
2. HostExample run on Host PC
3. SecsDriverControler run on HostPC

Configuration

The default configuration:
1. SecsDriver Host
- Host port: listening on port 5555 (Waiting connection from HostExample)
- Service port: listening on port 6666 (Waiting connection from SecsDriver Controler)
- CONTROL0=Type=HSMS-SS;Log= 0log;DeviceId=0;LUA=lua2.lua;XSML=varian_host.xsml;Port=9000;IpAddress=192.168.1.1;Mode=Passive;Role=HOST;T3=10;T5=5;T6=10;T7=10;T8=10;TCA=5

2. SecsDriver Tool (simulator)
- Host port: listening on port 5557 (Waiting connection from HostExample)
- Service port: listening on port 6667 (Waiting connection from SecsDriver Controler)
- CONTROL0=Type=HSMS-SS;Log=0log_tool;DeviceId=0;LUA=lua2.lua;XSML=varian_tool.xsml;Port=9000;IpAddress=127.0.0.1;Mode=Active;Role=HOST;T3=10;T5=5;T6=6;T7=10;T8=10;TCA=5

Running

From virtualBox:

1. Run SecsDriver Host

./run.sh

2. Run SecsDriver Tool (Simulator)

./run_tool.sh

3. Run SecsDriverControler (MSC.exe)

Connect to SecsDriver Host, by IP of Virtualbox and port 6666 (port 6666 is the service port of SecsDriver Host)

4. Run HostExample
Connect to the SecsDriver Host, by IP of VirtualBox and port 5555.

Tip: How to get the IP of the VirtualBox ?
run the linux command 
ifconfig


In this example, the IP of VirtualBox is 192.168.1.8

Now we go to the main tutorial, how to build the GoOnline Request from host

Build the GoOnline Request

First, use the MSC connect to the SecsDriver Host (port 6666), then try to send the S1F1 (are you there) by click on the SEND MESSAGE from the MSC. (See the image)
You can see the S1F1 has been sent and get back the reply S1F2 from SecsDriver simulator


Update the host script control

OK, so now we get the script and change some thing. From MSC, Control_0 tree node, right click and choose GET SCRIPT




And you will get back the script of the Control_0.

The MSC.exe have the very bad of text editor :( i am sorry :) so you can copy all to your text editor.
This is the LUA script language (https://www.lua.org)

Check the script here

function MESRequest(xmlRequest, ctlId)
    print("MESRequest Begin ctlId="..ctlId.." currentControlId="..ControlID.."\n");
    print("-XML="..xmlRequest);
    xml = xmlParser( xmlRequest );
    if (xml==nil or xml[1]==nil or xml[1].xarg==nil) then
    print "NULL"
    do return end
    end
    print_r( xml );
    requestname = xml[1].xarg.name;
    requestControlId = xml[1].xarg.controlId;
    -- Check the control Id...
    if(tonumber(requestControlId)~=ControlID) then
        print("If this is not the same Control ID, do not process...\n")
        print("MESRequest END...")
        return
    end
    -- print( "SIZE="..#xml[1] );
    param={};
    for i=1,#xml[1] do
        param[xml[1][i].xarg.name]=xml[1][i][1];
    end
    print( "Request Name: ["..requestname.."]\n" );
    print( "Parameter:\n-----------------" );
    print_r( param );
    print( "-----------------\n" );

    if( requestname=="GoOnline" ) then
        GoOnline( param );
    elseif( requestname=="GoOffline" ) then
        GoOffline( param );
    else
        WriteLog( "LUA CALL WRITE STRING " );
    end

    print("MESRequest End\n");
end

All host request will be came from the function MESRequest.

String: xmlRequest: is the XML (or JSON) from the HostExample
String: ctlId : is the control Id. (integer value)

If the requestname = "GoOnline" it will call to the GoOnline

function GoOnline(param)
-- SEND S1F1 message - and wait for getting back S1F2.
SendRecvMessage( "S1F1_F2_ARE_YOU_THERE" );
-- Report to HostExample
HostReport[[<HostReport name="GoOnlineRpt"><param name="resultText">Send GoOnlineReq to Equipment Sucessful</param></HostReport>]];
end

In the MSC, find the GoOnline function, and replace by this code above
Then, click on SAVE SCRIPT. MSC will update the lua script in the SecsDriver Host. (on virtualbox)


So now, from HostExample, connect to SecsDriver Host, then BuildReq and finally send the request to SecsDriver Host.



You can see the request had been sent to SecsDriver Host.
Then SecsDriver Host, send S1F1 to tool and wait to get back S1F2
Then, SecsDriver Host send the HostReport to hostExample.

Enjoy !

0 comments:

Post a Comment

About Me

Work as the developer. c++, cpp, java, c#...
vuzzan@gmail.com

Popular Posts

Search This Blog