frangoteam / FUXA

Web-based Process Visualization (SCADA/HMI/Dashboard) software
https://frangoteam.org
MIT License
2.67k stars 786 forks source link

[BUG] Archiving Siemens S7 Tag's values in sqlite db #1341

Open gabrielbalincaaeg opened 2 weeks ago

gabrielbalincaaeg commented 2 weeks ago

Describe the bug Archiving Siemens S7 Tag's values in SQLite DB doesn't work and no the values aren't there, I used SQLite Studio to check if they are there. I installed FUXA 1.2.0-1832 on fresh windows 10 virtual machine and tested with Siemens S7 1500 PLC and Modbus Simulator (ModRSsim2) and KEPServerEX 6 (OPC UA driver). Values are refreshing (so I guess the driver works ) but I can't see them in the database. With Modbus simulator and KEPServerEX 6 everything works fine.

To Reproduce Steps to reproduce the behavior: Just add an Siemens S7 connection and activate the registration.

  1. Add Siemens S7 Connection
  2. Press Tag Options
  3. Activate Registration Enabled or/and Save if changed

Expected behavior See the history values of Siemens S7 Tags in charts.

Environment

gabrielbalincaaeg commented 2 weeks ago

FIX :

server/runtime/devices/s7/index.js

this.polling = async function ()   // Line 99

and

// Line 110
          try {
               const result = await Promise.all(readVarsfnc);
                _checkWorking(false);
                if (result.length) {
                    let varsValueChanged = await _updateVarsValue(result);
                    lastTimestampValue = new Date().getTime();
                    _emitValues(varsValue);
                    if (this.addDaq && !utils.isEmptyObject(varsValueChanged)) {
                        this.addDaq(varsValueChanged, data.name, data.id);
                    }
                } else {
                    // console.error('not');
                }
                if (lastStatus !== 'connect-ok') {
                    _emitStatus('connect-ok');
                }
            }catch (reson) {
                if (reason && reason.stack) {
                    logger.error(`'${data.name}' _readVars error! ${reason.stack}`);
                } else {
                    logger.error(`'${data.name}' _readVars error! ${reason}`);
                }
                _checkWorking(false);
            };
MatthewReed303 commented 2 weeks ago

@gabrielbalincaaeg create a PR for the Fix and @unocelli can review it

martinjug commented 1 week ago

Hi,

I'm experiencing the same issue the S7 driver is functioning and values are refreshing, but they are not being stored in the SQLite database, which means historical values can't be displayed in charts.

unocelli commented 1 week ago

Hi, @gabrielbalincaaeg Thanks a lot for the report and the fix. I just commit in master branch