Saturday, January 31, 2009

Article posted on code project (Microsoft Robotics)

My article about Microsoft Robotics .net is posted on CodeProject site. You can access the article from the following link:

Click: Article on Code Project

Wednesday, January 28, 2009

ClickOnce (One application overwriting other)

Have you ever been faced a problem when one ClickOnce deployment is causing a different deployment to be overwritten? I have...

Let me explain the problem to you. We have two versions of our application. We develop and then move to TEST. In this evironment we run all the possible scenarios just to make sure everything is working. All the stakeholders are generally involved in this step.

But releasing the controller in this environment overwrote the PRODUCTION version of my application. Then an interesting thing I found. "ClickOnce identifies deployment based on Certificate and Assembly Name". So if you have same certificate and assembly name for two applications, releasing one will overwrite other.

Just use different certificate for both versions and it should work. It worked for me atleast :)

Monday, January 26, 2009

Microsoft Robotics

Robotics has always been considered as a field of research. It is supposed to be the field of universities and industries. Mainstream programming world is generally unaware of the advancements in this particular field. But this understanding should not be any more in the minds of the general public. This is because Microsoft has jumped into this field. This jump has been taken by Microsoft a few years back. As is the history of Microsoft, this field would now get the attention of general public and developers. People would take advantages of many robotics features they may use in their applications in different other fields like financial etc.

Microsoft’s release of Robotics Studio and its associated libraries requires several pages discussion each. But I thought there should be an introduction of all them in a single place which help a starter to identify each of the pieces so that they could efficiently use them as per their needs and are not lost in an individual piece of the overall system.


Primary Areas:
The Robotics release by Microsoft mainly consists of three main parts. Among these, CCR and DSS can also be used by applications outside the Robotics world.

1. Runtime: This supports from 8-bit to 32-bit robots. These robots may range from Toy Robots to Industrial Robots.

2. CCR: This is the Concurrency library. This is the base of Robotics architecture by Microsoft. You can even use this component for the applications running on a PC instead of a robot. CCR is available in the form of a dynamic link library which may be used by any .net language.

3. DSS: This is the services architecture. This is a companion to CCR. This is based on Service Oriented Architecture. This provides the ability to write applications which are highly distributed and modular. This means you can execute your code in the processing work horses and use anywhere in the distributed environment.

CCR (Concurrency & Coordination Runtime)
This is separate release by Microsoft and is not part of Robotics studio. These are basically designed for keeping robotics community in mind. But seeing its usefulness outside of robotics world this has been made a separate release.
CCR is a port based class library to develop asynchronous applications. It is designed to develop asynchronous, concurrent applications which could coordinate. This also handles failure handling issues for these operations.
With the use of CCR, we don’t need to do any manual threads management. This can be especially useful in handling concurrency and partial failure. CCR has a failure handling mechanism called Causalities. This is basically a generalization of Try / Catch for multiple threads. But this is for many machines and processes working in synchronous fashion. It also deals with join.

DSS (Decentralized Software Services)
This is a REST based model. This is services model which is state oriented. Making it REST based has made the services and applications to be independent of each other. They may be on the same machine or distributed across different machines connected through any means. When we say REST based, you should understand that the resources should be available by query strings. These services are available as resources to the other services, applications or User Interfaces. This is actually how Microsoft is able to promise low coupling between services.
This makes it possible to develop distributed applications. These applications may also run on the same machines.

DSSP:
DSSP is the protocol used for inter-services communication. This is a SOAP based protocol. LINQ queries are support in DSSP subscriptions which allows running queries on data sources and no movement of data is required to run these queries.

DSS Log Analyzer:
This is used to analyze the communication of messages between different DSS services existing in the same physical node or across different physical nodes.
Note: In the July 2008 CTP, core DSS and CCR assemblies are copied to Global Assembly Cache (GAC).

DSSME (DSS Manifest Editor):
DSSME is DSS Manifest Editor. As its name implies it is to wire-up different services on same machine or on different machines. We can also specify the initial state of the services and where they should run. These services may be developed using VPL (Visual Programming Language) or directly in Visual Studio.



Microsoft VPL (Visual Programming Language)
VPL is Visual Programming Language by Microsoft. This is to provide easy solution to develop CCR and DSS based applications. It must be remembered that this seems to follow Observer Pattern. This does not based on Control flow but on data flow which enables some program elements to get executed when some data arrives. So VPL is giving model driven approach to develop and orchestrate services.
There seems to be some overlap between VPL and DSSME as far as the orchestration of services is concerned. BUT DSSME seems to be promising much more than VPL seems to provide for services orchestration. This makes it possible to develop applications by simple drag and drop.



You can see that there are different Activities and Services, you can select from. You can define your flow of data based on those services and activities by connecting as per your needs.

Microsoft Visual Simulation Environment
There are three ways to test your ideas. They are Mathematical Models, Simulation and Experimentation. Everyone cannot create Mathematical Models. For experimentation, we need robots, which are expensive. Everybody cannot afford them to test their ideas. Microsoft has identified this potential issue for the adoption of its technologies by the community. So it has provided a simulation environment. This environment has helped us to simulate our application. If the desired results are achieved through simulation then we can move to experimentation.

