BUG Community

Welcome! Log In

Forums Recent Posts

Subscribe to Recent Posts 12,449 posts found

Feb 1, 2008 5:11pm
akravets 25 posts

Topic: BUG SDK / Using Configuration Admin

Sometimes there is a need to persist state of BUG between launches, this can be achieved using OSGi's Configuration Admin (CM). There is an implementation of CM provided by com.buglabs.osgi.cm that can be obtained from CVS and is available in SDK. Also test cases are available in com.buglabs.osgi.cm.tests

Bellow is short how-to on how to use CM:

Configuration Admin HOW-TO:

Upon unregistering a bundle from the OSGi Framework all configuration data that might have been set to define its state is gone. To relieve user of pains of reconfiguring the bundle
once its active, Configuration Admin can be used to persist configuration data so that upon the bundle's being active again its states can be set to those when they were before bundle was
unregistered.


Get Configuration Admin Service:

ServiceReference serviceReference = context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin configAdmin = (ConfigurationAdmin) context.getService(serviceReference);


or use a ServiceTracker in order to know when service will be available.


Get the Configuration:
Each Configuration contains a Dictionary that holds properties for service of interest, to initiate a new store or retrieve an existing one:

Configuration config = configAdmin.getConfiguration("com.buglabs.someService");


Retrieve properties for the service:
Dictionary properties = config.getProperties();


Update service with properties:

Dictionary prop = new Hashtable();
prop.put("enabled", new Boolean(true));


Refer to section 10.4.2 of OSGi R3 specifications for valid types that can be used in Dictionary.


config.update(properties);


Configuration's properties can also be cleared by executing config.update(null); This will clear all properties for this Configuration but leave Constants.SERVICE_PID intact since it identified id for this Configuration.


Complete specifications for OSGi including CM can be downloaded from http://www2.osgi.org/Specifications/HomePage.
Feb 1, 2008 4:54pm
Medium kgilmer 215 posts

Topic: BUG SDK / Servlet: static files?

Dave,

Nice work! For dynamic images you could create a PublicWSProvider that serves up images or you could have just another servlet. I haven’t tried this but as I mentioned earlier you should also be able to provide a custom HttpContext class.

Feb 1, 2008 2:58pm
MarcC 10 posts

Topic: BUG SDK / files

I’m in the midst of making a program. I need to save app settings to the bug so that when my app is started it can reload all its user settings. Is there limitation to saving files to the bug?

Thanks

Jan 31, 2008 11:04pm
Medium finsprings 268 posts

Topic: BUG SDK / Servlet: static files?

Ken, I managed to get a static image to work, in a similar manner to your 'buck' test case. I had to make a subdir under my Resources dir in the app jar that matched the alias I registered the resource at, but other than that it wasn't too tricky.

So now it looks a little bit prettier:


I've still got to get to the dynamic image part. That's next. For now, I pushed out v1.0.5 of BUGer to bugnet with the buglogo in it as above.
Jan 31, 2008 9:54pm
Medium finsprings 268 posts

Topic: BUG SDK / Problems getting HTTP server / debugger running on FC8

Hmmm. So I got home tonight, fired up the FC8 VM again, and it all worked….perfectly….
I guess it must have been a bit mixed up the other night, but I don’t use the VM for anything else and it was only paused, not rebooted, so I don’t know why it would have fixed itself.

Ah well, sorry for bugging you guys.

Jan 31, 2008 9:42pm
Medium kschultz 107 posts

Topic: BUGmodules / Connecting modules via cable

That sounds great. I'm interested in robotics as well, its actually what I'm concentrating in at school. Have you seen the Python Robotics project? It seems to be pretty simple I haven't delved into it too deep, and I haven't tried it with the BUG, but for something quick it is interesting. For a more serious solution look at Orca/Hydro, it has a more robust design with the ICE middleware, and is largely in C++ although it can use Python and Java, and a few others.
Jan 31, 2008 9:32pm
Medium cdraptor 25 posts

Topic: BUGmodules / Connecting modules via cable

I am looking at utilizing the BUGBase on a Hexapod robotic walker. One thing I would want to do is mount the BUGBase flat to the body panels – with the camera hooked up on a servo mount so it could pan/tilt to look around – so being able to have a cable plug into the BUGBase then plug into the Camera Module would be perfect. Also in a robotic configuration you may want to also mount the motion sensor module in a similar fashion.

I already ordered the Hiro P bundle, but I will also be buying additional BUGBases when they come out with WiFi built in to utilize on a couple robotic platforms along with having one as a handheld device (used to control the robot(s)

Jan 31, 2008 8:08pm
MarcC 10 posts

Topic: BUG SDK / import problem

Thanks to all, including @sethk on irc for helping me with my issues including eclipse ones. I am up and running with xerces for now but am looking at the parser included (com.buglabs.util.XmlParser) since it will most likely do what I need it to. Also thanks to Angel for his advice and Kevin for pointing me in the right direction.

Jan 31, 2008 5:04pm
Medium finsprings 268 posts

Topic: BUG SDK / import problem

Xerces is pretty hard core and will do namespaces and everything else you could ever need. However, if you only have simple needs then, as Kevin mentions above, I’d recommend trying the XML parser that comes in the BUG libraries. It’s at com.buglabs.util.XmlParser.

I use it in the BUGerServlet class of my BUGer app if you want to see it in action.

Jan 31, 2008 4:34pm
Medium kschultz 107 posts

Topic: BUG SDK / import problem

Marc,

Try using right click to "Import to SDK" rather than left clicking and opening the page. It sounds like Eclipse started to download it but for some reason didn’t finish, the workspace error usually pops up when you try to create a project with the same name as one that is already there. I left you a message on how to contact me directly so we can look at it in real time.

Thanks,

Powered by Community Engine

Top
Login
Close
Bottom