Hi, thanks very much for the video. I have a question. How do you get to the Windows desktop on your fanuc controller like you did at 4:58? Sorry if it's a dumb question, I am new to this stuff. Thanks!
Great series. I just binged through all of them. Why no use of C# exceptions? They reduce the clutter of error handling so one can more easily see the "normal" flow of control. I'd factor that "if(_rc)" clause out to a "testFocasResult(_rc, apiname)" method that throws if _rc is non-zero. You'd just follow each Focas call with a call to that routine. Then catch the exception in main() and print the result. I'd also wrap the handle in an RAII class that frees the handle on program exit. main() would use a using statement to ensure that the handle was Dispose'd of on exit. (For lurkers, handles allow you to maintain simultaneous connections to multiple CNCs.) A lot of the APIs have 2's and 3's after the name. Why? Are those updated version of the APIs with no number after them?
Thanks for checking out the series! I found when I was trying to learn this stuff that there isn't a lot of material on the internet, so I was hoping to help fill that gap for others. As for why I don't use better error handling, it is because I am trying to simply the code as much as I possibly can. I want everything I do to be explicit and to show what the true intent of the code is. In my own code I do things differently. But you are correct, there are certainly better ways to handle the errors. One thing you need to watch out for with the Focas library is the use of exceptions. Unfortunately, since the Focas library is written in C, a Try/Catch block doesn't catch all the exceptions that result from the function call and you can end up with an unhandled exception. As for the numbers after the API calls, the descriptions of the calls usually contain something like the following: "This function is the improved version of the [x] function". Sometimes this is because the older version doesn't support a specific control type, as is the case of www.inventcom.net/fanuc-focas-library/Position/cnc_rddynamic2
@@HierThinking Understood on ease of learning. You're typing in the entire program for the lesson, and a good exception idiom requires a fair amount of boilerplate. (I just coded one up in C++ and it got a little involved.) OTOH, you could prepare that part ahead of time in a header. It's pretty simple to understand, just tedious to write. The test and throw at the point of call is much tinier than checking error codes and much less intrusive, leaving the "normal" execution path much less cluttered and easier to understand. The error output is done in a catch clause in main. Since Focas is a C API, it doesn't throw at all, so you'd never get unhandled exceptions. Your description of the APIs with 2''s and 3's in the name matches what I'd suspected. There's even a version 4 of the handle API, but it's not documented. The new argument is an "id" but I have no idea what would go there.
If you have a Fanuc controller in your CNC then you should be able to use Focas. There are some older Fanuc controllers out there that may not support the Focas API, but I don't think I have come across any.
@@HierThinking ok my fanuc controller has fanuc focas. Could you help me develop something simple for monitoring the machine? (Program's name is running, when start, stop, allarm)? Please?
Sorry, I have been busy the past few days. I don't do RU-vid full time, so it may take me a bit to get to comments. I am not quite sure what you are asking here. If you are looking for someone to contract to help you create an application, you can visit my website and fill out the form to let me know what you are looking for. Here is a link... hierthinking.com/service-contact/
@@HierThinking Can I make a software (VB for example) using Focas Library and simply ask/read the machine the status? Start, stop, allarm, type allarm? Is it right?