Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Need some guidance

  1. #1

    Default Need some guidance

    I'm working on a driver for an Elk M1 Gold panel. I've looked at the G6 docs and looked at several other Lua based plugins, but I can't seem to find many commonalities between examples.

    My goal is to be able to select my plugin through the settings window, add the IP address/port number (or serial port number in the future), and have alarm events trigger actions that have been configured using the action tree. I would also like to use this code as a template for future plugins for other devices I have.

    Specific questions:
    - Why do some plugins have so many .lua files? example: device.lua, init.lua, control.lua
    - Are certain filenames hardcoded within G6 to perform certain functions? What calls init.lua?
    - What is the difference between init and start functions?

    I've attached what I have thus far, but I cannot get it to connect to the M1G upon startup of Girder. What have I missed?

    Thanks in advance!


    elk-M1G.zip

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    That is awesome news! Sorry about the state of the development docs. We've focused a lot more on features and user side docs up to now. We've started on a rough developer doc now.

    http://www.promixis.com/forums/showt...ugin-Writing-1

    Read through that.

    1. Many lua files - Depends on their functionality. If you do not expose to the device manager it can be really simple. ( about 4 files, 1 config, 1 lua, 1 javascript and a UI file )
    2. filenames are not hardcoded. Files are extracted from the *.plugin file ( see doc mentioned before ) Girder expects a certain set of functions in the Lua and Javascript files.
    3. in the plugin init is the object constructor. Start is when the plugin is allowed to start sending events.

    Take a look at lua\examples\plugin
    Ron
    No support through PM

  3. #3

    Default

    I have read through the plugin page. This answered a few questions, but created a lot more questions.

    Having read through every provided Lua based plugin only created even more confusion since there doesn't seem to be any uniformity between those plugins. Some require being called by a scripting action, some require configuration via the device manager, other require configuration via the plugin page itself. I would like to adhere to a standard if one applies, or at the very least, I would like to adhere to a recommended method.

    So:
    - How do I have my plugin create a new connection over the LAN upon startup of G6 without needing a scripting action to initiate that connection? I don't want to have to write code in a GUI to initiate backend code. I need to be able to write plugins and ship them to a friend who has limited tech skills. I may be working on two separate G6 installs, so simplicity is important.
    - Why do some plugins use an init.lua? Nothing seems to include them so how are they referenced? Do I even care about this?
    - Shouldn't a plugin be able to be loaded and start sending events to the action tree without any scripting outside of the plugin itself? Maybe this is the source of my confusion.

    I've RTFM, but it leaves a lot of gaps for a newb like myself. I'll be more than happy to help write a "starting from scratch guide" if I can get G6 to do what I need. For now though, I need to get over the hump.

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    1 Sure that is possible.
    2. The convention that I have been trying to stick with is that init.lua holds the actually communication items if the plugin uses the transport system. It's called typically from plugin.lua ( or backend.lua ).
    3. Yep

    There are basically two paths.

    1. You are going to expose devices to the device manager, devices are instantiated and configured from there. ( E.g. PIO-1, Global Cache )
    2. You are not. No devices and config happens on the settings page. For example the WinLirc plugin.

    1. Involves a lot more work and is probably not a good starting point to learn. So let's start with the WinLirc plugin as a starting point. It has config on the settings page and is really simple. Have a look at that. Then come back with questions ( or call me and I'll talk you through it ).

    I think the easiest way for you to get started is by making a copy of the winlirc plugin.
    Last edited by Ron; May 12th, 2015 at 12:47 PM.
    Ron
    No support through PM

  5. #5

    Default

    Heeding your advice, I took a third look at the WinLirc plugin. I now have an Elk M1 Gold plugin that triggers emails using just the action tree with no need for a scripting action. It's incredibly basic at this point, but it's a working PoC and something to build off of.

    A few questions though:
    - I noticed that the winlirc plugin forwards events to some sort of messaging bus (correct term?) instead of being sent directly as an event. This took a little while to see. What's the benefit of such an approach instead of just sending the event directly?
    - I would like to have pre-populated events displayed for each type of event. Examples: zone violation, zone normal, alarm state, etc... Is there an example plugin I can look at that makes use of such a thing? I would like to make an event a basic drag and drop type affair to harness the power of the GUI. I know scripting if far more powerful, but I think scripting should be an option that allows one to go beyond the basics, instead of the default.

  6. #6
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    You can call gir.triggerEvent with the whole pub / sub pattern if you like. It decouples the hardware communications from the Girder specific stuff (usually device manager interactions), but for something this simple it's just icing.

    edit checking on the events thing...
    Ron
    No support through PM

  7. #7
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Predefined Events,.. unfortunately not yet exposed to the Lua side of things... I will add it.
    Ron
    No support through PM

  8. #8
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    I've added predefined events lua access in my code here. Unfortunately I just did a full release which this feature missed. I'll see if I can do a new release in a few days.
    Ron
    No support through PM

  9. #9

    Default

    Hi Ron,

    I am looking at the pio1 plugin but I am also failing to see were init.lua is include or referenced. In plugin.lua (in your earlier post here you mention that this is normally done in plugin.lua or backend.lua) I find some of the other files that the plugin is composed of but not init.lua.

    Could you give us a short explanation on how this works (maybe add it to the plugin tutorial you started)?

    Joachim
    Last edited by Yoggi; June 8th, 2015 at 12:54 AM.

  10. #10
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    The PIO-1 plugin is Device Manager based as such the pio/init.lua file isn't loaded from plugin.lua but from device.lua ( since each PIO-1 is configured as a DM device ). So if you open device.lua line 2 loads init.lua

    Code:
    local pio1 = require('pio1')
    That is shorthand for require('pio/init.lua')
    Ron
    No support through PM

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •