Hello Guest it is April 13, 2024, 07:12:25 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Analias

Pages: « 1 2 3 4 5 6 7 8 9 10 11 »
41
Mach4 General Discussion /
« on: September 04, 2014, 04:32:35 AM »
Thanks Scott I'll have to look at the code later today after work. I appreciate the feedback.

-Freeman


Sent from my Xoom using Tapatalk

42
Mach4 General Discussion / Re: Screen Set Ideas
« on: September 03, 2014, 11:39:54 PM »
I've been playing around with a panel script Freeman had posted, Basically was trying to get an idea what is going on.
Thou have to admit not following all this Lua panel scripting. But did find I could get some basic information and compute some data from mouse events by using mouse down and and mouse up.
Found that the onSize() function is not working correctly

Getting the size of the Lua Panel and resizing the inserted wxPanel containing my image is where I'm getting stuck.  There's no reason to move forward with the rest of my probing/touch off script until I can resize the embedded image correctly.  If Steve or Brian can enlighten us (especially me) I really would appreciate it.

Using the attached image, I have a Lua Panel (red border) with an inner wxPanel (yellow border).  The paint event draws my image fine.  My problem is that I cannot get the wxPanel to resize to the full extent of the outer Lua Panel.

WARNING - the attached script is very incomplete, it is a snapshot of what I'm doing at this very moment.


-Freeman


43
Mach4 General Discussion / Re: Mach 4 Feature Request
« on: August 29, 2014, 03:35:59 PM »
Please modify the Lua Panels allowing developers to refer file name paths for the source of the panel.  This would allow developers to easily refer to a single source for embedded wizards. 

Currently Lua Panels need to have their implementation source code embedded in the Lua Panel.  If the source refers to an embedded wizard the developer has to cut-n-paste the wizard code into the Lua Panel.  Having the wizard code in an external .mcs file and inside the Lua Panel makes it difficult to maintain in two places.  A common best practice among developers is to only maintain a single copy of any code to avoid duplication and reduce code maintenance costs.  Extending the Lua Panel to allow it to refer to the external code path would allow developers to meet this ideal.


-Freeman

44
Scott,

I tried the following, assuming the screen set had already been loaded as a resource.  Unfortunately, it's failing bitmap:Ok() and showing the error.  Do you have an example of how to do this?

Code: [Select]
local wxXmlResource = wx.wxXmlResource:Get();
local imagePath = 'MSM_Probe_1.png';

function onPaint (event)
    local dc = wx.wxPaintDC(panel);

    local bitmap = wxXmlResource:LoadBitmap (imagePath);

    if (not bitmap or not bitmap:Ok()) then
        wx.wxLogError("Could not load image from '%s'!", imagePath);
        dc:delete();
        return;
    end

    dc:DrawBitmap (bitmap, 0,0, true);

    dc:delete ();
end

The error I get is:  XRC error: XRC resource "MSM_Probe_1.png" (class "wxBitmap") not found. 

I tried it with several paths variations with no luck.


-Freeman

45
Mach4 General Discussion / Re: Mach 4 Bug Reports
« on: August 17, 2014, 01:05:58 AM »
Mach 4 Build 1936

When using a Lua Panel, the initial size is set by the screen editor.  When panel resized, when the Mach 4 is loaded or resized, the Lua Panel (as pointed to by mcLuaPanelParent) does not resize appropriately.

To test, drop a Lua Panel into a screen set.  Insert the code below as the script property of the Lua Panel. Use your own image, set the size of the Lua Panel smaller than your image to force it to crop.  My image was 380x380 pixels, my panel is 350x350 px. Exit the screen editor to cause Mach 4 to resize the contents of the screen set. 

Note that image is cropped to the initial size of the Lua Panel, and is surrounded on the left and bottom by blank space.  Clicking on the image causes the onLeftUP() event handler to fire and show the X/Y coordinates of the click.  Clicking outside of the image, in the solid blank area, returns no feed back.


Code: [Select]

local panel = mcLuaPanelParent

function onPaint (event)
    local dc = wx.wxPaintDC(panel);

    local image = wx.wxImage();
    if (not image:LoadFile('./screens/MyStdMill/images/MSM_Probe_1.png', wx.wxBITMAP_TYPE_PNG)) then
        wx.wxLogError("Could not load image from '%s'!", imagePath);
        dc:delete();
        return;
    end

    --image:Resize(panel.getSize());
   
    local bitmap = wx.wxBitmap(image);

    dc:DrawBitmap (bitmap, 0,0, true);

    dc:delete ();
end

function onLeftUp (event)
    local mouseX = event:GetX();
    local mouseY = event:GetY();

    wx.wxMessageBox("LEFT CLICK - X: "..tostring(mouseX)..", Y: "..tostring(mouseY));
end

function onSize (event)
    local size = panel.getSize();

    wx.wxMessageBox('Width: %d, Height: %d', size.getWidth(), size.getHeight());

    event:skip();
end

-- connect the paint event handler function with the paint event
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);
panel:Connect(wx.wxEVT_SIZE, onSize);

-Freeman

46
I've made some progress on this.  It's not done by far, but I thought I would share for those who might be interested.

While chatting with Scott (poppabear) he mentioned the "Lua panels".  This got me thinking and I now have an embedded Lua panel loading my image and returning the mouse X and Y coordinates when the left mouse button is clicked.  This gets me closer to a component that can load an image and provide feed back when clicked on - think image maps like in HTML.  I'll probably use a second bitmap that mirrors the image shown and provides quick lookup if the user clicked in a roped off area or not.

