Create visualisation from script - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Create visualisation from script (/showthread.php?tid=3023) |
Create visualisation from script - MantasJ - 25.11.2020 Hello, Is it possible to achieve such thing: There would be a script, which would contain such information:
Logicmachine5 Input Input State Output Control output Comment A A State A On/Off Not checked And then if the script would run, it would create such a table in visualisation with all the objects, for this example it would have to create everything like this:
Is it possible to do this? Maybe someone could give me a short example how this would work so I can build something out of it? The main part which I need is to know how can I create, if possible, visualisation elements from a script. Thanks! RE: Create visualisation from script - admin - 26.11.2020 This is possible but you will need to do direct db queries. You can log all elements from a single plan (change 123 to your plan ID) like this: Code: id = 123 Then you can insert new elements into a plan. Data must be a table containing all the required field apart from id which must be nil to add a new element: Code: db:insert('visobjects', item) RE: Create visualisation from script - MantasJ - 26.11.2020 Ok, got it! Thanks! I'll let You know how it goes. RE: Create visualisation from script - Leo681 - 06.12.2020 Good night, I write this but the object is not created and when I consult the table it appears empty. Could you explain a little more? Code: db =insert('table', {object = 2305, name = 'Electro-válvula Corte Agua', RE: Create visualisation from script - admin - 07.12.2020 1. Check Errog log for errors because your code has correct syntax but running it will produce an error 2. Log the return value of the insert function call. Otherwise you won't know why insert does not happen 3. As I've already mentioned do not specify ID because it must be unique. The database will set it automatically if ID is not specified 4. type value is missing, this will cause the visualization to stop working completely Try this: Code: require('json') RE: Create visualisation from script - Leo681 - 07.12.2020 To much Thanks!!!! it works fine!!! RE: Create visualisation from script - Håvard Fosså - 16.03.2021 I borrow this thread. I have used the code above with success, but i have a problem using additional icons. When making a log out of my sample floor, i get this sub table for the param section: "icons_add":[{"min":0, "max":20, "icon":"arrow-up.svg"}, {"min":20, "max":80, "icon":"minus.svg"}, {"min":80, "max":100, "icon":"arrow-down-active.svg"}], How do i write the section for the additional icons? RE: Create visualisation from script - khalil - 17.03.2021 (07.12.2020, 07:18)admin Wrote: 1. Check Errog log for errors because your code has correct syntax but running it will produce an errorHello To run this code in different machine one should change Name: which is the plan name? icon_on, icon_off, icon_touch: script created Icon, and the icon name should be in my machine object, statusobject! I don't understand what are these what else should be changed? regards RE: Create visualisation from script - admin - 17.03.2021 (16.03.2021, 21:12)Håvard Fosså Wrote: How do i write the section for the additional icons? Code: icons_table = { Add to params table: Code: icons_add = icons_table, (17.03.2021, 08:45)khalil Wrote: Name: which is the plan name?floor = 851, where 851 is the plan ID. For icons just specify the filename of each icon that is uploaded to Vis.graphics > Icons. RE: Create visualisation from script - khalil - 17.03.2021 (17.03.2021, 08:49)admin Wrote:(16.03.2021, 21:12)Håvard Fosså Wrote: How do i write the section for the additional icons? thank you, admin what about object = 2305, statusobject = 2405, what are these see what I got RE: Create visualisation from script - admin - 17.03.2021 Main/status object address in a numeric form: X/Y/Z => X * 2048 + Y * 256 + Z RE: Create visualisation from script - khalil - 17.03.2021 (17.03.2021, 09:07)admin Wrote: Main/status object address in a numeric form: X/Y/Z => X * 2048 + Y * 256 + Z thank you, admin I appreciate your help and patience RE: Create visualisation from script - Håvard Fosså - 22.03.2021 (17.03.2021, 08:49)admin Wrote:Thank you! RE: Create visualisation from script - DGrandes - 22.04.2021 Hi, How can I create text label? An object is db:insert('visobjects', item) but a text? Thanks RE: Create visualisation from script - admin - 22.04.2021 Like this: Code: require('json') |