Fix COnnect startup

This commit is contained in:
Samuele E. Locatelli
2020-10-20 19:03:32 +02:00
parent 946ce23f6f
commit e3df06bb08
8 changed files with 26 additions and 15 deletions
+2
View File
@@ -66,6 +66,8 @@ namespace Thermo.Active.Config
public static List<RiskBoardModel> RiskBoardConfig;
public static List<AxesConfigModel> AxesConfig;
public static Dictionary<string,string> CMSConnectEntry;
public static string CMSConnectDataModel;
}
@@ -297,6 +297,7 @@ namespace Thermo.Active.Config
XElement el = xmlConfigFile.Descendants("Machine").First();
CMSConnectEntry = new Dictionary<string, string>();
ElaborateDataModel(el,el.Name.LocalName, ref CMSConnectEntry);
CMSConnectDataModel = File.ReadAllText(CONNECT_DATAMODEL_CONFIG_PATH);
}
private static void ElaborateDataModel(XElement el, string Parent, ref Dictionary<string, string> Paths)
+5 -1
View File
@@ -1140,8 +1140,12 @@ public static class ThreadsFunctions
NcAdapter ncAdapter = new NcAdapter();
try
{
//Write all the datamodel
if (!RedisController.WriteDatamodel(CMSConnectDataModel))
ManageError(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE);
//Write all the default Entry
//Write all the default entries
if (!RedisController.WriteDefaultEntry(CMSConnectEntry))
ManageError(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE);
-8
View File
@@ -38,7 +38,6 @@ namespace Thermo.Active.Core
ThreadsFunctions.ReadM154Data // levare?
};
private static Action ThreadSetupCmsConnect = ThreadsFunctions.SetupCmsConnect;
private volatile static List<Thread> RunningThreadsList = new List<Thread>();
public static Thread StartClient;
@@ -48,13 +47,6 @@ namespace Thermo.Active.Core
public static void Start()
{
ThreadsFunctions.RestoreConnection();
if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady)
{
Thread t = new Thread(() => ThreadSetupCmsConnect());
t.Start();
Thread.Sleep(30);
}
}
public static void StartWorkers()
@@ -22,7 +22,8 @@ namespace Thermo.Active.Database.Controllers
private const string alarmsPath = "Machine:Plc:Condition";
private const string processStatusPath = "Machine:Cnc:CncProcesses:%NN%:Status";
private const string processModePath = "Machine:Cnc:CncProcesses:%NN%:Mode";
private const string datamodelPath = "TODO";
public static void WriteProductionNotification(uint ProductionProcess, string Notification)
{
string redisHash = redUtil.man.redHash(redisNotificationAddress).Replace("%NN%", ProductionProcess.ToString("00"));
@@ -58,8 +59,13 @@ namespace Thermo.Active.Database.Controllers
string redisHash = redUtil.man.redHash(redisAlmEn);
return redUtil.man.redSaveHashDict(redisHash, alarms);
}
public static bool WriteDatamodel(string datamodel)
{
string redisHash = redUtil.man.redHash(datamodelPath);
return redUtil.man.setRSV(redisHash, datamodel.ToString());
}
public static bool WriteDefaultEntry(Dictionary<string, string> entries)
{
foreach (KeyValuePair<string,string> entry in entries)
+5
View File
@@ -772,6 +772,11 @@ namespace Thermo.Active.NC
Directory.CreateDirectory(dir);
}
File.WriteAllText(LIVE_RECIPE_PATH, rawData);
if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady)
{
RedisController.WriteProductionName(1, RecipeLiveData.RecipeName);
}
answ = true;
}
catch
@@ -307,10 +307,6 @@ namespace Thermo.Active.Listeners.SignalR
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.Group("ncData").recipeChangedData(currMessage);
if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady)
{
RedisController.WriteProductionName(1,currMessage.recipeName);
}
}
}
+5
View File
@@ -84,6 +84,11 @@ namespace Thermo.Active
if (!string.IsNullOrWhiteSpace(ServerStartupConfig.ServerAddress.ToString()))
opt.Urls.Add("http://" + ServerStartupConfig.ServerAddress.ToString() + ":" + ServerStartupConfig.ServerPort.ToString());
if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady)
{
ThreadsFunctions.SetupCmsConnect();
}
// read and save last CURRENT RECIPE data...
NcFileAdapter.ReadLastRecipe();
RecipeController.WriteCurrentRecipeToPlc();