Crimson C-language program examples

These are some examples written specifically from Crimson 3.

It is worth googling "crimson 3 reference manual" it is very useful.

Simple action of printing the value of a tag out of a 232/485 port:

PortPrint (2,AsText(PAXI.distance));
PortPrint (2,",");
PortPrint (2,AsText(PAXI.speed/10.0));
PortPrint (2, "\r\n");

Program taking a raw RS232 input into a port and processing it into data tags:

cstring String;
cstring GPSHeader,NSInd,EWInd;
int Lat,LatMin,LatSec,Long,LongMin,LongSec,nos;


//initialize mydata with data string
String = PortInput(1, 0, '\r', 2000, 0); //rs232
//PortInput(PORT, START, END, TIMEOUT, LENGTH)

if(String != "")
{

//Sentence Identifier (Value &GPGGA)
GPSHeader := (Mid(GPS.rawString,1,Find(GPS.rawString,',',0)-1)); //find the value before first(1st) occurrence of ,
GPS.header := GPSHeader; // stores string header in tag GPS.header as string value

//Latitude (Value ddmm.mmmm)
Lat := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +1) +1,2),10); //find the value after second(2nd) occurrence of , in the 232 string.
GPS.Lat := Lat;// Latitude postion in decimal stored in GPS.Lat as int data
LatMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) -2,2),10); //find the value before first(1st) occurrence of . in the 232 string.
GPS.LatMin := LatMin;// Latitude postion in decimal stored in GPS.Lat as int data
LatSec := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) +1,4),10); //find the value after first(1st) occurrence of . in the 232 string.
GPS.LatSec := LatSec;// Latitude postion in decimal stored in GPS.Lat as int data

//Latitude Hemisphere (Value N or S)
NSInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +2) +1,1)); //find the value after third(3rd) occurrence of , in the 232 string.
GPS.NSInd := NSInd;// North or South value stored in GPS.NSInd as string data

//Longitude (Value dddmm.mmmm)
Long := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +3) +1,3),10); //find the value after fourth(4th) occurrence of , in the 232 string.
GPS.Long := Long;//Longitude position in decimal stored in GPS.Long as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) +1,5),10); //find the value after second(2nd) occurrence of . in the 232 string.
GPS.LongSec := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) -2,2),10); //find the value before second(2nd) occurrence of . in the 232 string.
GPS.LongMin := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data

//Longitude Hemisphere (Value E or W)
EWInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +4) +1,1)); //find the value after fifth(5th) occurrence of , in the 232 string.
GPS.EWInd := EWInd;// East or West value stored in GPS.EW Ind as string data

//Number of Satellites (Value 0-12)
nos := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', 0) +1,2),10); //find the value after sixth(6th) occurrence of , in the 232 string.
GPS.nos := nos;// Number of satellites being used stored in GPS.nos as int data

GPS.rawString := String; //Contains raw string data from GPS

// Activates flag tags for GPS Hemisphere indicators
if (GPS.NSInd == "N")
(GPS.NSInd_Bool := 1);

if (GPS.NSInd == "S")
(GPS.NSInd_Bool := 0);

if (GPS.EWInd == "E")
(GPS.EWInd_Bool := 1);

if (GPS.EWInd == "W")
(GPS.EWInd_Bool := 0);

}
 
Last edited:
Ya'll might want to be aware that you can wrap code tags around your program code to preserve the formatting...

Code:
#include <stdio.h>

int main (void)
   {
      printf("Hello World");
      exit(0);
   )
 

Similar Topics

Hey guys, hoping someone here could give me a little advice. I'm working with a CR1000-04000 in Crimson 3.1 and I was interested in adding the...
Replies
4
Views
143
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
5
Views
275
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
120
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
103
Has anyone setup communications with Red Lion 3.0 MODBUS to Baker Hughes Centrilift GCS VFD? Thanks
Replies
0
Views
94
Back
Top Bottom