SCADA-LTS / Scada-LTS

Scada-LTS is an Open Source, web-based, multi-platform solution for building your own SCADA (Supervisory Control and Data Acquisition) system.
GNU General Public License v2.0
732 stars 292 forks source link

Showing scripts in graphical view #2034

Closed jmuguruza closed 2 years ago

jmuguruza commented 2 years ago

I have created a .json file and a background image in order to preview one part of a project. I defined 9 different HTML data points and 9 scripts. Now I want to show an output value (arbitrary value of 100 decided by me) at the output box after "Caudal de Aire:". This integer value comes from one of the nine scripts defined at the .json file. I am not able to see that value in graphical views; the script declaration at the file must be wrong. json graphical_view

Does anyone know how to define it in the .json file?

Thanks in advance

Limraj commented 2 years ago

Hi @jmuguruza,

  1. If you would like to return a constant value there, it is enough in the script: "return 100;", if you want it to be a string then: "return '100a';" you can also do something like this: return "<p style='font-size:50px'>" + "100" + "</p>"; in json: "script":"return \"<p style='font-size:25px'>\" + \"100\" + \"<\/p>\";"
  2. If you would like to return there the current point value that is set in this component, the script will suffice: "return this.value;" You also have access to other point data here, for example: "return point.name + '';" or "return point.xid + '';" and other
jmuguruza commented 2 years ago

All right. Thank you for your help @Limraj !!!

Limraj commented 2 years ago

@jmuguruza No problem, do you have any other questions? Or maybe in this context you would like to ask something else?

Limraj commented 2 years ago

@jmuguruza Can I close this topic?

jmuguruza commented 2 years ago

Yes, by the moment everything is ok. Thanks!

El lun., 10 ene. 2022 17:58, Kamil Jarmusik @.***> escribió:

@jmuguruza https://github.com/jmuguruza Can I close this topic?

— Reply to this email directly, view it on GitHub https://github.com/SCADA-LTS/Scada-LTS/issues/2034#issuecomment-1009129236, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASVR2LUYMBOB2X3BTBWAHZDUVMF4BANCNFSM5LQPLX2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

jmuguruza commented 2 years ago

Now I want to show the variable "Caudal de Purga" at the input box; this variable come from OpenPLC. I defined it as an integer in OpenPLC Editor, initialized with value 95145. So I would like to see that number at the Scada graphical views. I used this instruction at the .json file when defining the script:

"script":"return(\"

\" + parseFloat(this.value).toFixed(0) + \"<\/p>\") "

Is there anything wrong or I might have made another mistake?

Limraj commented 2 years ago

