Using a system trained in Synapse
One commonly asked question is how to best use a trained system with new data. There are three basic approaches:
- Using the probe post-processing component .
- Deploying the system (covered in detail by tutorial #2)
- Loading the new data into Synapse
-
As the first two ways are covered by existing tutorials, this post will cover 3) - how you load and and use new data within a solution in Synapse.
Consuming deployed Synapse components from C++
Sometimes you wish to use a deployed Synapse component from software not written in a .NET language. If the software is written in C++ or can make use of native DLLs you can still make use of deployed Synapse components either directly from C++ or by creating a C++ wrapper that exports key functionality.
This post shows how this can be done by writing a simple application in C++ that uses the deployed component from the famous police tutorial. For the steps described in this post we will not need Synapse but will use Microsoft Visual Studio 2010 (Make sure it is the C++ version if you use the express edition).
In order to manage our .NET object in the unmanaged world we will make a class called Client that will handle instantiation and destruction of an instance of the .NET object (in our this case Peltarion.Deployed.GodCopBadCop). In this class we can also implement any access methods to provide communication with the managed object.
We will then use this Client class to instantiate an instance of the deployed Synapse component and evaluate a test sample from the police data file.
Fist off start Visual Studio and create a new C++ project. For this exercise we will use a Win32 Console Application. I'm calling this project NativeSyn. (Check empty project in the second page before you click finish.)
I have copied the Synapse deployment directory GodCopBadCop to the project folder for easy access. To use it though we must add a reference to it. In the Solution Explorer select the NativeSyn project and hit Alt+Enter to bring up the properties window.
Turn on Common Language Runtime Support under configuration properties
Then add a reference to the dll containing the deploys Synapse system. For us that will be GodCopBadCop.dll.
(If you just want the project and source files to play with on your own you can find them at the end of the post)
Now let's add a header file called Client.h and start crafting our Client class. We will need a private void *ref to keep track of the managed .NET object. (We can't point to it directly since it's in managed space but we will get to that.) We will also need an alloc and a free method that will be called from the constructor and destructor respectively. Finally we will need a test method to facilitate the testing of Dutch policemen.

