Red Lion HMI code help needed.

This is a discussion on Red Lion HMI code help needed. within the C Programming forums, part of the General Programming Boards category; I am posting to this board first time with a request for some help with an industrial HMI (touchscreen) that ...

  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    4

    Red Lion HMI code help needed.

    I am posting to this board first time with a request for some help with an industrial HMI (touchscreen) that interfaces with a programmable computer. My specific request is for someone to help me with retrieving values that are stored to a CompactFlash card. I am able to store values (we call them recipes) to the CompactFlash card as .csv file. I just haven't been able to figure out the code to retrieve this information back to the touchscreen.


    Let me first post my code that stores the recipes; (it works as intended)

    Code:
    // Create a new folder if it doesn't exist
    
    CreateDirectory("/recipes");
    
    //Create the file if it doesn't exist
    
    CreateFile("/recipes/recipe.csv");
    
    
    //open the file
    
    hfile = OpenFile("/recipes/recipe.csv", 2);
    
    
    //Write each recipe as a line in the file
    
    //Copy each array index as a file line beginning by therecipe index
    
    for (i = 0; i < 100; i++) {
    
      WriteFileLine(hfile, AsText(i) + ","
                    + OutsideDiameter[i].AsText + ";"
                    + RecipeOD[i].AsText + ";"
                    + WallThickness[i].AsText + ";"
                    + RecipeWall[i].AsText + ";"
                    + GapRoll1[i].AsText + ";"
                    + GapRoll3[i].AsText + ";"
                    + GapRoll5[i].AsText + ";"
                    + GapRoll7[i].AsText + ";"
                    + GapRoll9[i].AsText + ";"
                    + AngleRoll1[i].AsText + ";"
                    + AngleRoll3[i].AsText + ";"
                    + AngleRoll5[i].AsText + ";"
                    + AngleRoll7[i].AsText + ";"
                    + AngleRoll9[i].AsText + ";"
                    + AngleRoll2[i].AsText + ";"
                    + AngleRoll4[i].AsText + ";"
                    + AngleRoll6[i].AsText + ";"
                    + AngleRoll8[i].AsText + ";"
                    + AngleRoll10[i].AsText + ";"
                    + DeflectRoll4[i].AsText + ";"
                    + DeflectRoll6[i].AsText + ";" + DeflectRoll8[i].AsText);
    
    }
    
    //Close the file
    
    CloseFile(hfile);
    Now with that said, I would like to retrieve these values from the .csv file.

    I am a newbie to c programming so please bear with me as I try to process any help rendered to me.

    Thanks in advance,

    Jfls45
    Last edited by Salem; 09-19-2013 at 11:39 AM. Reason: removed all the useless font/size tags - code is now readable

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    What language and OS is this?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Sep 2013
    Posts
    4
    C (I posted this in a C forum) The code is used in a software program that is downloaded into the touchscreen. Not sure what the actual OS is. The programming software has it's own built in compiler, etc.


    Quote Originally Posted by oogabooga View Post
    What language and OS is this?

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    I hate to disagree with you but that's not C.
    It looks more like Java or Javascript.

    You can't concatenate strings in C with +.

    EDIT: Actually, I suppose it could be C++ (or could it? ).
    You'd have to post more of the code for me to be sure what it is.
    Last edited by oogabooga; 09-19-2013 at 03:22 PM.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,641
    When dealing with specialized hardware, your first choice for help should always be the manufacturer's website. In this case that manufacturer is Red Lion. Once there, you should look under Support, where you'll find some proprietary language called Crimson, which is what this appears to be. While it's C-like, it's definitely not C.

  6. #6
    Registered User
    Join Date
    Sep 2013
    Posts
    4
    Unfortunately the Red Lion support isn't that helpful. They have various samples of code posted which when downloaded into their touchscreen doesn't execute. I think it is sample code submitted by end-users.

    As for this being Javascript, it is not, although some of the syntax appears to be. I have asked the technicians at Red Lion to give me a specific answer to what is this code and they only respond with C programming.

    The following code was sent to me by an engineer as an example of how he retrieves data from a CompactFlash card.

    Code:
    // This program reads data from a file on the CF card and stores
    // it in the appropriate arrays on the G3.
    
    cstring fname, linetxt;
    int i, ofile, fabnum, delim1, delim2;
    
    fname := "/" + filename + ".csv";    // Generate filename.
    ofile := OpenFile(fname,0);       // Open the file.
    
    // Clear all recipe arrays before importing.
    Fill(recipe_PileHeight[0],0,1000);
    for(i:=0; i<1000; i++) recipe_Description[i] := "";
    Fill(recipe_BuffActive[0],false,1000);
    Fill(recipe_CardActive[0],false,1000);
    Fill(recipe_BevelActive[0],false,1000);
    Fill(recipe_TrimActive[0],false,1000);
    Fill(recipe_BufferSpeed[0],0,1000);
    Fill(recipe_CardingSpeed[0],0,1000);
    Fill(recipe_FBUFF_ExtPos[0],0,1000);
    Fill(recipe_RBUFF_ExtPos[0],0,1000);
    Fill(recipe_FCARD_ExtPos[0],0,1000);
    Fill(recipe_RCARD_ExtPos[0],0,1000);
    Fill(recipe_FTRIM_ExtPos[0],0,1000);
    Fill(recipe_RTRIM_ExtPos[0],0,1000);
    Fill(recipe_BuffDwell[0],0,1000);
    Fill(recipe_CardDwell[0],0,1000);
    
    linetxt := ReadFileLine(ofile);       // Read first line of file (headers).
    linetxt := ReadFileLine(ofile);       // Read second line of file (first line of data).
    
    while(linetxt != "")   // Loop until all lines are read
    {
        delim2 := Find(linetxt,',',0);
        fabnum :=TextToInt(Mid(linetxt,0,delim2),10);   // Get fabric number from first item
    
        delim1 := delim2;
        delim2 := Find(linetxt,',',1);
        recipe_PileHeight[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 := Find(linetxt,',',2);
        recipe_Description[fabnum] :=Mid(linetxt,delim1+1,delim2-delim1-1);
    
        delim1 := delim2;
        recipe_BuffActive[fabnum] :=TextToInt(Mid(linetxt,delim1+1,1),10);
        recipe_CardActive[fabnum] :=TextToInt(Mid(linetxt,delim1+3,1),10);
        recipe_BevelActive[fabnum] :=TextToInt(Mid(linetxt,delim1+5,1),10);
        recipe_TrimActive[fabnum] :=TextToInt(Mid(linetxt,delim1+7,1),10);
    
        delim1 := delim1 + 8;
        delim2 := Find(linetxt,',',7);
        recipe_BufferSpeed[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 := Find(linetxt,',',8);
        recipe_CardingSpeed[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 := Find(linetxt,',',9);
        recipe_FBUFF_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',10);
        recipe_RBUFF_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',11);
        recipe_FCARD_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',12);
        recipe_RCARD_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',13);
        recipe_FTRIM_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',14);
        recipe_RTRIM_ExtPos[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        delim2 :=Find(linetxt,',',15);
        recipe_BuffDwell[fabnum] :=TextToInt(Mid(linetxt,delim1+1,delim2-delim1-1),10);
    
        delim1 := delim2;
        recipe_CardDwell[fabnum] :=TextToInt(Mid(linetxt,delim1+1,Len(linetxt)-delim1-1),10);
    
        linetxt :=ReadFileLine(ofile);        // Read nextline of file.
    }
    
    CloseFile(ofile);    // Close the file.

    I'm interested to see if you figure out if it is C++ or some proprietary type code?

  7. #7
    Registered User
    Join Date
    Sep 2013
    Posts
    4
    From Red Lions Software Help file:


    PROGRAMMING TIPS
    The sections below provide an overview of the programming constructions supported by Crimson. The basic syntax used is that of the C programming language. Note that the aim is not to try to teach you to become a programmer, or to master the subtleties of the C language. Such topics are beyond the scope of this manual. Rather, the aim is to provide a quick overview of the facilities available, so that the interested user might experiment further.

    MULTIPLE ACTIONS
    The simplest type of program comprises a list of actions, with each action taking up a single line, and being followed by a semicolon. All of the various actions defined in the Writing Actions section are available for use. Simple programs like this are typically used where combining the actions in a single action definition would otherwise prove unreadable.
    The sample shown below sets several variables, and then changes the display page…
    Motor1 = 0; Motor2 = 1; Motor3 = 0;
    GotoPage(Page1);
    The actions will be executed in order, and the program will then return to the caller.

    IF STATEMENTS
    This type of statement is used within a program to make a decision. The construct consists of an
    if statement with a condition in parentheses, followed by an action (or actions) to be executed if the condition is true. If more than one action is specified, each should be placed on a separate line, and curly-brackets should be used to group the statements together. An optional else clause can be used to provide for code to be run if the condition is false.
    The example below shows an
    if statement with a single action…
    if( TankFull ) StartPump = 1;
    The example below shows an
    if statement with two actions

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Definitely not C, but you have the output code that created the data file, so now you need to discover the input code that is the input match of it, line by line. The language doesn't appear especially difficult. Looks (rather) easy to learn, actually.

    The manufacturer should provide you with a manual (perhaps a file you download), to at least explain what the keywords are for the language, and a tutorial with some WORKING examples.

    Be sure and Google for the manufacturers name and HMI and the language name once you discover it (is it Crimsom?). You might get lucky.

    You could use a little, right now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with code needed
    By ToweyLeake in forum C++ Programming
    Replies: 3
    Last Post: 09-27-2011, 06:54 PM
  2. Code help needed
    By balhazar in forum C Programming
    Replies: 1
    Last Post: 12-01-2010, 05:54 PM
  3. Code Help needed.
    By krimzon in forum C++ Programming
    Replies: 5
    Last Post: 02-15-2005, 02:21 PM
  4. Code needed
    By PanzTec in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2004, 06:42 AM
  5. Help Needed W/ Code..please!!
    By aspand in forum C Programming
    Replies: 3
    Last Post: 05-28-2002, 02:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21