hello @jmuguruza, The problem in your definition is that the whole property "script" is one string, the problem is with it + and using ", lower level denoted by \" (nesting), try: "script":"return(parseFloat(this.value).toFixed(0) + \"<\/p>\");",

jmuguruza commented 2 years ago

I still got the same result; a 0. Captura

Limraj commented 2 years ago

@jmuguruza Could you please send me the entire system configuration by e-mail: kamil.jarmusik@softq.pl? (To do this, go to 'Import / Export' -> 'Export Project (Download)' section -> 'Export Project' button

  1. As for the value 0: try setting return this.value there, although it will probably be 0. Another possible cause is something wrong with the connection. If you send me the configuration, it will be easier for me to help. You can also describe exactly in the email what you set up in OpenPLC Editor.
  2. As for the appearance of this value, there must be something wrong with the html / css styles structure in the view definition.
jmuguruza commented 2 years ago

Ok, I will send it now.

jmuguruza commented 2 years ago

My situation now is the following:

1- I have created an .st file, with memory addressing that I did not do before and the monitor shows the following: monitoring

2- I changed a little bit the .json file, 'pointLocator' arguments at the 'dataPoints' part. These arguments are 'range', 'modbusDataType' and 'slaveID'.

3- I import the .json file at the 'Import/Export' menu and get this values: graphical_views

Limraj commented 2 years ago

Hello @jmuguruza

I think it's a matter of configuring the correct registers, addresses, and types, in Scada you change the address using the offset parameter (0-65535), then you have 4 types of registers: 1) Coils status - read/write 1 bit register (Coils - name from documentation) 2) Inputs status - read 1 bit register (Discretes Input) 3) Holding register - read/write 16 bit register (Holding Registers) 4) Input register - read 16 bit register (Input Registers)

and what you changed modbusDataType to test yourself and determine these settings, type, register and addresses, you can use the section to test the connection: point_locator_test

Modbus documentation https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf

Greetings, Kamil Jarmusik

jmuguruza commented 2 years ago

Hi @Limraj

I defined the 7 inputs as Input Registers (read) in the .json file and the 2 outputs as Holding Registers (read/write).

Now I don't know how to deal with the offset. How should I configure that parameter?

Limraj commented 2 years ago

Hey @jmuguruza , register has the addresses 0-65535. See yourself for documentation, I also showed you how to test it in the Scada, you have to look into the program in which you configure points and look for something that may be responsible for it, in my opinion you can try extreme addresses, probably by default either addresses from 0-65535 (try 0, 1, 2, 3...) or 65535-0 (65535, 65534...), maybe it has to do with "location" or that .st file that you defined.

Greetings, Kamil Jarmusik

jmuguruza commented 2 years ago

Fine, I think that I solved this problem.

Thank you once again @Limraj.

jmuguruza commented 2 years ago

Hi @Limraj, one last thing. I achieved this in Scada-LTS: scada

I am able to see all the values in the graphical views, but can not receive those two output variables in OpenPLC. They are defined this way: script

Then the data points are defined as 2 Byte int signed holding registers and I get this in OpenPLC: monitoring (1)

Limraj commented 2 years ago

Hi, I don't quite understand, because in these scripts you return the constant values ​​100 and 57087? If you want a value from that point then you have to change it to this.value, but we've already talked about that ... I'm glad you managed to configure it.

Greetings, Kamil Jarmusik

jmuguruza commented 2 years ago

The input variables come from OpenPLC and I use this.value and get those values, but now I am writing myself that output value of 100 and want to send it to OpenPLC. That is what I do not manage to do.

Limraj commented 2 years ago

To enable the value to be changed: 1) The first shorter solution, you need to set the point as settable, read / write register, and create a 'simple point' component on the view with this point, and select the "Display controls" parameter in it. Then, after hovering over the point, you should be able to change the value. This solution is rather recommended in case there is a problem, let me know. Screenshot 2022-01-23 at 19 44 35 change value: Screenshot 2022-01-23 at 19 42 30

2) Another solution that requires more steps but uses scripts: a) create datasource as ds_1 (virtual) and datapoint (numeric, settable, no change) as dp_to_read; b) create script as script_write in the scripts tab, adding datapoint dp_to_read as val_read to the context and using a special function there val_2.writeDataPoint ('DP_OPENPLC_XID', val_read.value); Screenshot 2022-01-23 at 19 25 13 c) then creating two components on the view for setting values, 'simple point' and setting dp_to_read in it, and component 'Button (script)' with script_write script to change the value.

Greetings, Kamil Jarmusik

jmuguruza commented 2 years ago

If I select one of the two output values and click on "Point details" then I can set a value manually and get it in the OpenPLC monitoring. It works with a value of 100, but when writing 57087 it does not work (both are defined as integers). a b

Limraj commented 2 years ago

Everything I have told you so far should enable you to solve these types of problems. The other thing is that you don't listen to the instructions, so act your way. I can't help you any more. Greetings.

Limraj commented 2 years ago

Hey @jmuguruza, did you deal with the problem?

jmuguruza commented 2 years ago

For the last output variable (57087) no, the program did not let me set a value like that one. But it was part of my final degree project, that I finished some days algo, so do not worry. Thank you for your help this weeks :-)