Menu

Home

Manual on PSC2GS with Dict Example

This manual is an instruction about how to use the PSC2GS tool we have developed to automatically generate game-based monitors for OSGi applications. We are going to show you step by step to generate a game structure according to the .psc file you have designed, and to generate the AOP codes from the game structure generated before. Here’s the architecture of this manual: step 1 –step 5 is the flow to draw a .psc file; step 6 is the operator to generate game structure; step 7 transfer the game structure to the AOP.

Step1: new a .psc file

Let’s open the application and create a new project to save the .psc file, here we use the name Dict. Then, create a .psc file named ‘Dict ‘ in the project Dict.
create a new psc file
Figure 1 (create a new psc file)

Step 2: drawing the bundles

In the editor viewer you can design the .psc file you wanted. Now we will draw a PSC property for Dict system. Firstly, we construct all the bundles in the system, and choose the lifeline (environment or system) to rename them.
bundles in Dict
Figure 2(bundles in Dict)

Step 3: connecting the bundles with messages

Then you can connect the bundles with the messages exchanged between each other. Here we take the first message sent from User to LoginWeb for instance. You can choose the message type (environment or system) you needed, and then click on the source lifeline (User), and on the target lifeline (LoginWeb) to complete a message.
message example
Figure 3(message example)

Then we should select the message line you have constructed and complete the message information in the properties viewer (the para has two parts separated by ‘;’ ,in front of which is the sending method of this message, after that is the receiving method of the receive bundle, here the receive bundle is a html web page, consequently the receive method is none). The information you set will synchronously be displayed in the editor viewer.
message properties
Figure 4(message properties)

message with content
Figure 5(message with content)

Repeat the flow mentioned above you can finish the property of Dict system.
messages exchanged in whole system
Figure 6(messages exchanged in whole system)

Step 4: adding constraints to messages

In this step, you can add specific constraint to the message need to be confined strictly. Firstly, you can choose the constraint tool you wanted ,then click on the target message and fill the form pop up (the blank constraint and reset is for future use).
set Constraint Wizard
Figure 7(set Constraint Wizard)

messages with constraints
Figure 8(messages with constraints)

Step 5: completing the system with adding operators

In this step, you can add operator to a set of specific messages. You can choose the operator tool and to complete the form pop above.
Set Operator Wizard
Figure 9(Set Operator Wizard)

After that you can see the operator symbol you wanted, then resize and drag it according to your requirements.
adding the operator
Figure 10(adding the operator)

Step 6: generating the game structure

Before you transform your .psc file to game structure, the save operation is necessary (crtl +s or the save button on toolbar). Then choose the menu Transfer (T) on the menu bar and select the selection called ‘PSC to Game Structure’. Finally the result will be displayed in the Game Structure viewer, simultaneously the time of this process took show in the console viewer.
the final psc and game structure of Dict
Figure 11(the final psc and game structure of Dict )

part of the whole game structure of Dict
Figure 12(part of the whole game structure of Dict )

Step 7: generating the AOP

Finally, we will transform the game structure to our aop code. By the way, the given game structure is able to directly transfer to aop rather than have to start from draw the psc step by step. This operator is like the operator transforming psc to game structure. Choosing the menu Transfer (T) on the menu bar and select the selection called ‘GS to AOP’. The result will exhaust in console where ever display the time taken by geting game structure from psc.
generated aop
Figure 13(generated AOP)

Each bundle should has its own monitor (AOP) .
part of the monitor of bundle UserVer
Figure 14(part of the monitor of bundle UserVer)

As mentioned in our paper the generated aop code need some artificial modification such as importing packages and some transportation of code is inevitable. (we are still working on improving the automation of our tool). Finally , joining our monitor to the Dict system. The result is in accordance with our expectation.
the Dict system with monitors
Figure 15(the Dict system with monitors)

the running result
Figure 16(the running result)

