Hello Guest it is March 28, 2024, 08:14:04 AM

Author Topic: Lua Stats  (Read 3556 times)

0 Members and 1 Guest are viewing this topic.

Lua Stats
« on: April 30, 2018, 04:00:26 PM »
Does anyone know how to include Lua Stats and or Lua Graph into Mach4?

Thanks
Re: Lua Stats
« Reply #1 on: April 30, 2018, 06:12:33 PM »
I will just program what I need for stats but would like to add graphing for Lua...

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Lua Stats
« Reply #2 on: May 03, 2018, 06:10:41 PM »
Any LUA compatible 5.2 module library can be placed in the Modules directory and used.

Steve
Re: Lua Stats
« Reply #3 on: May 05, 2018, 08:00:13 PM »
Hi,
I found this page which has an extensive list of libraries:

http://lua-users.org/wiki/LibrariesAndBindings

And on that list I found:

http://plplot.sourceforge.net/

It is a 5.0 and 5.1 library so should be good for 5.2.

Does any of that look useful?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Lua Stats
« Reply #4 on: May 11, 2018, 11:15:59 PM »
Hi,
OK, I've finally got CMake and MinGW installed.

I've downloaded PLplot and built it and have it in C;\Program Files\plplot so now what?. As far as I know its all there and OK, but its not a program you can run....there's no .exe
file in it anywhere. I don't know what I was expecting but I didn't get it!.

If I understand correctly its really a library that allows me to write a program in Lua which calls on a very extensive library of functions for drawing graphs. So how do
I go about using it?

I guess I have to let Mach know that I wish to use functions from an external file. How do I do that. Do I require a module? I see a Lua function called dofile()...what does it do?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Lua Stats
« Reply #5 on: May 12, 2018, 01:05:01 AM »
Usually, you would try and find pre-built binaries that will just drop into the Modules directory.  But it seems that it is "campy" to not provide pre-built binaries.  Like you have to be in their exclusive programmer club to be able to use the library modules.  At least that is my cynical take on it.  :)  But you have to realize that a lot of the guys that write this stuff are unix/linux oriented and they rather hate Windows with a passion.  EVERYTHING is built from source in the unix/linux world.  So pre-built binaries only exist in the Windows world.  

But you can build it with the development tools.  But if you haven't done that, it will be a steep learning curve.  However, it is not rocket science.  Anyone can do it, but it WILL be like poking the proverbial knitting needle through your eardrums.  That, I can promise you!

To build this stuff, you need the compiler (MinGW), the library source, any other library source that the target one depends on (if any), LUA 5.2 headers and libraries, and cmake.  There is a cmake GUI that makes it a little less painful.  In the world of cmake, you point to the source files, point to a build directory (usually one that you create), and "configure".  Which basically generates make files for the chosen compiler.  Then you have to go to the old command prompt, change into the build directory, and type "make".  The make program reads the generated make file (usually called Makefile without an extension) that cmake produced and that, in turn, will produce the binaries.  Cmake is all a an attempt at making the source compile-able with any compiler on any platform.  But...  to me, it is a huge pain in the ass.

You don't let Mach know anything other than placing the resultant LUA module DLL into the modules directory.  Then you use the module in your scripts, you "require" the module.  

graph = require "plplot"

If the module DLL is called plplot.dll.  Then you access the functions with the graph variable.

But wait...  there's more!  LUA 5.2 is different than LUA 5.0 and 5.1 where modules are concerned.  If the module source is not setup to compile with LUA 5.2, then you will have to "port" the source to something that is compatible with LUA 5.2  This generally involves changing the call to luaL_register() to use lua_newtable() and luaL_setfuncs() instead.  Here is an example from a LUA library that I recently compiled (and had to port).  

Code: [Select]
#if LUA_VERSION_NUM > 501
  lua_newtable(L);
  luaL_setfuncs(L, functions_tb, 0);
  lua_pushvalue(L,-1);
  lua_setglobal(L,LIBNAME);
#else
  luaL_register(L, LIBNAME, functions_tb);
#endif

Steve
Re: Lua Stats
« Reply #6 on: May 12, 2018, 01:53:24 AM »
Hi Steve,
thanks for the knitting needle analogy....it makes me cringe.

The binaries are available for Linux and Mac but not Windows. I downloaded the source files as a zip archive which I then expanded.
I have Cmake installed so I pointed the unzipped source file to it and had it build in Program File\plplot.

The original expanded source file is a little over 100M but the files in Program File\plpot are only about 5M. When I inspect the individual files I was expecting bianary code,
but no, each file is a CMake file. I have come to the conclusion that the binaries have not in fact been created but rather a whole bunch of Cmake files which presumably
direct the complier/linker in the creation of the files. Its just that they haven't done so yet.

Quote
Then you have to go to the old command prompt, change into the build directory, and type "make".  
I think this is where I am at.....I'll look a bit harder and try to replicate what you have described.

Thanks for your help....this is not Mach per se, so I really appreciate that you would take the time to help out. I like the thought of being able to attach or otherwise incoperate
some of the very wide ranging Lua compatible libraries. Whats more if I can do it so can others,,,,

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Lua Stats
« Reply #7 on: May 12, 2018, 03:30:01 AM »
Hi,
the knitting needle is about half way though....

I had to download GnuWin32 Make and install it. Had to put its path in the PATH variable. Thereafter at the 'make' command in the plplot directory produces a whole
bunch of files....but I don't know where they all go.  The plplot directory doesn't seem to grow at all and very few new files have been added to it?

I suspect there must be a bunch of command line switches which I haven't tumble to yet.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Lua Stats
« Reply #8 on: May 12, 2018, 03:39:17 AM »
Look at the Makefile and look for the target "all"

the format is:

target:dependencies

A target may include other targets as dependencies.  Layer upon layer, etc...

Also, search the build directory and all child directories for *.dll.

Sometimes the modules will have more than a DLL file and have quite complex directory structures.  In that case, look for an installation directory path in the Makefile.  INSTALLDIR or something of the like.  You can directly edit the Makefile if needed.  Create a directory and point the installation directory variable to that path.  Then "make install".  All of the build files will be copied to the directory you created with the correct directory structure.  To use them in Mach, you would copy all of those files to the Modules directory of Mach, preserving the directory structure. 

Steve
Re: Lua Stats
« Reply #9 on: May 12, 2018, 03:58:24 AM »
Hi Steve,
a lot of that was above my head.

This is in the Makefile  in the top directory of plplot:
Quote
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.10

# Default target executed when no arguments are given to make.
default_target: all

.PHONY : default_target

# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:

Is that what you were asking about/alluding to?

In plplot there is a folder called dll, and at the start of this excerise I thought it was empty. Now it has a number of files
of the type libqsastime.dll . Does this mean that some binaries are being generated?

There is also a folder called Bindings and in it a whole bunch of files, one for each language that binds to plplot, including one for Lua.
I'm almost certain that before the 'Make' process there were a few Cmake files and a Cmake folder in the Lua folder. After the 'Make' process
nothing seems to have changed. I changed directory to Lua and issued another 'make' command, it returned almost immediately and produced
no new binaries or any other file within itself.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'