Rifartek Robot Training Course - How to use ClientRobot

521 views
490 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
521
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rifartek Robot Training Course - How to use ClientRobot

  1. 1. Rifartek Middleware Programming Training Course How to use ClientRobot
  2. 2. Outline <ul><li>Use ClientRobot to integrate ZigBee in 10 minutes </li></ul><ul><li>ClientRobot Integration </li></ul>
  3. 3. CliRobot Integration Script
  4. 4. Integrate ZigBee into DB (1/5) <ul><li>The ZigBee module will return: </li></ul><ul><ul><li>node-id, tag-id, LQI, RSSI </li></ul></ul>
  5. 5. Integrate ZigBee into DB (2/5) <ul><li>Insert Raw data into DB for further processing </li></ul><ul><ul><li>Use Database Module and </li></ul></ul><ul><ul><li>The “script” integration method </li></ul></ul>
  6. 6. Integrate ZigBee into DB (3/5) <ul><li>Click “script” button </li></ul><ul><li>Invoke wRobot to insert data for you </li></ul>
  7. 7. Integrate ZigBee into DB (4/5) String a[] = id.split(&quot;,&quot;); String param[] = new String[2]; param[0] = &quot;execute&quot;; param[1] = &quot;INSERT INTO zigbee(allid,insertTime,node_id,tag_id,LQI,RSSI) &quot; + &quot;values('&quot;+id+&quot;',NOW(),&quot;+a[0]+&quot;,&quot;+a[1]+&quot;,&quot;+a[2]+&quot;,&quot;+a[3]+&quot;)&quot;; try{ frame.call(&quot;Database&quot;,param); }catch(Exception e){ }
  8. 8. Integrate ZigBee into DB (5/5) <ul><li>Result </li></ul>
  9. 9. Integrate ZigBee into File
  10. 10. More about ClientRobot Integration
  11. 11. CliRobot and ServRobot <ul><li>Dynamic Relationship </li></ul>ServRobot module1 module2 CliRobot tab1 tab1 Negotiate Number of Modules Module attributes Security Mechanisms …
  12. 12. CliRobot and ServRobot (Cont.) <ul><li>Message Dispatch Relationship </li></ul>ServRobot CliRobot sendMsg (String) OnMsg(String) call(module, param) OnCmd( ) sendData (String) Server send RFID Tag information Client request server module to do command
  13. 13. CliRobot and Extension <ul><li>Script (java statement) </li></ul><ul><li>Plugin (java program) </li></ul>
  14. 14. CliRobot and Extension (Cont.) <ul><li>Script vs. Plugins </li></ul>CliRobot Receive Message For each module tab Is script? Is plugin? For each plugin Invoke plugin’s OnMsg() method dynamically execute statement done for this module yes yes No No
  15. 15. Script of CliRobot <ul><li>Click “script” button and </li></ul><ul><li>Write Java Statements </li></ul><ul><ul><li>What you want to do when you receive a message. </li></ul></ul><ul><ul><li>Ex: Write file </li></ul></ul>
  16. 16. Plugins of CliRobot <ul><li>Click “plugins..” button and </li></ul><ul><li>Write Java classes </li></ul><ul><ul><li>A set of java classes that fulfill your task </li></ul></ul><ul><li>Load main java class into plugin management panel </li></ul>
  17. 17. CliRobot Integration Using Script
  18. 18. Integrate ZigBee into DB (1/5) <ul><li>The ZigBee module will return: </li></ul><ul><ul><li>node-id, tag-id, LQI, RSSI </li></ul></ul>
  19. 19. Integrate ZigBee into DB (2/5) <ul><li>Insert Raw data into DB for further processing </li></ul><ul><ul><li>Use Database Module and </li></ul></ul><ul><ul><li>The “script” integration method </li></ul></ul>
  20. 20. Integrate ZigBee into DB (3/5) <ul><li>Click “script” button </li></ul><ul><li>Invoke wRobot to insert data for you </li></ul>
  21. 21. Integrate ZigBee into DB (4/5) String a[] = id.split(&quot;,&quot;); String param[] = new String[2]; param[0] = &quot;execute&quot;; param[1] = &quot;INSERT INTO zigbee(allid,insertTime,node_id,tag_id,LQI,RSSI) &quot; + &quot;values('&quot;+id+&quot;',NOW(),&quot;+a[0]+&quot;,&quot;+a[1]+&quot;,&quot;+a[2]+&quot;,&quot;+a[3]+&quot;)&quot;; try{ frame.call(&quot;Database&quot;,param); }catch(Exception e){ }
  22. 22. Integrate ZigBee into DB (5/5) <ul><li>Result </li></ul>
  23. 23. Integrate ZigBee into File
  24. 24. CliRobot Integration Using Plugin
  25. 25. The “ RifartekRobotPlugin ” base class (1/3) <ul><li>The base class that </li></ul><ul><ul><li>communicates with CliRobot </li></ul></ul><ul><ul><li>extends the capability of CliRobot </li></ul></ul><ul><li>Class Hierarchy: </li></ul>RifartekRobotPlugin MyPlugin OOP Extends java.awt.Frame OOP Extends Abstract class
  26. 26. The “ RifartekRobotPlugin ” base class (2/3) <ul><li>Constructor </li></ul><ul><li>Extensible methods </li></ul>Parent: The CliRobot reference ModuleName: The name of corresponding module that this plugin resident RifartekRobotPlugin( WRobotFrame parent, String moduleName); Explanation Method prototype The initialization jobs that have to do when the corresponding module is started or loaded. OnLoad( ) The cleanup jobs that have to do when the corresponding module is closed or unloaded. OnUnLoad( ) Explanation Method prototype
  27. 27. The “ RifartekRobotPlugin ” base class (3/3) <ul><li>Extensible methods (Cont.) </li></ul>The cleanup jobs that have to do when the plugin is stop by plugin management panel OnDestroy( ) The callback method that the PDI architecture would invoke when CliRobot receives a message from corresponding module. OnMsg(String msg, String antenna, String moduleName) The callback method that the PDI architecture would invoke when CliRobot receives a message from corresponding module and it founds that the plugin is busy processing previous jobs. OnBattleNeck(int buffer) buffer means the number of accumulated un-dispatched messages Simpler version of OnMsg( ) OnMsg(String msg) Explanation Method prototype
  28. 28. Basic steps to development plugin <ul><li>Extend RifartekRobotPlugin class </li></ul><ul><li>Overwrite Necessarily methods of RifartekRobotPlugin abstract class </li></ul><ul><ul><li>OnMsg() is the most important and should be overwritten </li></ul></ul><ul><li>Compile </li></ul><ul><li>Testing with CliRobot </li></ul><ul><li>Repeat 1 ~ 4 to enhance functionality </li></ul>
  29. 29. Basic steps to development plugin – 1. Extend RifartekRobotPlugin class
  30. 30. Basic steps to development plugin – 2. Overwrite necessary methods
  31. 31. Basic steps to development plugin – 3. Compile <ul><li>Put your class in C:RifartekcliRobot </li></ul><ul><li>Use javac to compile with wRobotApp.jar </li></ul><ul><ul><li>Ex: </li></ul></ul><ul><ul><li># javac –classpath wRobotApp.jar;. BasicPlugin.java </li></ul></ul>
  32. 32. Basic steps to development plugin – 4. Test with CliRobot <ul><li>Add “BasicPlugin” </li></ul>
  33. 33. Basic steps to development plugin – 5. Enhance functionality (1/3) Prepare a StringBuffer and TextArea to display read tags Initialize and setup UI properties
  34. 34. Basic steps to development plugin – 5. Enhance functionality (2/3) append tags into StringBuffer each time the CliRobot invokes the OnMsg method. And update TextArea to show the status
  35. 35. Basic steps to development plugin – 5. Enhance functionality (3/3)
  36. 36. Use Eclipse to development plugins <ul><li>Eclipse </li></ul><ul><ul><li>The open-source Java IDE </li></ul></ul>
  37. 37. Steps of using Eclipse <ul><li>Create One Eclipse Workspace </li></ul><ul><li>Create One java project </li></ul><ul><li>Copy CliRobot related files </li></ul><ul><li>Setup compilation parameters </li></ul><ul><li>Extends RifartekRobotPlugin and Test </li></ul><ul><li>Enhance functionality </li></ul>
  38. 38. Steps of using Eclipse – 1. Create One Eclipse Workspace <ul><li>Create one directory and </li></ul><ul><ul><li>ex: NCUTrainWorkSpace </li></ul></ul><ul><li>Switch Eclipse workspace </li></ul><ul><ul><li>File  SwitchWorkspace </li></ul></ul>
  39. 39. Steps of using Eclipse – 2. Create Java Project <ul><li>File  New  Project  Java Project </li></ul>
  40. 40. Steps of using Eclipse – 3. Copy CliRobot related files <ul><li>Related files </li></ul><ul><ul><li>Robot component: wRobotApp.jar, MessageBox.exe </li></ul></ul><ul><ul><li>image files </li></ul></ul>
  41. 41. Steps of using Eclipse – 4. Setup Compilation Parameters (1/5) <ul><li>Parameters </li></ul><ul><ul><li>include the robot jar file </li></ul></ul><ul><ul><li>Startup methods </li></ul></ul>Before setting, everything is mess
  42. 42. Steps of using Eclipse – 4. Setup Compilation Parameters (2/5) <ul><li>The jar file </li></ul><ul><ul><li>right click the project name, choose “properties” </li></ul></ul><ul><ul><li>choose the “Libraries” tab </li></ul></ul><ul><ul><li>click the “Add JARs…” and select “wRobotApp.jar” </li></ul></ul>
  43. 43. Steps of using Eclipse – 4. Setup Compilation Parameters (3/5) <ul><li>after setting, errors are gone! </li></ul>
  44. 44. Steps of using Eclipse – 4. Setup Compilation Parameters (4/5) <ul><li>Setup startup parameters </li></ul><ul><ul><li>right click the project name </li></ul></ul><ul><ul><li>click “Run As”, click “Run” </li></ul></ul><ul><ul><li>right click “Java Application”, new one </li></ul></ul><ul><ul><ul><li>The “Main” tab </li></ul></ul></ul><ul><ul><ul><ul><li>Enter “wRobotApp” as Main class </li></ul></ul></ul></ul><ul><ul><ul><li>The “Arguments” tab </li></ul></ul></ul><ul><ul><ul><ul><li>Enter “config.data 1234” in Program arguments </li></ul></ul></ul></ul>
  45. 45. Steps of using Eclipse – 4. Setup Compilation Parameters (5/5)
  46. 46. Steps of using Eclipse – 5. Test

×