Automate the "Home Machine" Dialog

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automate the "Home Machine" Dialog

    As the title says, I was wondering if it was possible to select "OK" on the "Home Machine" dialog box through a script or to have it start to home by default when pc-dmis is launched?

    I have operator's that forget to select ok when they start up the computer/machine in the morning and then call me saying the machine won't move when they start a program.

    I know training and having capable operators is the ideal solution, but sometimes you gotta work with what you got.

    Any help is appreciated as always

  • #2
    I've put this option into the suggested features section, no response!

    Comment


    • #3
      DANGEROUS! Yeah, dangerous, if it just automatically does HOME, then a crash WILL happen, sooner or later (probably sooner).
      sigpic
      Originally posted by AndersI
      I've got one from September 2006 (bug ticket) which has finally been fixed in 2013.

      Comment


      • CodeWarrior
        CodeWarrior commented
        Editing a comment
        I could give you my word that I won't blame Hexagon...

      • Matthew D. Hoedeman
        Matthew D. Hoedeman commented
        Editing a comment
        and the check is in the mail, right?

      • CodeWarrior
        CodeWarrior commented
        Editing a comment
        Yeah i might have sent it to the wrong address though

    • #4
      Again , perfect example for using a cattle prod. Gets their attention right away.

      B&S CHAMELEON/PCDMIS CAD++ V2011

      There are no bugs, only "UNDOCUMENTED ENHANCEMENTS!"

      sigpic

      Comment


      • KIRBSTER269
        KIRBSTER269 commented
        Editing a comment
        you should go into the cattle prod business, you would probably make some good cash

    • #5
      I dunno, there's the options for setting precedence in which axis the machine moves first, second and third when homing... Why can't they have a button that defaults to off, that you can toggle to auto-home the CMM? seems of a rather low risk considering the speed the home typically traverses...

      As for a script, i feel it would be a challenge as the start up time and when the prompt appears would certainly vary by equipment. Plus if other pop-ups (like tc/ip send error or license has expired) are prompted prior to the press OK to home, it would likely throw you into either a horrible error loop, or prevent you from seeing the prompt forever. Yeah?

      Comment


      • #6
        Thank you all for the advice. I was afraid this would be the answer however. The cattle prod seems to be my best option

        louisd I was thinking along the lines of a script. The timing of when the window pops up along with other possible windows that are already opened/opening seemed difficult to manage

        Comment


        • #7
          Originally posted by CodeWarrior View Post
          Thank you all for the advice. I was afraid this would be the answer however. The cattle prod seems to be my best option

          louisd I was thinking along the lines of a script. The timing of when the window pops up along with other possible windows that are already opened/opening seemed difficult to manage
          I just took an automotive part fixture off the Validator. If Pcdmis automatically homed when started, it would have destroyed the machine and possibly the fixture as well. The fixture is only clear of the bridge by about 7" and almost as wide as the X travel. NO where for the machine to go to home. I have to manually move the machine, before starting Pcdmis, up, right, front and rotate the head to A90B0 or it will smash something trying to home.
          sigpic
          Originally posted by AndersI
          I've got one from September 2006 (bug ticket) which has finally been fixed in 2013.

          Comment


          • #8
            Originally posted by Matthew D. Hoedeman View Post
            DANGEROUS! Yeah, dangerous, if it just automatically does HOME, then a crash WILL happen, sooner or later (probably sooner).
            Everytime, and I do mean everytime, the first thing it does is goes straight up in the "Z" direction, unless you have things covering up the probe or knuckle over top of it, not so dangerous. When I shut the CMM down. I would usually put it at A90B0 and put it all the way down on the table, reason- If CMM every fails and falls in "Z" it's already at the bottom of the table, little to no damage. I don't start stacking things above the knuckle, so not really dangerous, back to the question. Sorry I have no answer.
            (In Memory of my Loving wife, "Ronda" who I lost March 7, 2016. I love you baby.)
            They say "Nobody's Perfect." I must be Nobody.

            Comment


            • Matthew D. Hoedeman
              Matthew D. Hoedeman commented
              Editing a comment
              HA, on the Validator, you would have to place the head ON something as the column, with NO HEAD, will rest on the table. Not a very good design IMO. I mean, you ever going to do anything without some kind of a head on the machine?

          • #9
            You could have an external alignment where the origin is at the home position. First command in the program is a read point and then check if the probe is reasonably close to the home position. Wouldn't be an absolute guarantee but should help.

            Comment


            • #10
              Funny thing, on the Validator, Sharpe32 controller, V3.7, if you tell it no, it will pop up again in a few seconds, telling you to home.
              sigpic
              Originally posted by AndersI
              I've got one from September 2006 (bug ticket) which has finally been fixed in 2013.

              Comment


              • #11
                How about creating a startup and shutdown process for them to follow and have this process near there workstation.

                Comment


                • kingsld1
                  kingsld1 commented
                  Editing a comment
                  Oh, you have people that consistently follow processes?

                  In all seriousness, the OP indicated his operators 'forget' to do something as simple as pressing an OK button. It sounds like, It's either dummy down the process or get new operators.

                  Having a troubleshooting list may help until it gets lost...

                • CodeWarrior
                  CodeWarrior commented
                  Editing a comment
                  I have a laminated card attached to the screen for the "shortened" start-up procedure. They aren't able to follow that card, just the other one that has my number on it

              • #12
                You can create an application to run in the background. It scans window handles by title each cycle tick and when it detects the one of interest you can raise whatever you want... like a full screen message that the operators cannot miss. Just an idea...

                I wrote something similar for PcDmis: I use the keyboard for everything. When there's a message popup/warning in PcD the cursor looses focus to the Edit Window, annoys me! What I did was create similar app mentioned and tied PcD ESC key to execute it. Now every time the cursor looses focus to the EW pressing ESC key will bring it right back without having to slow down to touch the mouse.

                Here's the class I pieced together, not pretty but what do you expect when there isn't enough time to do it 'right':
                C# flavor
                Code:
                using System;
                using System.Runtime.InteropServices;
                using System.Text;
                
                namespace EditWindow_SetFocus
                {
                class WndSearcher
                {
                public static IntPtr SearchForWindow(string wndclass, string title)
                {
                SearchData sd = new SearchData { Wndclass = wndclass, Title = title };
                EnumWindows(new EnumWindowsProc(EnumProc), ref sd);
                return sd.hWnd;
                }
                
                public static bool EnumProc(IntPtr hWnd, ref SearchData data)
                {
                // Check classname and title
                // This is different from FindWindow() in that the code below allows partial matches
                StringBuilder sb = new StringBuilder(1024);
                GetWindowText(hWnd, sb, sb.Capacity);
                
                string strName = sb.ToString();
                if (strName.StartsWith(data.Title))
                {
                data.hWnd = hWnd;
                return false;
                }
                return true;
                }
                
                public class SearchData
                {
                public string Wndclass;
                public string Title;
                public IntPtr hWnd;
                }
                
                private delegate bool EnumWindowsProc(IntPtr hWnd, ref SearchData data);
                
                [DllImport("user32.dll")]
                [return: MarshalAs(UnmanagedType.Bool)]
                private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, ref SearchData data);
                
                [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
                public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
                
                [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
                public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
                
                [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
                public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, int dwExtraInfo);
                private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
                private const uint MOUSEEVENTF_LEFTUP = 0x04;
                
                public static void sendMouseDown()
                {
                mouse_event(MOUSEEVENTF_LEFTDOWN, 50, 50, 0, 0);
                }
                public static void sendMouseUp()
                {
                mouse_event(MOUSEEVENTF_LEFTUP, 50, 50, 0, 0);
                }
                
                [DllImport("user32.dll", SetLastError = true)]
                public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
                
                [StructLayout(LayoutKind.Sequential)]
                public struct RECT
                {
                public int Left;
                public int Top;
                public int Right;
                public int Bottom;
                }
                
                [DllImport("user32.dll", SetLastError = false)]
                static extern IntPtr GetDesktopWindow();
                }
                }
                How it's implemented:
                Code:
                using System;
                using System.Threading;
                using System.Windows.Forms;
                using System.Drawing;
                
                
                namespace EditWindow_SetFocus
                {
                class Program
                {
                static void Main(string[] args)
                {
                IntPtr hWnd = WndSearcher.SearchForWindow("AfxFrameOrView110u", "Edit Window"); //<<-- eidt this to your liking.... use Spy++ to get the first input aka window class.
                
                //if (hWnd = IntPtr.Zero)
                //{
                // does not work?
                //}
                
                WndSearcher.RECT myRect = new WndSearcher.RECT();
                WndSearcher.GetWindowRect(hWnd, out myRect);
                
                // Start cursor point to return to
                StartPoint startPoint = new StartPoint();
                startPoint.X = Cursor.Position.X;
                startPoint.Y = Cursor.Position.Y;
                
                int curY1 = ((myRect.Top + myRect.Bottom) / 2);
                int curX1 = ((myRect.Left + myRect.Right) / 2);
                Cursor.Position = new Point(curX1, curY1);
                
                int curY2 = myRect.Bottom - 225;
                Cursor.Position = new Point(curX1, curY2);
                
                //Thread.Sleep(250);
                WndSearcher.sendMouseDown();
                Thread.Sleep(250);
                WndSearcher.sendMouseUp();
                
                Cursor.Position = new Point(curX1, curY1);
                Cursor.Position = new Point(startPoint.X, startPoint.Y);
                }
                
                public struct StartPoint
                {
                public int X;
                public int Y;
                }
                }
                }
                My apologies, indentation is lost as soon as it's pasted here.

                You will have to edit the XY coordinates to match your setup. It's currently setup for my rig, I run 3 monitors.
                Last edited by Kp61dude!; 02-10-2020, 10:05 AM.
                PcDmis 2015.1 SP10 CAD++
                Global 7-10-7 DC800S

                Comment


                • CodeWarrior
                  CodeWarrior commented
                  Editing a comment
                  I'm gonna take a further look into this when I have a moment to test. Thank you

                • Kp61dude!
                  Kp61dude! commented
                  Editing a comment
                  Disclaimer: improper use may result in your machine smacking the dust out of itself!!!!! Be careful, handle it like sharp scissors. I'm afraid your operators need to be trained on how to handle such things....

              • #13
                Originally posted by CodeWarrior View Post
                As the title says, I was wondering if it was possible to select "OK" on the "Home Machine" dialog box through a script or to have it start to home by default when pc-dmis is launched?
                Technically possible - yes; safe and practical - NO!. I won't tell you how to do it even though I know...


                AndersI
                SW support - Hexagon Metrology Nordic AB

                Comment


                • KIRBSTER269
                  KIRBSTER269 commented
                  Editing a comment
                  how rude anders, give up the info, let them make their own mistakes, that's how one learns

                • CodeWarrior
                  CodeWarrior commented
                  Editing a comment
                  Would using C# to handle the windows as shown in the example above be the correct route to take? I know you can't say exactly how to do it so maybe I'll be able to find my way there on my own

                • Peter Fuller
                  Peter Fuller commented
                  Editing a comment
                  You said what I was thinking Andersl.

              • #14
                I figured out how to do it, but from the overwhelming concern about practicality and safety I won't post the completed solution code.

                Through the concern, I've rethought the startup process of my GUI and included a pseudo "Home Machine" dialog in the app.

                The operator will still have to answer the "Home Machine" dialog, but they will be less likely to miss it if it is topmost on the main window of the app.

                Thank you all for the input

                Comment


                • davehocum
                  davehocum commented
                  Editing a comment
                  Good job CodeWarrior. You adjusted your process to work within its environment.

              • #15
                Originally posted by CodeWarrior View Post
                I figured out how to do it, but from the overwhelming concern about practicality and safety I won't post the completed solution code.

                Through the concern, I've rethought the startup process of my GUI and included a pseudo "Home Machine" dialog in the app.

                The operator will still have to answer the "Home Machine" dialog, but they will be less likely to miss it if it is topmost on the main window of the app.

                Thank you all for the input
                Like I mentioned previously... create an app to always be on the lookout for "Home" window stick it in your startup folder or link it with the PcDmis shortcut icon. Prompt the operator with a full screen window to warn that the CMM is requesting to go "Home" with an ok button that will close the full screen message and bring up the "Home" menu. Operators will still be responsible to click the button.
                PcDmis 2015.1 SP10 CAD++
                Global 7-10-7 DC800S

                Comment

                Related Topics

                Collapse

                Working...
                X