For the actual implementation add a source file called Client.cpp.
Include windows.h , Client.h and in order to comunicate with the managed world, vcclr.h. We will also be using namespaces System and System::Runtime::InteropServices.
Next is the implementation of the constructor and destructor. This is particularly easy as all they have to do is call alloc() and free(). We will however add a #pragma unmanaged prior to their implementation.
The rest of the code will be devoted to dealing with managed interop so #pragma managed this time. To run anything .NET related we need a using directive to mscorlib.dll and we will need another to GodCopBadCop.dll.
The type we go through all this trouble for is Peltarion.Deployed.GodCopBadCop in C++ that becomes Peltarion::Deployed::GoodCopBadCop. Since it is quite long to type let's make a typedef.
alloc(), now the interesting things start. Our .NET type is managed and subject to the CLS garbage collector. If we just instantiate an instance of it and there is no managed pointer to it we can be pretty certain the GC will destroy and collect it so will need to notify the GC we want that object to stay alive. This is done through the concept of internal pointers and GCHandles. I will not go in to details here but the process is to use gcnew to create an object instance and then register it with a GCHandle and finally store a pointer to the GCHandle.
Now, every time we need to use the object we need to go through the GCHandle to find it. When we want to tell the GC we are done with the object, and that it can be safely collected, we need get our GCHandle and call free on it.
The implementation of alloc() and free() looks like this:
The test method also need to access the object so we need to use the Target property of the GCHandle to get an internal pointer to it. After that you can use it access all the methods of the .NET object. We will primarily be interested in the Set_CSV and the StepEpoch methods along with the properties exposing the system output (on this system the output function layer is called FunctionLayer4 so we will access the FunctionLayer4_Port0 property).
Using the Client in an application is strait forward. We add a main.cpp source file to our project, include Client.h and we are god to go. (If you want you can turn off Common Language Runtime Support for the main.cpp file and all other files that don't do explicit interop stuff.)
Now, the moment of truth! Ctrl+F5

This was a small example to get you going. You might want to mimic some of the deployed Synapse components API or if this was a wrapper class to cater for some other interop you would probably export methods for creation, destruction and access methods that suite that particular platform.
The Visual Studio solution that was created for this post can be downloaded here and Microsoft has published a video tutorial covering this same issue over at http://msdn.microsoft.com/en-us/visualc/Video/bb892742
Synapse 1.5 released
Synapse 1.5 has been released and is available for download.
Main highlights:
- Full multicore support for optimizers.
- A new Fully Forward Connected Perceptron Array (FFCPA) advanced neural network block.
- New non-linear gradient optimization algorithms.
- Improved SQL interoperability and data loading performance improvement.
- Control system customization (for deployment)
- Many performance improvements and bug fixes.
-
If you have Synapse installed and automatic updates enabled, you'll get the 1.5 version just by starting up Synapse - for Windows 7 & Server 2008 installations, read note below. Customers can download the full installation package from the customer area. A 30-day evaluation version can be downloaded here.
Very important upgrade information
-
Due to recent changes to the way Windows handles file and directory permissions, if you have User Account Control (UAC) activated the Synapse automatic updates will fail. This is because it no longer has permissions to write to its own plugin directory. In order for the upgrade to work you need to right click on the Synapse icon and select "Run as administrator".
You will only need to do this once as the 1.5 version is compatible with the newer Windows permission policy.
Synapse 1.3.1 updates
We have released Synapse 1.3.1 which contains a number of improvements.
The most visible change is to the Sensitivity Analyzer postprocessor which now has a new interface and functions for compensating for internal correlation between features.
There are two major groups of fixes that have been made. One concerns how validation sets are handled by control systems and filters. Only having one or more validation sets could cause inconsistent behaviour in some filters and that has been fixed.
The second group concerns data loading with major improvements in the SQL format and the CSV file format. In both cases threaded data loading speeds have been vastly improved. Also support for accessing a Synapse solution offline (i.e. when the data file/database connection is can't be accessed) has been added. The data unit input manager has been improved as well to better support threaded loading and offline mode.
Finally, on an unrelated topic, the Peltarion website now fully supports the Google Chrome browser.
--The Peltarion Team
Server upgrades

We are currently in the process of upgrading our server hardware, software as well as launching a new version of the home page and a new version of Synapse. This will cause interruptions in our service for the next 24-48 hours. We apologize for the inconvenience but we are sure you will like the improvements.
The new documentation system (http://www.peltarion.com/doc) is online and you can reach it if your ISP's DNS entries have been updated (if not, they will within the next 24 hours). The forums (http://www.peltarion.com/forums) will remain offline for a short while until the upgrades have settled.
A new version of Synapse that features massive improvements will be released tomorrow as both download and automatic update. More on that tomorrow.
We apologize for any inconveniences during this upgrade and hope you will enjoy the new site and the new Synapse 1.3.
--The Peltarion Team
Deployed systems on Mono?

First, sorry for the lack of updates on the blog. We've been very busy working on a very large update package for Synapse as well as a new documentation system. We are also migrating to new servers, which does take some time. The good news is that we are seeing the light at the end of the tunnel and hope to have everything finished soon and ready for release. You'll be happy with the new documentation system that is a vast improvement over the existing stuff and it also features a community forum which I'm sure is good news as many have requested it.
Now to the point of this post which is a question that we get relatively often. The question is do systems deployed from Synapse work on mono? (Mono is a .NET framework clone that runs on Linux, Solaris, Mac OS X and a few other platforms.)
The short answer is: No.
The long answer is: Not yet.
The primary problem is a bug in Mono that causes it not to recognize .NET Compact assemblies. Base level components in Synapse are all Compact compatible (so you can use a deployed system on a PocketPC or any Windows Mobile phone and a range of other devices).
We will look into the mono problem and try to come up with a solution. Until then, if you are using Linux (or FreeBSD or OS X etc), you can always use the WINE emulator to run systems. In that case you can probably use Synapse as well. It is of course completely unsupported on our part, but it may be worth a try.
The Synapse Spiral
Consuming deployed components as Synapse plugins

We have received questions on how to load a deployed component into Synapse as a plugin and use it as a building block for new systems. This was something that was intended from early on, but was cut from the release and until now we have had few questions on the subject.
This post will almost be in the form of a tutorial and it will explain the interfaces needed to produce a plugin and to allow for standard signal flow. First we will create a minimal plugin, then fill it with a deployed component and lastly add some bells and whistles.










