How to use more than twenty ports in a PortSet?
In Robotics Studio the operations supported by a service are also defined as ports in a CCR PortSet (Microsoft.Ccr.Core.PortSet). And the former is defined as a set of generic ports: PortSet<T0, ..., T19>.
The problem comes when you want to use more than 20 ports in the same port set, because there is no definition for PortSet<T0,...,T24> for instance.
The good news (as answered by George Chrysanthakopoulos in MSRS forum) is that there is a new variable type PortSet available in MSRS 1.5. Using it you can have as many operations as you want.
Note: In .NET Compact Framework the limitation is 8 generic type arguments for any class. However, this same approach can be applied to work arround this issue.
Follow these steps to use as many ports as you want:
1.- Instead of using the generic PortSet, use the non-generic PortSet class and pass the types of operations as a list in the constructor of PortSet:
Example:
Instead of using:
class DriveControlEvents : PortSet<OnLoad,OnClosed,...>
Use the following:
public class DriveControlEvents : PortSet { public DriveControlEvents()
: base( typeof(OnLoad), typeof(OnClosed), typeof(OnChangeJoystick), typeof(OnConnect), typeof(OnConnectMotor), typeof(OnConnectSonar), typeof(OnConnectSickLRF), typeof(OnConnectArticulatedArm), typeof(OnConnectWebCam), typeof(OnStartService), typeof(OnMove), typeof(OnRotate), typeof(OnTranslate), typeof(OnEStop), typeof(OnApplyJointParameters), typeof(OnDisconnectSonar), typeof(OnDisconnectSickLRF), typeof(OnDisconnectWebCam), typeof(OnLogSetting), typeof(OnQueryFrame), typeof(OnConnectSetting), typeof(OnOptionSettings)) {} }
2.- If your services posts to itself, replace the post messages with PostUnknownType method.
Example:
private void btnConnectSonar_Click(object sender, EventArgs e) { string SONAR = ServiceByContract(pxsonar.Contract.Identifier); if (sonar != null) { _eventsPort.PostUnknownType(new OnConnectSonar(this, sonar)); } }
3.- In the main Arbiter pattern (for instance, the Interleave where you specify the handlers for operations), replace Arbiter.Receive with ArbiterReceiveFromPortSet and Arbiter.ReceiveWithIterator with Arbiter.ReceiveWithIteratorFromPortSet for those operations defined for the non-generic PortSet.
Add as favourites (215) | Quote this article on your site | Views: 5194
Only registered users can write comments. Please login or register.
Related Items:
- Raúl Arrabales Moreno
- Lectures on Machine Consciousness - Madrid 2011
- Jobs: Two Chair positions for new Centre for Computational Neuroscience and Co
- Birmingham Fellows in Robotics and Cognitive Systems
- Finding papers about consciousness and robotics
- Paladyn. Journal of Behavioral Robotics
- International Journal of Social Robotics
- Retecog 2011 - The Architectures of Mind
- Toward a Science of Consciousness - Stockholm - Live Streaming
- Consciousness and AI. AAAI Symposium. 2007
|