The service tutorials show how to persist service state and read it again but if you are looking for a logger of messages going in and out of the service then you can configure the runtime to log messages as described in [1] which is part of the MSRS online documentation starting at [2]
Henrik
check out the SImpleDashboard sample: It uses our file log service to record data.
In particular look for the code section that starts with the line sbelow, (about line 625)
fs.FileStorePort _fileStorePort = null;
object _fspLock = new object();
void OnLogSettingHandler(OnLogSetting onLogSetting)
{
_state.Log = onLogSetting.Log;
_state.LogFile = onLogSetting.File;
Very tasty example. Thanks for the pointer. It did send me in the right direction, but I ran into a brick wall pretty quickly. I'm looking at a set file to go to everytime like so:
staticstring filename = "C:\\Microsoft Robotics Studio 1.5 (CTP May 2007)\\store\\babydoll.txt";Uri file = newUri(filename);
But when I run the code that tries to open the log I get the following error:
A file path must be child of the instance store directory Parameter name: filePath
Any pointers would be appreciated.
Hi, construct the path using our LayoutPaths static class, and that should guarantee the file is in the right place. The file store service will only let you write files to our "sandbox", which is why file shave to be under \store
try something like this:
filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "babydoll.txt";
How can I put this delicately....oh, I know......Aaaaarrrrrrghhhh! First off thanks a bunch for the help! I am up and running now. I should have known from wording of the error...
filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "babydoll.txt";
Does not work, however creating a directory "baby" in the store directory then:
filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "baby\\babydoll.txt";
works like a charm. So in the error "A file path must be child of the instance store directory " child of the instance store directory means a sub directory in the store directory. Once again, thanks for the help!
One final nit to pick. The code that I lifted from the simple dashboard uses the following snippet for initiating the write to file:
void LogObject(object data)
{
lock (_fspLock)
{
LogInfo("Writing something:" + data.ToString());
_fileStorePort.Post(new fs.WriteObject(data));
}
}
Which results in something like so being logged.....
<SonarState xmlns
="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns
="http://schemas.microsoft.com/xw/2004/10/dssp.html" xmlns="http://schemas.microsoft.com/robotics/2006/06/sonar.html">
<TimeStamp>2007-06-08T21:32:07.03125-07:00</TimeStamp>
<HardwareIdentifier>4</HardwareIdentifier>
<MaxDistance>2.5</MaxDistance>
<DistanceMeasurement>255</DistanceMeasurement>
<AngularRange>30</AngularRange>
<AngularResolution>0</AngularResolution>
<Pose>
<Position xmlns="http://schemas.microsoft.com/robotics/2006/07/physicalmodel.html">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
<Yada><Yada><Yada>
I appears that the only argument that fs.WriteObject will take is the actual message body. Is there any way to limit what get's written to file. The case in question I'm looking to log the DistanceMeasurement value and have no interest in logging the pose or any other values. As always, any help would be appreciated.