diff --git a/Thermo.Active/Controllers/SignalR/NcHub.cs b/Thermo.Active/Controllers/SignalR/NcHub.cs index 016b3cd1..27959666 100644 --- a/Thermo.Active/Controllers/SignalR/NcHub.cs +++ b/Thermo.Active/Controllers/SignalR/NcHub.cs @@ -18,6 +18,11 @@ namespace Thermo.Active.Controllers.SignalR public static List ConnectedClients = new List(); public static bool NewConnectedClients = false; + /// + /// Oggetto adapter condiviso da Signal-r + /// + protected static NcAdapter ncAdapter = new NcAdapter(); + public override Task OnConnected() { Groups.Add(Context.ConnectionId, "ncData"); @@ -55,11 +60,8 @@ namespace Thermo.Active.Controllers.SignalR [SignalRAuthorize(FunctionAccess = STARTUP_ICONS, Action = ACTIONS.WRITE)] public void PutPowerOnData(uint id) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - ncAdapter.Connect(); - ncAdapter.PutPowerOnData(id); - } + CmsError libraryError = ncAdapter.Connect(); + ncAdapter.PutPowerOnData(id); } // [SignalRAuthorize(FunctionAccess = "functionAccess", Action = ACTIONS.READ)] @@ -67,160 +69,125 @@ namespace Thermo.Active.Controllers.SignalR [SignalRAuthorize(FunctionAccess = ALARM_CMD, Action = ACTIONS.WRITE)] public void RefreshAllAlarms() { - using (NcAdapter ncAdapter = new NcAdapter()) - { - CmsError libraryError = ncAdapter.Connect(); - // Call the library functions - libraryError = ncAdapter.RefreshAllAlarms(); - } - // MessageServices.Current.Publish(SHOW_MSG_UI, null, "Refresh All Alarms."); + CmsError libraryError = ncAdapter.Connect(); + // Call the library functions + libraryError = ncAdapter.RefreshAllAlarms(); } [SignalRAuthorize(FunctionAccess = ALARM_CMD, Action = ACTIONS.WRITE)] public void RefreshAlarm(uint id) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - CmsError libraryError = ncAdapter.Connect(); - // Call the library functions - libraryError = ncAdapter.RefreshAlarm(id); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } - - // MessageServices.Current.Publish(SHOW_MSG_UI, null, "Refresh Single Alarm. ID: " + id); + CmsError libraryError = ncAdapter.Connect(); + // Call the library functions + libraryError = ncAdapter.RefreshAlarm(id); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = ALARM_CMD, Action = ACTIONS.WRITE)] public void RecoveryProcedure(uint id) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - CmsError libraryError = ncAdapter.Connect(); - // Call the library functions - libraryError = ncAdapter.RestoreAlarm(id); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } - - // MessageServices.Current.Publish(SHOW_MSG_UI, null, "Recovery Alarm. ID: " + id); + CmsError libraryError = ncAdapter.Connect(); + // Call the library functions + libraryError = ncAdapter.RestoreAlarm(id); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = USER_SOFTKEY, Action = ACTIONS.WRITE)] public void UserSoftKeyClick(int id) { - using (NcAdapter ncAdapter = new NcAdapter()) + ncAdapter.Connect(); + foreach (var softKey in SoftKeysConfig) { - ncAdapter.Connect(); - foreach (var softKey in SoftKeysConfig) + // Check softKey type + if (softKey.Type == SOFTKEY_TYPE.GROUP) { - // Check softKey type - if (softKey.Type == SOFTKEY_TYPE.GROUP) + // Find in the subkeys + foreach (var subkey in softKey.SubKeys) { - // Find in the subkeys - foreach (var subkey in softKey.SubKeys) - { - if (subkey.Id == id) - { - // Write click button - ncAdapter.PutUserSoftKeyClick((uint)subkey.PlcId); - break; - } - } - } - else - { - if (softKey.Id == id) + if (subkey.Id == id) { // Write click button - ncAdapter.PutUserSoftKeyClick((uint)softKey.PlcId); + ncAdapter.PutUserSoftKeyClick((uint)subkey.PlcId); break; } } } + else + { + if (softKey.Id == id) + { + // Write click button + ncAdapter.PutUserSoftKeyClick((uint)softKey.PlcId); + break; + } + } } } [SignalRAuthorize(FunctionAccess = PROCESS_CMD, Action = ACTIONS.WRITE)] public void SelectProcess(ushort procNumber) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - // Connect the NC - CmsError libraryError = ncAdapter.Connect(); - // Put value into memory - libraryError = ncAdapter.PutSelectProcess(procNumber); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + // Connect the NC + CmsError libraryError = ncAdapter.Connect(); + // Put value into memory + libraryError = ncAdapter.PutSelectProcess(procNumber); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = AXES_SELECTION, Action = ACTIONS.WRITE)] public void SelectAxis(byte axisId) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - // Connect the Nc - CmsError libraryError = ncAdapter.Connect(); - // Put value into memory - libraryError = ncAdapter.PutSelectAxis(axisId); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + // Connect the Nc + CmsError libraryError = ncAdapter.Connect(); + // Put value into memory + libraryError = ncAdapter.PutSelectAxis(axisId); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = HEADS_CMD, Action = ACTIONS.WRITE)] public void AddOverride(uint id) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - // Connect the Nc - CmsError libraryError = ncAdapter.Connect(); + // Connect the Nc + CmsError libraryError = ncAdapter.Connect(); - // Put value into memory - libraryError = ncAdapter.PutOverride(id, "plus"); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + // Put value into memory + libraryError = ncAdapter.PutOverride(id, "plus"); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = HEADS_CMD, Action = ACTIONS.WRITE)] public void SubOverride(uint id) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - // Connect the Nc - CmsError libraryError = ncAdapter.Connect(); + // Connect the Nc + CmsError libraryError = ncAdapter.Connect(); - // Put value into memory - libraryError = ncAdapter.PutOverride(id, "minus"); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + // Put value into memory + libraryError = ncAdapter.PutOverride(id, "minus"); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = GENERAL, Action = ACTIONS.WRITE)] public void WriteM155Response(int process, double responseVal) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - ncAdapter.Connect(); - CmsError libraryError = ncAdapter.WriteM155Data(process, responseVal); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + ncAdapter.Connect(); + CmsError libraryError = ncAdapter.WriteM155Data(process, responseVal); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } [SignalRAuthorize(FunctionAccess = GENERAL, Action = ACTIONS.WRITE)] public void WriteScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value) { - using (NcAdapter ncAdapter = new NcAdapter()) - { - ncAdapter.Connect(); - CmsError libraryError = ncAdapter.WriteScada(memIndex, memType, value); - if (libraryError.IsError()) - throw new HubException(libraryError.localizationKey); - } + ncAdapter.Connect(); + CmsError libraryError = ncAdapter.WriteScada(memIndex, memType, value); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } } diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index 982fc180..e78916da 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.9.24")] +[assembly: AssemblyVersion("0.9.25")] diff --git a/Thermo.Active/makeTestVersion.bat b/Thermo.Active/makeTestVersion.bat deleted file mode 100644 index 04dc0ca1..00000000 --- a/Thermo.Active/makeTestVersion.bat +++ /dev/null @@ -1,52 +0,0 @@ -@echo off -REM SCript di creazione e compilazione versioen per test in macchina - -REM Check parameters -REM IF "%1"=="" GOTO ShowHelp - -REM :MsBuild - -:Npm -cd wwwroot -REM install moduli npm -IF "%1"=="y" ( - echo %date%-%time% START npm install >> c:\tmp\Script.log - powershell.exe npm install - echo %date%-%time% END npm install >> c:\tmp\Script.log -) - -REM: compilazione npm -IF "%2"=="y" ( - echo %date%-%time% Start file replace >> c:\tmp\Script.log - REM replace seriate server dev (seriate.steamware.net) --> produzione (locahost) - powershell.exe "((Get-Content -path index.html -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path index.html" - powershell.exe "((Get-Content -path config.development.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.development.json" - powershell.exe "((Get-Content -path config.production.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.production.json" - - REM build pacchetti npm - echo %date%-%time% START npm run build >> c:\tmp\Script.log - npm run build - echo %date%-%time% END npm run build >> c:\tmp\Script.log -) - -:Copy -cd .. -REM copio wwwroot --> view -echo %date%-%time% Start copy >> c:\tmp\Script.log - -robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\view /MIR /Z /LOG:C:\tmp\ViewMirror.log /XF *.babelrc .bowerrc .editorconfig bower.json compilerconfig.json* package*.json tsconfig.json webpack.config.js /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\node_modules C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\src - -robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\ C:\Users\samuele\Desktop\ThermoActive\ /MIR /Z /LOG:C:\tmp\ThermoMirror.log /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\Client_Debug -echo %date%-%time% END copy >> c:\tmp\Script.log - - -REM :Compress -echo "%date%-%time% START zip" >> c:\tmp\Script.log -powershell.exe Compress-Archive -Path C:\Users\samuele\Desktop\ThermoActive -DestinationPath "C:\Users\samuele\Desktop\ThermoActive_%3.zip" -echo "%date%-%time% END zip" >> c:\tmp\Script.log - -:ShowHelp -REM echo makeTestVersion n n vers_number - i primi 2 parametri sono y/n per indicare se eseguire npm install ed npm build, il terzo è il nome versione da accodare a zip - - -@echo on \ No newline at end of file diff --git a/Thermo.Active/makeTestVersion.ps1 b/Thermo.Active/makeTestVersion.ps1 index 04dc0ca1..598795dc 100644 --- a/Thermo.Active/makeTestVersion.ps1 +++ b/Thermo.Active/makeTestVersion.ps1 @@ -1,52 +1,75 @@ -@echo off -REM SCript di creazione e compilazione versioen per test in macchina +# Script di creazione e compilazione versione per test in macchina -REM Check parameters -REM IF "%1"=="" GOTO ShowHelp +# Check parameters +Param ( + [Parameter(Mandatory=$True)] + [ValidateNotNull()] + $npmInstall, + [Parameter(Mandatory=$True)] + [ValidateNotNull()] + $npmBuild,[Parameter(Mandatory=$True)] + [ValidateNotNull()] + $version +) -REM :MsBuild +# recupera timestamp x logging +function Get-TimeStamp { + + return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date) + +} +# registra log! +function DoLog($txt2log) +{ + Write-Output "$(Get-TimeStamp) $txt2log" | Out-File c:\tmp\Script.log -Append +} -:Npm + +DoLog("-------------------------------- START script --------------------------------") +$StopWatch = New-Object System.Diagnostics.Stopwatch +$StopWatch.Start() + +# mi sposto in wwwroot cd wwwroot -REM install moduli npm -IF "%1"=="y" ( - echo %date%-%time% START npm install >> c:\tmp\Script.log - powershell.exe npm install - echo %date%-%time% END npm install >> c:\tmp\Script.log -) +# NPM install/build step +if($npmInstall -eq "y") +{ + DoLog("START npm install") + npm install | Out-File c:\tmp\Script.log -Append + DoLog("END npm install") +} -REM: compilazione npm -IF "%2"=="y" ( - echo %date%-%time% Start file replace >> c:\tmp\Script.log - REM replace seriate server dev (seriate.steamware.net) --> produzione (locahost) - powershell.exe "((Get-Content -path index.html -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path index.html" - powershell.exe "((Get-Content -path config.development.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.development.json" - powershell.exe "((Get-Content -path config.production.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.production.json" +if($npmBuild -eq "y") +{ + DoLog("START file replace") + # replace seriate server dev (seriate.steamware.net) --> produzione (locahost) + ((Get-Content -path index.html -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path index.html + ((Get-Content -path config.development.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.development.json + ((Get-Content -path config.production.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.production.json - REM build pacchetti npm - echo %date%-%time% START npm run build >> c:\tmp\Script.log - npm run build - echo %date%-%time% END npm run build >> c:\tmp\Script.log -) + # build pacchetti npm + DoLog("START npm run build ") + npm run build | Out-File c:\tmp\Script.log -Append + DoLog("END npm run build ") + } -:Copy +# torno in folder base cd .. -REM copio wwwroot --> view -echo %date%-%time% Start copy >> c:\tmp\Script.log +# copio wwwroot --> view +DoLog("START copy step") robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\view /MIR /Z /LOG:C:\tmp\ViewMirror.log /XF *.babelrc .bowerrc .editorconfig bower.json compilerconfig.json* package*.json tsconfig.json webpack.config.js /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\node_modules C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\src - robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\ C:\Users\samuele\Desktop\ThermoActive\ /MIR /Z /LOG:C:\tmp\ThermoMirror.log /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\Client_Debug -echo %date%-%time% END copy >> c:\tmp\Script.log +DoLog("END copy step") -REM :Compress -echo "%date%-%time% START zip" >> c:\tmp\Script.log -powershell.exe Compress-Archive -Path C:\Users\samuele\Desktop\ThermoActive -DestinationPath "C:\Users\samuele\Desktop\ThermoActive_%3.zip" -echo "%date%-%time% END zip" >> c:\tmp\Script.log +# Compression step +DoLog("START ZIP step") +$ProgressPreference = "SilentlyContinue" +Compress-Archive -CompressionLevel Fastest -Force -Path C:\Users\samuele\Desktop\ThermoActive -DestinationPath "C:\Users\samuele\Desktop\ThermoActive_$version.zip" | Out-File c:\tmp\Script.log -Append +$ProgressPreference = "Continue" +DoLog("END ZIP step") -:ShowHelp -REM echo makeTestVersion n n vers_number - i primi 2 parametri sono y/n per indicare se eseguire npm install ed npm build, il terzo è il nome versione da accodare a zip - - -@echo on \ No newline at end of file +$StopWatch.Stop() +$StopWatch.Elapsed | Out-File c:\tmp\Script.log -Append +DoLog("-------------------------------- END script --------------------------------") diff --git a/Thermo.Active/wwwroot/config.development.json b/Thermo.Active/wwwroot/config.development.json index 58ce0f2f..8c7723c2 100644 --- a/Thermo.Active/wwwroot/config.development.json +++ b/Thermo.Active/wwwroot/config.development.json @@ -2,7 +2,7 @@ "env": "development", "api": { "enabled": true, - "apiServerUrl": "http://seriate.steamware.net:9000/" + "apiServerUrl": "http://localhost:9000/" }, "allUIVisible": true } \ No newline at end of file diff --git a/Thermo.Active/wwwroot/index.html b/Thermo.Active/wwwroot/index.html index dbc47d4e..ef830a90 100644 --- a/Thermo.Active/wwwroot/index.html +++ b/Thermo.Active/wwwroot/index.html @@ -13,7 +13,7 @@ - + diff --git a/Thermo.Active/wwwroot/package-lock.json b/Thermo.Active/wwwroot/package-lock.json index 63fbfb8b..db23e3fc 100644 --- a/Thermo.Active/wwwroot/package-lock.json +++ b/Thermo.Active/wwwroot/package-lock.json @@ -16304,11 +16304,6 @@ "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", "dev": true }, - "ts-debounce": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-2.0.1.tgz", - "integrity": "sha512-+TztZrH7GnAD5CKxUohIAqIVHLrtivsYT7tZCLeRTCaBMSsfgYwprhA00kB/m0ezvYheOXJQqPfarAvgoayb7A==" - }, "ts-loader": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-6.2.1.tgz", diff --git a/Thermo.Active/wwwroot/package.json b/Thermo.Active/wwwroot/package.json index 7cef66d3..1cc3a6c1 100644 --- a/Thermo.Active/wwwroot/package.json +++ b/Thermo.Active/wwwroot/package.json @@ -72,4 +72,4 @@ "last 2 versions", "not ie <= 8" ] -} \ No newline at end of file +}