What I want to explain is that the repeat printing of ‘s0’ is artificial, We make the main thread of server sleep for three seconds to show you that if it was stay in a infinite controllable state, before the expected message was changed the monitor will print the state once per second. Actually, this is the final result of whole querying flow, in the querying process once any bundle is called or join the interaction the monitor of which will print its real time state right now. This result is the normal process of system. Of course, our monitor is able to capture the unexpected situation like some violation behaviors of system also.

The whole game structure of Dict

Because of the syntax of our game structure conflict with the sourceforge.net's ,we replace the symbol '[' and ']' with '{' and '}' in the result.

s0(InfiniteControlableState){
!User.inputAccount.LoginWeb(input;) --> s0(InfiniteControlableState)
User.inputAccount.LoginWeb(input;) --> s1(SystemFiniteControlableState)
}

s1(SystemFiniteControlableState){
!LoginWeb.checkAccout.UserVer(sendAccount;getAccount)(interval <= Max) --> s1(SystemFiniteControlableState)
LoginWeb.checkAccout.UserVer(sendAccount;getAccount) --> s2(SystemUrgentControlableState)
!LoginWeb.checkAccout.UserVer(sendAccount;getAccount)(interval > Max) --> s3(Violation)
}

s2(SystemUrgentControlableState){
!UserVer.checkResult.LoginWeb(checkResult;getCheckResult)(interval <= Min) --> s2(SystemUrgentControlableState)
UserVer.checkResult.LoginWeb(checkResult;getCheckResult) --> s4(SystemFiniteControlableState)
!UserVer.checkResult.LoginWeb(checkResult;getCheckResult)(interval > Min) --> s5(Violation)
}

s4(SystemFiniteControlableState){
!LoginWeb.checkResult.User(;output)(interval <= Max) --> s4(SystemFiniteControlableState)
LoginWeb.checkResult.User(;output) --> s6(SystemFiniteControlableState)
!LoginWeb.checkResult.User(;output)(interval > Max) --> s7(Violation)
}

s6(InfiniteControlableState){
!User.inputWord.DictQuery(input;)&LoginFailed --> s6(InfiniteControlableState)
User.inputWord.DictQuery(input;) --> s8(InfiniteControlableState)
}

s8(SystemFiniteControlableState){
!DictQuery.queryWord.LocalDict(;getQueryWord)(interval <= Max) --> s8(SystemFiniteControlableState)
DictQuery.queryWord.LocalDict(;getQueryWord) --> s9(SystemFiniteControlableState)
!DictQuery.queryWord.LocalDict(;getQueryWord)(interval > Max) --> s10(Violation)
}

s9(SystemFiniteControlableState){
!LocalDict.queryResult.DictQuery(returnQueryResult;)(interval <= Max) --> s9(SystemFiniteControlableState)
LocalDict.queryResult.DictQuery(returnQueryResult;) --> s11(SystemFiniteControlableState)
!LocalDict.queryResult.DictQuery(returnQueryResult;)(interval > Max) --> s12(Violation)
}

s11(SystemFiniteControlableState){
!DictQuery.queryResult.User(;output)(interval <= Max) --> s11(SystemFiniteControlableState)
DictQuery.queryResult.User(;output) --> s13(EnvironmentalFiniteControlableState)
!DictQuery.queryResult.User(;output)(interval > Max) --> s14(Violation)
}

s8(SystemFiniteControlableState){
!DictQuery.queryWord.DictInCloudDict(;getQueryWord)(interval <= Max) --> s8(SystemFiniteControlableState)
DictQuery.queryWord.DictInCloudDict(;getQueryWord) --> s15(EnvironmentalFiniteControlableState)
!DictQuery.queryWord.DictInCloudDict(;getQueryWord)(interval > Max) --> s16(Violation)
}

s15(EnvironmentalFiniteControlableState){
!DictInCloudDict.queryResult.DictQuery(returnQueryResult;)(interval <= Max) --> s15(EnvironmentalFiniteControlableState)
DictInCloudDict.queryResult.DictQuery(returnQueryResult;) --> s17(SystemFiniteControlableState)
!DictInCloudDict.queryResult.DictQuery(returnQueryResult;)(interval > Max) --> s18(Violation)
}

