Interfacing with CC3 via ‘Intercom’

In the last post, I introduced Intercom with an old example I wrote using VB6.  This post will be a much more modern example using C#.
I’ve also included a “Round Trip” example where the command is initiated via CC3.  By adding this small macro, you now have a command that draws a diamond on the screen.

Code Snippet
  1. MACRO DIAMOND
  2. GP TEMP ^DCenter:
  3. SENDM 2 TEMP
  4. ENDM

What this does is as the user to get a point (GP) and then send it via Intercom to the c# application.
Once it gets to the c# code, it takes the string from CC3 (all data sent from CC3 via Intercom is in strings), splits it on the comma and converts the two substrings into doubles.  Then it creates a command string and passes it back to CC3.

Code Snippet
  1. var strNumbers = System.Text.Encoding.ASCII.GetString(bytMsg).Split(‘,’);
  2. var x = double.Parse(strNumbers[0]);
  3. var y = double.Parse(strNumbers[1]);
  4. var strDiamond = “LINE \n” +
  5.                     (x – 100) + “,” + y + ” \n” +
  6.                     x + “,” + (y – 100) + ” \n” +
  7.                     (x + 100) + “,” + y + ” \n” +
  8.                     x + “,” + (y + 100) + ” \n” +
  9.                     (x – 100) + “,” + y + ” \n\n” +
  10.                     “ENDM”;
  11. icSendMsg(20, strDiamond);

Here is a link to the C# portion

Comments are closed.