Thread: advice for gui front end

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    15

    advice for gui front end

    I appreciate any advice. I have been programming HMI's and PLC's for a while. I was about to switch to c-programming for portability when I started researching and have not found many gui builders. I design and program many different control systems and have done fine with plc's and hmi's for a while. My last program turned out extremely nice and I ran into a very substantial lag due to maxing out the plc (I had to mulitplex quite a few of my control functions just to fit within code size limitations). I am not trying to discuss other plc's and have fully decided to make the switch to c-programming for a few reasons that I will list in case I am incorrect in my thinking:

    -portability (I would think that I can use the c-application on everything from a RTOS to windows 7 or OSX so I can write the program once and use for embedded micro-processors or a desktop on a plant floor)

    -no hardware limitations (if I am using a panel pc and running an application that is taking the hardware to the limit and notice considerable lags, which happened in the above situation, I can just move to a panel pc with faster processor or more memory ect)

    -If/when I decide to switch to microprocessors and develop my own boards I will know c so can use any of the standard compilers for the embedded processor manufacture of my choice

    Now for the issue currently at hand. Assuming that my above thinking is correct, I want to start learning c. I catch on to languages very quickly and feel extremely confident that I can learn c quickly and start designing so systems within a few weeks (always had a strong aptitude for languages). My biggest hang-up is the gui programming. I am not interested at all in hand coding a gui and need a wysiwyg builder. What I have been looking for since their does not seem to be an all in one c gui builder out there that I can use c for everything is to create the brains of the application in c and figure out what gui builder/language I can use to connect to my main c-application. This seems to be a pretty clean scenario for me as I am used to similar architecture with the HMI and plc (HMI is the U.I. for the plc application) and would allow me to change my U.I. without changing my main application. Does anyone have any suggestions for a gui builder that I can connect with a c-application. I need something that will have examples and/or tutorials to catch on to as this is all pretty new to me. Thanks for any advice

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    GUI... for which operating system?

    You will find the windowing techniques of each OS have so little in common one might conclude they come from different planets. If you are talking about Windows, then you can google "Rapid Application Design" and find all kinds of stuff.

    However; you should know that RAD tools are the number one cause of "bloatware" that now polutes everything we do. The underlying obfuscations needed to make it "easy" also take up tons of space.

    So my advice to you would be to settle on an OS and learn it's native windowing techniques... They may seem like a needlessly low level approach, but if your systems are maxing out, you may have little or no choice.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    15

    Thanks for the reply

    I appreciate the reply. I am used to programming without an OS (common in industrial environments with dedicated processors to specific tasks) so I am sorry if my question was not stated properly. Basically, where I stand I guess is not typical "programmer" in that I am controlling dedicated machines with tasks. I am only interested in moving towards hardware running an OS because the hardware that is economically feasible for my applications all run some sort of OS (linux embedded, windows ce, windows xpe, windows desktop, linux desktop). I have a lot on my plate usually from hardware design to the software design including the user interface layout design ect. I really am looking for an easy transition from my dedicated softwares that I use now that limits my hardware choices to a more portable universal language like c. That being said I don't want to have to (or better stated not have time for) deal with the gui any more than a drag and drop input and output to/from my c-application. So before I get neck deep in learning C I have to figure out what avenue I am going to take for my gui to make sure it will be compatible with my C-application. Really the way I would like to design these systems is with 2 different applications:

    1st- the main c-application that is doing all of the logic and control
    2nd- the user interface portion that just passes info back and forth to my c-application

    I am used to this technique now because I currently do the same thing with 2 different components (1 processor to handle the control/logic and 2nd processor to handle the GUI)

    If my thinking is way off I would appreciate any suggestions ect
    Thanks in advance

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    29
    I read what your asking for. And it isn't that simple for C. For OSX, cocoa programming is much different than standard C. They have their own built in interface builder.

    Windows has WinGUI programming, which C takes advantage of. But that is very much different than cocoa c. Which cocoa c is the only programming for macs I know to exist when it comes to good running programs.

    Linux, I'm sure has compatibility to run some PC software from C based applications, but to run from a MAC is probably different. Your asking for it to be simplified for you, it just isn't the case. Standard C is universal, regardless of system. It'll compile to do (nearly) the exact same thing. You'll come across minor tweeks. (Or I have). But when it comes to the interface, hire someone if you don't want to do it. No other way (and if there is, it won't be simple to use.)

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Trinity32244 View Post
    1st- the main c-application that is doing all of the logic and control
    2nd- the user interface portion that just passes info back and forth to my c-application

    I am used to this technique now because I currently do the same thing with 2 different components (1 processor to handle the control/logic and 2nd processor to handle the GUI)
    Can you, by chance post a screen shot of a UI something like you have in mind?

    C Is not a difficult language to learn the basics in, but it somehow manages to just keep on coming where the details and capabilities are concerned. It's very minimal, primitive almost, and therein lies it's power.

    IF you can live with text based gui... C just might do the whole job and in a LOT less code than you've been used to.

    A second thought is that if you are using 2 machines (i.e. disconnected) why not run Win XPe in one for your gui and let the other do the grunt work. Network them and you can even implement long range remote control...

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    A free drag-and-drop editor that can produce cross-platform GUI apps in C doesn't exist to the best of my knowledge.

    Making your GUI compatible with your controller should be relatively easy. I built something like this many years ago. I wrote a crude command line interface that allowed setting parameters and polling data. I could talk to this myself over telnet, and I wrote an app with a nice GUI that showed a diagram of the system with all the valve states, temp sensors, etc. It spoke the same command-line language, polling the data periodically and updating the display. You could do something a little more modern (and quicker), using network sockets instead of the serial modem I had.

    Since you want your two-layer system, I would use C for the controller, and maybe something a little more platform independent for the GUI/front end. Java and the Swing API are much better at cross platform stuff. I'm sure you can find an IDE that allows drag-and-drop GUI building for Java (Eclipse, NetBeans). Anything that runs Java can run your app with little or no effort. You can also look at using a web-based front end for your systems. That would even allow monitoring from a web-capable phone. I'm sure you can find WYSIWYG editors for web front ends as well, and there are some pretty nice JavaScript libraries (ExtJS, Dojo).

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    15
    Thanks for the response. Not counting OSX would you say that an ANSI C application should work (possibly with minor tweaks) for Linux and Windows? If the answer is yes then why couldn't I build say a Java Gui (as long as their is a VM installed) that sends information back and forth to the c-application. I am asking mainly to get a better understanding if my thinking about this is just very unorthodox or just not possible due to the OS not allowing shared memory area? I do come from a much lower level background but as far as any processor is concerned- it has a memory area (0x7FF for example) and the application accesses/controls the values in the memory area. If you have an OS or good compiler I think you don't have to worry about specifically selected where in the available memory of the processor(or external) and this is done behind the scenes but I am just a little confused on why it would be difficult to use one application to talk to another one. Thanks again and I am not trying to beat a dead horse by any means but the sooner I wrap my mind around some of the "whys" the sooner I can figure out what I will need to do to transition.

  8. #8
    Registered User
    Join Date
    Feb 2011
    Posts
    15

    Thanks

    Thanks
    I did not see the reply before posting. Should have refreshed!!

  9. #9
    Registered User
    Join Date
    Feb 2011
    Posts
    15
    So by your post it seems like it is not so difficult to get a JAVA gui to "talk" to the main c app?

  10. #10
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    No, not difficult at all. You first need to define the language they're going to speak. It should be a fairly simple one in your case, probably just get and set commands, with a list of values you can get (e.g. ambient_temp, RPM), and parameters you can set (e.g. hysteresis 3 degrees). You probably don't want to have to deal with actual human readable strings, so you could map 1 to get and 2 to set, then map another set of numbers to different parameters. This is more compact and makes the processing on the controller a littler easier.

    Then, pick a communication method. As I mentioned, TCP/IP sockets are fairly quick, reliable, and in very common use. That means there are great libraries for them on pretty much every platform and in every language. You might want to consider UDP since if you drop a single packet, you probably just want your GUI to keep updating since it will get a new value next time it polls. Almost any device with an ethernet controller should support this.

  11. #11
    Registered User
    Join Date
    Feb 2011
    Posts
    15
    Just to make sure we are on the same page. The communication would be from the gui application to the c application running on the same processor

  12. #12
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Sure, you could talk sockets to stuff on the same system. I do it all the time.

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Trinity32244 View Post
    Just to make sure we are on the same page. The communication would be from the gui application to the c application running on the same processor
    Except that running an *interpreted* GUI (Java, .Net, C# etc.) on the same processor could suck the life right out of the system...

  14. #14
    Registered User
    Join Date
    Feb 2011
    Posts
    15
    Thank you for the advice Tator. The systems I design generally are performing only 1 task and really won't be meant for multiple applications so to speak. Any application besides the main app would be secondary out of convenience (i.e. web browser, calculator, ect) and the main app would be expected to have priority.

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Trinity32244 View Post
    Thank you for the advice Tator. The systems I design generally are performing only 1 task and really won't be meant for multiple applications so to speak. Any application besides the main app would be secondary out of convenience (i.e. web browser, calculator, ect) and the main app would be expected to have priority.
    My point was that depending on your processor, running a monster language like C# could well drain so much CPU time as to affect even 1 background task.

    If you ever want to see a PC brought to it's knees... launch a C# program that uses.net as it's framework... I program on an AMD64x2 @ 2.8ghz... I can't run anything built on .net and play a HD movie at the same time.

    I was trying to caution you to test thoroughly as some of these RAD platforms are major resource hogs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why am I getting this error?
    By We'reGeeks in forum C Programming
    Replies: 6
    Last Post: 01-02-2011, 01:33 PM
  2. Replies: 5
    Last Post: 12-11-2010, 12:21 AM
  3. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 01:21 PM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Explain this whole "Big Bang" thing to me
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 65
    Last Post: 01-14-2005, 12:37 PM

Tags for this Thread