To use this, add a Lua Panel to your screen set.  Cut-n-paste the code below into the script property of the panel.  Be sure to choose a different image.  My images are broken out into directory image of the screen set (ie. the .set file has been unzipped).  I will eventually need to know how to read a file from the zip if I want to keep my images in the screen set.  Brian, Steve, et al - if you have any guidance on how to read images from the screen set file, I would be very interested in hearing how.

I still need to wire in the proper events to catch resizing of the panel to resize the image on the fly.

Code: [Select]
function onPaint (event)
    local dc = wx.wxPaintDC(panel);

    local image = wx.wxImage();
    if (not image:LoadFile('./screens/MyStdMill/images/MSM_Probe_1.png', wx.wxBITMAP_TYPE_PNG)) then
        wx.wxLogError("Could not load image from '%s'!", imagePath);
        dc:delete();
        return;
    end

    --image:Resize(panel.getSize());
   
    local bitmap = wx.wxBitmap(image);

    dc:DrawBitmap (bitmap, 0,0, true);

    dc:delete ();
end

function onLeftUp (event)
    local mouseX = event:GetX();
    local mouseY = event:GetY();

    wx.wxMessageBox("LEFT CLICK - X: "..tostring(mouseX)..", Y: "..tostring(mouseY));
end

function onSize (event)
    local size = panel.getSize();

    wx.wxMessageBox('Width: %d, Height: %d', size.getWidth(), size.getHeight());
end

panel = mcLuaPanelParent

-- connect the paint event handler function with the paint event
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);
panel:Connect(wx.wxEVT_SIZE, onSize);

-Freeman

47
Mach4 General Discussion / Lua Panels and events
« on: August 14, 2014, 01:14:34 AM »
Steve (aka smurph), is there something that is causing mouse events not to work in Lua Panels that are dropped into a screen set?  I have panel that I plan to show an image in, and have event handlers capture the mouse X & Y coordinates on left clicks.  I copied and simplified some code from one of the wizards and dropped it into the script property of the Lua Panel.  The onPaint() event is working, but the onLeftUp() event handler is not.  Is there something blocking events from happening on

Code: [Select]
-- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
require("wx")

-- paint event handler for the frame that's called by wxEVT_PAINT
function onPaint(event)
    -- must always create a wxPaintDC in a wxEVT_PAINT handler
    local dc = wx.wxPaintDC(panel)
    -- call some drawing functions
    dc:DrawRectangle(10, 10, 300, 300);
    dc:DrawRoundedRectangle(20, 20, 280, 280, 20);
    dc:DrawEllipse(30, 30, 260, 260);
    dc:DrawText("A test string", 50, 150);
    dc:delete() -- ALWAYS delete() any wxDCs created when done
end

function onLeftUp (event)
    local mouseX = event.GetX();
    local mouseY = event.GetY();

    mc.mcCntlSetLastError("LEFT CLICK - X: "..tostring(mouseX)..", Y: "..tostring(mouseY));
end

panel = mcLuaPanelParent

-- connect the paint event handler function with the paint event
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);

Hmmm... I just tried modifying the original wizard code and it's not showing left clicks either :(  I wonder what I'm missing?


-Freeman

48
Mach4 General Discussion / Re: Mach4 Printer Port Discussions
« on: August 09, 2014, 06:41:10 PM »
Art, when I set Darwin back down closer to my minimum calculated speed for my desired acceleration in motor tuning, my axis start running much smoother.  With my motors, ballscrews, and desired top acceleration that minimum is *just* under 17000.  I have Darwin set to 18kHz and I have been as high as 22kHz before noticing problems.  I'm running at 18kHz at the moment to allow my Z axis to run without seizing and squealing.  This driver (v1.10) seems to be much better at handling frequencies above the minimum of 17kHz I needed in the past.  It use to be that any thing above 17kHz would cause problems.

I'm wondering if there is some relationship between the usable frequency range that you tune your motors for and how fast you can marshal requests to the driver.  Not knowing the internals of Darwin or Mach 4, and only going on the hints you have giving on the forum, in emails, and in videos - it got me thinking if Mach is having a problem feeding Darwin fast enough to to keep it from starving, or if you have a classic bug with the queue boundary tracking being overwritten.

Just some random thoughts from someone who doesn't know better.


-Freeman

49
Mach4 General Discussion / Re: Mach4 Printer Port Discussions
« on: August 09, 2014, 02:39:42 PM »
Freeman:

  Pretty strange. I find it hard to blame that on CPU Power, my machine isnt great but run at 0%..

Has to be some process or another hanging up.. hopefully it will become appararent as we go..

Art


Chrome hangouts was running in the background.  That seemed to be the only "extra" processing that was running for me or any other user on the system.  I made a point killing everything that was extraneous, only "slight" improvement in jogging or rapids.  I seem to remember one of the first attempts early on that ran smoothly, it was on my built in video card, so I removed the GTX 550ti and the extra PCI serial port.  Still no improvement.

I tried forcing the process priority higher incrementally, there was "slight" improvement until I set the mach4gui process to "realtime".  There was no performance gain but, the GUI was ignored.  Jogging once caused the table to stutter move until it hit a limit switch was hit or I triggered one myself.  None of the GUI buttons were responded to.

Just as a data point, I'm running under Win 7 Home edition.  I tried running under Win XP SP 3 compatibility mode with no change.


-Freeman

50
Mach4 General Discussion / Re: Mach4 Printer Port Discussions
« on: August 09, 2014, 12:27:16 PM »
No luck with Darwin 1.11 - the stuttering while jogging or rapids in Mach4 are still there.  Homing while referencing axis moves smoothly, but that's all Darwin there.  No crashes for me.

-Freeman

Pages: « 1 2 3 4 5 6 7 8 9 10 11 »