Start update for signal-r THERMO management

This commit is contained in:
Samuele Locatelli
2020-05-15 18:38:49 +02:00
parent f9586ce949
commit 426eaeea95
6 changed files with 167 additions and 63 deletions
Binary file not shown.
+6 -1
View File
@@ -263,7 +263,12 @@ namespace Thermo.Active.Model
public const string SEND_QUEUE_DATA = "SEND_QUEUE_DATA";
public const string SEND_M155_DATA = "SEND_M155_DATA";
public const string SEND_SCADA_DATA = "SEND_SCADA_DATA";
public const string SEND_RECIPE_STATUS = "SEND_RECIPE_STATUS";
// MVVM Messages for Thermo active specs
public const string SEND_THERMO_RECIPE_FULL = "SEND_THERMO_RECIPE_FULL";
public const string SEND_THERMO_RECIPE_OVERWIEW = "SEND_THERMO_RECIPE_OVERWIEW";
public const string SEND_THERMO_MODULE_DATA = "SEND_THERMO_MODULE_DATA";
public const string SEND_THERMO_WARMERS_DATA = "SEND_THERMO_WARMERS_DATA";
public const string BROADCAST_DATA = "BROADCAST_DATA";
+58 -44
View File
@@ -4,6 +4,7 @@ using CMS_CORE_Library.Fanuc;
using CMS_CORE_Library.Models;
using CMS_CORE_Library.Osai;
using CMS_CORE_Library.Siemens;
using CMS_CORE_Library.S7Net;
using Thermo.Active.Database.Controllers;
using Thermo.Active.Model.DatabaseModels;
using Thermo.Active.Model.DTOModels;
@@ -27,6 +28,11 @@ namespace Thermo.Active.NC
{
public class NcAdapter : IDisposable
{
/// <summary>
/// check e usare dati simulati/reali (in fase implementazione)
/// </summary>
public bool simData = true;
public Nc numericalControl;
public NcAdapter() =>
@@ -69,6 +75,9 @@ namespace Thermo.Active.NC
case NC_VENDOR.OSAI:
return new Nc_Osai(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
case NC_VENDOR.SIEMENS_S7:
return new Nc_S7Net(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
}
return null;
@@ -1413,7 +1422,7 @@ namespace Thermo.Active.NC
}
/// <summary>
/// Legge tutti i parametri della ricetta
/// Legge tutti i parametri della ricetta
/// </summary>
/// <param name="currRecipe">Oggetto ricetta corrente HMI</param>
/// <returns></returns>
@@ -1426,54 +1435,59 @@ namespace Thermo.Active.NC
RPRange currRange = new RPRange();
RPStatus currStatus = new RPStatus();
// !!!FARE davvero!!!
if (simData)
{
// leggo l'intero array delle DB... QUI FAKE sulle DB configurate...
List<DTORecipeConfigModel> recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel()
{
Id = x.Id,
Category = x.Category.ToString(),
SubCategory_1 = x.SubCategory_1,
SubCategory_2 = x.SubCategory_2,
Name = x.Name,
Description = x.Description,
Format = x.Format,
Label = $"{x.Category}_{x.SubCategory_1}_{x.SubCategory_2}_{x.Name}".Replace("__", "_").Replace("__", "_").ToLower()
}).ToList();
int minVal, maxVal, actVal;
Random rnd = new Random();
foreach (var item in recipeConfig)
{
// randomizzo valori...
minVal = rnd.Next(0, 10);
maxVal = rnd.Next(100, 200);
actVal = rnd.Next(minVal - 5, maxVal + 5);
currRange = new RPRange()
{
Min = minVal,
Max = maxVal,
};
currStatus = new RPStatus()
{
Visible = true,
Enabled = true,
HasError = (actVal < minVal || actVal > maxVal)
};
currParam = new DTORecipeParam()
{
Range = currRange,
Status = currStatus,
UnitMeasure = "",
ValueAct = actVal
};
currRecipe.Add(item.Label, currParam);
}
}
else
{
// FIXME
#if false
// gestione errore
cmsError = ReadScadaData(schema, out currParam);
if (cmsError.IsError())
return cmsError;
#endif
// leggo l'intero array delle DB... QUI FAKE sulle DB configurate...
List<DTORecipeConfigModel> recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel()
{
Id = x.Id,
Category = x.Category.ToString(),
SubCategory_1 = x.SubCategory_1,
SubCategory_2 = x.SubCategory_2,
Name = x.Name,
Description = x.Description,
Format = x.Format,
Label = $"{x.Category}_{x.SubCategory_1}_{x.SubCategory_2}_{x.Name}".Replace("__", "_").Replace("__", "_").ToLower()
}).ToList();
int minVal, maxVal, actVal;
Random rnd = new Random();
foreach (var item in recipeConfig)
{
// randomizzo valori...
minVal = rnd.Next(0, 10);
maxVal = rnd.Next(100, 200);
actVal = rnd.Next(minVal - 5, maxVal + 5);
currRange = new RPRange()
{
Min = minVal,
Max = maxVal,
};
currStatus = new RPStatus()
{
Visible = true,
Enabled = true,
HasError = (actVal < minVal || actVal > maxVal)
};
currParam = new DTORecipeParam()
{
Range = currRange,
Status = currStatus,
UnitMeasure = "",
ValueAct = actVal
};
currRecipe.Add(item.Label, currParam);
}
// restituisco cod errore se trovato
@@ -1482,7 +1496,7 @@ namespace Thermo.Active.NC
/// <summary>
/// Legge tutti i parametri della ricetta e calcolo la overview dei vari steps
/// Legge tutti i parametri della ricetta e calcolo la overview dei vari steps
/// </summary>
/// <param name="currOverview">Oggetto overview ricetta corrente HMI</param>
/// <returns></returns>
+20 -4
View File
@@ -90,10 +90,26 @@ namespace Thermo.Active.Listeners
infos.Add(MessageServices.Current.Subscribe(SEND_CMSCONNECT_GW_REBOOT_STATUS, (a, b) =>
{
SignalRListener.SetGatewayRebootStatus(a);
}));
}));
// add specific modules for THERMO
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_RECIPE_FULL, (a, b) =>
{
SignalRListener.SendThermoRecipeFullData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_RECIPE_OVERWIEW, (a, b) =>
{
SignalRListener.SendThermoRecipeOverviewData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_MODULE_DATA, (a, b) =>
{
SignalRListener.SendThermoModulesData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_WARMERS_DATA, (a, b) =>
{
SignalRListener.SendThermoWarmersData(a);
}));
//////////////////////////// Database
///// erano tooling...
// Broadcast
infos.Add(MessageServices.Current.Subscribe(BROADCAST_DATA, (a, b) =>
@@ -103,7 +119,7 @@ namespace Thermo.Active.Listeners
SignalRListener.BroadcastData();
}));
}
public static void Stop()
{
MessageServices.Current.UnSubscribe(infos.ToArray());
@@ -14,6 +14,7 @@ using System.Threading;
using static Thermo.Active.Listeners.SignalRStaticObjects;
using static Thermo.Active.Model.Constants;
using static Thermo.Active.Config.ServerConfig;
using Thermo.Active.Model.DTOModels.Recipe;
namespace Thermo.Active.Listeners.SignalR
{
@@ -249,6 +250,61 @@ namespace Thermo.Active.Listeners.SignalR
}
}
public static void SendThermoRecipeFullData(object recipeFull)
{
Dictionary<string, DTORecipeParam> currRecipeFull = recipeFull as Dictionary<string, DTORecipeParam>;
// FIXME TODO: usare un foreach comparer?
if (!LastRecipeFullData.SequenceEqual(currRecipeFull))
{
LastRecipeFullData = currRecipeFull;
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.Group("ncData").recipeFullData(currRecipeFull);
}
}
public static void SendThermoRecipeOverviewData(object recipeOver)
{
Dictionary<string, RecipeCatStatus> currRecipeOver = recipeOver as Dictionary<string, RecipeCatStatus>;
if (!LastRecipeOverData.SequenceEqual(currRecipeOver))
{
LastRecipeOverData = currRecipeOver;
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.Group("ncData").recipeOverData(currRecipeOver);
}
}
public static void SendThermoModulesData(object modules)
{
Dictionary<string, DTORecipeParam> currModules = modules as Dictionary<string, DTORecipeParam>;
// FIXME TODO: usare un foreach comparer?
if (!LastRecipeFullData.SequenceEqual(currModules))
{
LastRecipeFullData = currModules;
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.Group("ncData").recipeModulesData(currModules);
}
}
public static void SendThermoWarmersData(object warmers)
{
Dictionary<string, DTORecipeParam> currWarmers = warmers as Dictionary<string, DTORecipeParam>;
// FIXME TODO: usare un foreach comparer?
if (!LastRecipeFullData.SequenceEqual(currWarmers))
{
LastRecipeFullData = currWarmers;
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.Group("ncData").recipeWarmersData(currWarmers);
}
}
public static void SetGatewayRebootStatus(object status)
{
string msg = status.ToString();
@@ -286,32 +342,40 @@ namespace Thermo.Active.Listeners.SignalR
group.expiredMaintenances(LastExpiredMaintenances);
// Send nc status
context.Clients.Group("ncData").ncNetworkStatus(
group.ncNetworkStatus(
new
{
connected = LastIsNcConnected
});
// Send softkeys Nc
context.Clients.Group("ncData").ncSoftKeys(LastNcSoftKeysData);
group.ncSoftKeys(LastNcSoftKeysData);
// Send user softKeys
context.Clients.Group("ncData").userSoftKeys(LastUserSoftKeysData);
group.userSoftKeys(LastUserSoftKeysData);
// Send heads data
context.Clients.Group("ncData").headsData(LastHeadsData);
group.headsData(LastHeadsData);
// Send axesNames data
context.Clients.Group("ncData").axesNames(LastAxesNamesData);
group.axesNames(LastAxesNamesData);
// Send positions
context.Clients.Group("ncData").axesPositions(LastAxesPositions);
group.axesPositions(LastAxesPositions);
// Send active program data
context.Clients.Group("ncData").activeProgramData(LastProgramData);
group.activeProgramData(LastProgramData);
// Send magazine is active data
context.Clients.Group("ncData").magazineIsActive(LastNcMagazineIsActive);
group.magazineIsActive(LastNcMagazineIsActive);
// Send PP Queue
context.Clients.Group("ncData").partProgramQueue(LastPartProgramQueue);
group.partProgramQueue(LastPartProgramQueue);
// Send m155 data
context.Clients.Group("ncData").m155Data(LastM155Data);
group.m155Data(LastM155Data);
// Send Scada
context.Clients.Group("ncData").scadaData(LastScadaData);
group.scadaData(LastScadaData);
// Send THERMO Recipe data
group.recipeFullData(LastRecipeFullData);
group.recipeOverData(LastRecipeOverData);
// Send THERMO Modules data
group.recipeModulesData(LastModulesData);
// Send THERMO Warmers data
group.recipeWarmersData(LastWarmersData);
Debug.WriteLine(string.Format("{0} {1} Broadcast..completed", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), DateTime.Now.Millisecond));
Monitor.Exit(_broadcastlock);
@@ -2,6 +2,7 @@
using Thermo.Active.Model.DTOModels.AlarmModels;
using Thermo.Active.Model.DTOModels.Scada;
using System.Collections.Generic;
using Thermo.Active.Model.DTOModels.Recipe;
namespace Thermo.Active.Listeners
{
@@ -23,11 +24,15 @@ namespace Thermo.Active.Listeners
public static Dictionary<int, bool> LastNcMagazineIsActive = new Dictionary<int, bool>();
public static List<DTOQueueModel> LastPartProgramQueue = new List<DTOQueueModel>();
public static List<DTOM155InputModel> LastM155Data = new List<DTOM155InputModel>();
public static List<DTOScadaModel> LastScadaData = new List<DTOScadaModel>();
public static List<DTOScadaModel> LastScadaData = new List<DTOScadaModel>();
// FIXME TODO inserire oggetti corretti per THERMO
public static Dictionary<string, DTORecipeParam> LastRecipeFullData = new Dictionary<string, DTORecipeParam>();
public static Dictionary<string, RecipeCatStatus> LastRecipeOverData = new Dictionary<string, RecipeCatStatus>();
public static List<DTOScadaModel> LastModulesData = new List<DTOScadaModel>();
public static List<DTOScadaModel> LastWarmersData = new List<DTOScadaModel>();
public static bool LastIsNcConnected = false;
// aggiugere oggetti nuovi e levare quelli che non servono +...
}
}