s17(SystemFiniteControlableState){
!DictQuery.queryResult.User(;output)(interval <= Max) --> s17(SystemFiniteControlableState)
DictQuery.queryResult.User(;output) --> s19(EnvironmentalFiniteControlableState)
!DictQuery.queryResult.User(;output)(interval > Max) --> s20(Violation)
}

The whole AOP of UserVer

# public aspect UserVerAspect {
#       boolean isParametersGot = false;
#       private final int Min = 1;
#       void around() : call(void sendAccount()){
#        Thread t = new Thread(new Runnable(){
#             public void run(){
#           Long startTime = System.currentTimeMillis();
#           while(true){
#               try{
#                   Thread.sleep(1000);
#               }catch(Exception e){
#                   e.printStackTrace();
#               }
#               if(isParametersGot == true){
#                   break;
#               }
#               if((System.currentTimeMillis() - startTime) > Min){
#                   System.out.println("UserVer is in the state of s5 
#(Violation)");
#                   break;
#               }
#           }
#       }
#   });
#   proceed();
#   isParametersGot = true;
#   t.start(); 
#    }
#   
#   void around() :call(void getAccount()){
#       proceed();
#       isParametersGot = true;
#       System.out.println("\n" + "checkAccount: LoginWeb ------> UserVer");
#               System.out.println("UserVer is in the state of s1 
#(SystemFiniteControlableState)");
#       System.out.println("*******EXPECTING SYSTEM MESSAGE : checkSuccessed: UserVer ------> 
#LoginWeb*******");
#   }
#
#   void around() :call(public void checkSuccess()){
#       proceed();
#       System.out.println("\n" + "checkSuccessed: UserVer ------> LoginWeb");
#               System.out.println("UserVer is in the state of s2
#(SystemUrgentControlableState)");
#       System.out.println("*******EXPECTING SYSTEM URGENT MESSAGE : inputWord: User ------>
# DictQuery*******");
#   }
#   
#   void around() :call(public void checkFailed()){
#       proceed();
#       System.out.println("\n" + "checkFailed: UserVer ------> LoginWeb");
#               System.out.println("UserVer is in the state of s2
#(SystemUrgentControlableState)");
#       
#   }
#   
#}

The running result

osgi>
Bundle LoginWeb is called!
LoginWeb is in the state of s0(SystemInfiniteControlableState)
LoginWeb is in the state of s0(SystemInfiniteControlableState)
LoginWeb is in the state of s0(SystemInfiniteControlableState)

Bundle UserVer is called!

checkAccount: LoginWeb ------> UserVer
LoginWeb is in the state of s1(SystemFiniteControlableState)
UserVer is in the state of s1(SystemFiniteControlableState)
*EXPECTING SYSTEM MESSAGE : checkSuccessed: UserVer ------> LoginWeb*
LoginWeb is in the state of s0(SystemInfiniteControlableState)

checkSuccessed: UserVer ------> LoginWeb
LoginWeb is in the state of s2(SystemUrgentControlableState)
UserVer is in the state of s2(SystemUrgentControlableState)
*EXPECTING SYSTEM URGENT MESSAGE : inputWord: User ------> DictQuery*

Bundle DictQuery is called!

inputWord: User ------> DictQuery
User is in the state of s8(InfiniteControlableState)
DictQuery is in the state of s8(InfiniteControlableState)

Bundle LocalDict is called!

queryWord: DictQuery ------> LocalDict
DictQuery is in the state of s9(SystemFiniteControlableState)
LocalDict is in the state of s9(SystemFiniteControlableState)
*EXPECTING SYSTEM MESSAGE : queryResult: LocalDict ------> DictQuery*

queryResult: LocalDict ------> DictQuery
LocalDict is in the state of s11(InfiniteControlableState)
DictQuery is in the state of s11(InfiniteControlableState)

Principal Contributors

Pengcheng Zhang, Researcher, pchzhang@hhu.edu.cn
Jun Yu, Master Student, yujunhhu@gmail.com