From RTSC-Pedia
[printable version] | offline version generated on 04-Aug-2010 21:08 UTC |
ROV Module Writers Guide/Getting Started
Steps for writing your first ROV view
Getting Started
Where to begin
Start with your module's specification, Mod.xdc.
Begin by defining your view structures, which dictate what will be displayed. A good tactic here is to simply copy your actual state structures, then go through the fields and decide which you want to display. It's a good idea to begin with simple fields to convince yourself that your view is basically working.
Step 1: Define your first view structure | |
| metaonly struct BasicView { String label; Int priority; SizeT stackSize; } internal: metaonly struct Instance_State { Int priority; SizeT stackSize; } |
Once you have your view structure defined, define your module Facet configuration parameter which just specifies what views you will display and what function and structure they will reference.
Step 2: Define your ROV facet | |
| import xdc.rov.ViewInfo ... @Facet metaonly config ViewInfo.Instance rovViewInfo = ViewInfo.create({ viewMap: [ ['Basic', {type: ViewInfo.INSTANCE, viewInitFxn: 'viewInitBasic', structName: 'BasicView'}], ] }); |
Next move to your module's XS file, Mod.xs. Again, it's good to start with just the basic fields. Write your view function to simply copy values from your target state structure into your view structure. Don't bother with the more complicated fields yet that involve retrieving extra data from the target.
Step 3: Write a basic view function | |
| /* * ======== viewInitBasic ======== * Initialize the 'Basic' instance view. */ function viewInitBasic(view, obj) { view.priority = obj.priority; view.stackSize = obj.stackSize; } |
Once that's done, launch CCS and ROV and verify that you're seeing your view.
This should give you the confidence to move on and make more complex improvements to the view.
Debugging your code
As you move on to more complex ROV operations, you'll want a way to debug problems in your ROV code.
The main tool for debugging XS code is just print statements.
In CCS, these print statements will go to a special console which you must enable when you launch CCS. To do this CCS needs to be launched with the -consolelog flag. You can do this by opening a command prompt and navigating to the 'eclipse' directory of your CCS 4 installation, and launching CCS with "eclipse.exe -consolelog". Or, you can simply edit your CCS 4 shortcut and in the 'Target' field add -consolelog to the end.
When you launch CCS, you should see a separate command prompt window open behind it. This is the consolelog, and any print statements from your ROV code should appear here.