These simulations can also be recorded and played back in the same environment. These recording are saved in the form of XML files. The simulation media resources such as texture maps, bitmaps and mesh files can be stored as embedded resources as part of the assembly instead of external files.

The rendering engine is developed on Microsoft XNA Framework. The engine is based on AGEIA™ PhysX™ Technologies. There are different renderings available in the environment. They are as follows:

1. Visual
2. Wireframe
3. Combined
4. Physics
5. Floor Plan



There are different simulation environments available in July CTP. The one presented above is the Basic Simulation Environment.

What’s in the Installation Box of Robotics Studio?
When you install July CTP or Robotics Developer 2008, it comes up with the following:

1. Microsoft XNA Framework 2.0
2. AGEIA PhysX System Software
3. Microsoft Visual C++ 2008 Redistributable Package
4. Microsoft CCR and DSS Runtime Redistributable

All the required components are installed with the July CTP installed. They also include VPL, CCR & DSS and Simulation Environment. This also includes necessary Project Templates to develop DSS Services in C# and VB.net. Robotics Common includes Generic contract used by Microsoft Robotics Developer Studio samples. The samples include Generic Differential Drive and Generic Contact Sensors.



Different programming languages are supported with the Robotics Studio. They include C# / VB or any of the .net languages including Microsoft Iron Python. You would be amazed to know that you can even write code in Jscript. This means not only you can do the measurement of your robots but you could also control them right from your browser from anywhere in the world through Internet.

As you know that non-managed code may be used by managed code if we create a managed proxy of non-managed code. So you can use all your C++ code for performance reasons and after creating a managed proxy you can use them by the studio.

Overlapping between CCR & DSS AND Parallel Extensions .net
As you go along you may find some overlapping between the features provided by Parallel Extensions .net and CCR & DSS. Remember that when they were designed, Microsoft had different visions for both the technologies. But now they will be made part of .net framework. At that time Microsoft will look at the overlapping between the two and would address this issue. Till then for non-robotics applications, we should bear with this.

Robotics in the ecologic world of Application Development:
1. Robotics with Speech API:
When you would start working with your robots, which could interact with real world. The first requirement which you could have is that these robots could speak to the persons they are working for. So you can take advantage of the speech API of Microsoft or any other third party.

2. Robotics and Game Programming:
If you look at the games they are exactly the visualizations of robots which can move and have different senses (behave like). There are different objects on the screen which may work concurrently. Objects actions depend on their position. The more you thing the more you find the analogy between these two fields. But how come they have been designed differently by different sets of people with different background. If we just two different sets of engineers together and make them work together. This would be the point which could serve as the launching pad of this field. From this point, industrial applications and their simulations would work together. So I think, in future, Robotics could go hand in hand in Microsoft world which could inspire independent consortiums to develop standards for these fields.

So the game programming will also be greatly influenced by the Robotics programming.

Software Development Kit:
Microsoft Robotics SDK

Robotics Resources on Internet:
There are different resources available on internet which might help in getting understanding about Microsoft involvement in this novel field. Some of the resources are as follows:

• http://msdn.microsoft.com/en-us/library/bb881626.aspx
• http://channel9.msdn.com/Wiki/CcrPatterns/
• http://en.wikipedia.org/wiki/Microsoft_Robotics_Studio
• http://blogs.msdn.com/MSRoboticsStudio/

Books:
Professional Microsoft Robotics Developer Studio (Johns, Kyle)

Saturday, January 10, 2009

Enabling CLR Integration

To enable CLR on your SQL Server, first you would have to setup server level configuration. For that 'CLR ENABLED' has to be set on the server.

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO


Trust Worthy Computing
To deploy CLR stored procedures, trustworthy computing has to be enabled for the database in which you want to host your CLR code. To enable CLR, ALTER DATABASE statement is used:

ALTER DATABASE MYDB SET TRUSTWORTHY ON

Friday, January 9, 2009

Killing SQL Server Process with X Lock on a table

Ever troubled with an X Lock on you table which you desperately want to remove?

I was hit with this problem today. You can do the following in order to remove the lock from your table:

First we find out how many locks are on your table.

SELECT REQUEST_MODE, REQUEST_TYPE, REQUEST_SESSION_ID FROM
sys.dm_tran_locks
WHERE RESOURCE_TYPE = 'OBJECT'
AND RESOURCE_ASSOCIATED_ENTITY_ID =(SELECT OBJECT_iD('TBL_PROD_TQ'))


In the above example, the details of locks on the table “MyTable” are queried. Along with the Lock type, the session responsible for the lock is also displayed.

Now if you find there is an ‘X’ lock on your table. Then using the session ID found as a result of the above query, session can be killed. We assume that our session id is 140.

KILL SESSION_ID (e.g. KILL 140)

If you want to get further details about your session, dm_exec_sessions can be used. To get the details of the session:

SELECT * FROM
sys.dm_exec_sessions
where session_id = 114


To get the IP Address of the party involved in the session, we can use dynamic management view dm_exec_connections:

SELECT * FROM
sys.dm_exec_connections
WHERE SESSION_ID = 114