Bozza gestione multi state machine con REDIS
This commit is contained in:
Generated
+17
-1
@@ -24938,7 +24938,7 @@ SELECT CodArticolo, DescArticolo, CurrRev, ProdRev, FlagIsNew FROM AnagArticoli
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "15.0.0.0")]
|
||||
private void InitCommandCollection() {
|
||||
this._commandCollection = new global::System.Data.SqlClient.SqlCommand[2];
|
||||
this._commandCollection = new global::System.Data.SqlClient.SqlCommand[3];
|
||||
this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
|
||||
this._commandCollection[0].Connection = this.Connection;
|
||||
this._commandCollection[0].CommandText = "dbo.stp_MSFD_getAll";
|
||||
@@ -24950,6 +24950,11 @@ SELECT CodArticolo, DescArticolo, CurrRev, ProdRev, FlagIsNew FROM AnagArticoli
|
||||
this._commandCollection[1].CommandType = global::System.Data.CommandType.StoredProcedure;
|
||||
this._commandCollection[1].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
|
||||
this._commandCollection[1].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
|
||||
this._commandCollection[2] = new global::System.Data.SqlClient.SqlCommand();
|
||||
this._commandCollection[2].Connection = this.Connection;
|
||||
this._commandCollection[2].CommandText = "dbo.stp_MSFD_getMulti";
|
||||
this._commandCollection[2].CommandType = global::System.Data.CommandType.StoredProcedure;
|
||||
this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
@@ -24992,6 +24997,17 @@ SELECT CodArticolo, DescArticolo, CurrRev, ProdRev, FlagIsNew FROM AnagArticoli
|
||||
this.Adapter.Fill(dataTable);
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "15.0.0.0")]
|
||||
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
|
||||
[global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)]
|
||||
public virtual DS_applicazione.MSFDDataTable getMulti() {
|
||||
this.Adapter.SelectCommand = this.CommandCollection[2];
|
||||
DS_applicazione.MSFDDataTable dataTable = new DS_applicazione.MSFDDataTable();
|
||||
this.Adapter.Fill(dataTable);
|
||||
return dataTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2385,6 +2385,16 @@ SELECT CodArticolo, DescArticolo, CurrRev, ProdRev, FlagIsNew FROM AnagArticoli
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
</DbSource>
|
||||
<DbSource ConnectionRef="MoonProConnectionString (Settings)" DbObjectName="Donati_MoonProLAV.dbo.stp_MSFD_getMulti" DbObjectType="StoredProcedure" GenerateMethods="Get" GenerateShortCommands="true" GeneratorGetMethodName="getMulti" GetMethodModifier="Public" GetMethodName="getMulti" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="getMulti" UserSourceName="getMulti">
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="StoredProcedure" ModifiedByUser="false">
|
||||
<CommandText>dbo.stp_MSFD_getMulti</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DataTypeServer="int" DbType="Int32" Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
</DbSource>
|
||||
</Sources>
|
||||
</TableAdapter>
|
||||
</Tables>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Changes to this file may cause incorrect behavior and will be lost if
|
||||
the code is regenerated.
|
||||
</autogenerated>-->
|
||||
<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="-10" ViewPortY="-28" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout">
|
||||
<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="-10" ViewPortY="-8" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout">
|
||||
<Shapes>
|
||||
<Shape ID="DesignTable:Macchine2FamiglieMacchine" ZOrder="17" X="553" Y="715" Height="135" Width="300" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="76" />
|
||||
<Shape ID="DesignTable:FamiglieMacchine" ZOrder="20" X="519" Y="1007" Height="135" Width="296" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="76" />
|
||||
@@ -29,7 +29,7 @@
|
||||
<Shape ID="DesignTable:ParetoDurate" ZOrder="10" X="5" Y="14" Height="227" Width="300" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="145" />
|
||||
<Shape ID="DesignTable:SignalLog" ZOrder="9" X="18" Y="523" Height="227" Width="237" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="168" />
|
||||
<Shape ID="DesignTable:AnagArticoli" ZOrder="13" X="627" Y="31" Height="204" Width="256" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="145" />
|
||||
<Shape ID="DesignTable:MSFD" ZOrder="1" X="974" Y="1361" Height="388" Width="234" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="306" />
|
||||
<Shape ID="DesignTable:MSFD" ZOrder="1" X="974" Y="1361" Height="411" Width="255" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="306" />
|
||||
</Shapes>
|
||||
<Connectors>
|
||||
<Connector ID="DesignRelation:FK_Macchine2FamiglieMacchine_FamiglieMacchine" ZOrder="44" LineWidth="11">
|
||||
|
||||
+86
-8
@@ -478,12 +478,13 @@ namespace MapoDb
|
||||
{
|
||||
// inizio preprocessing
|
||||
string newVal = "";
|
||||
// processo OGNI macchina a stati dell'impianto... (IdxMacchina e IdxMacchina#qualcosa...)
|
||||
//foreach(){ !!!FARE!!!
|
||||
newVal = preProcInput(idxMacchina, valore);
|
||||
// ora processo e salvo il valore del microstato... INTERNAMENTE gestisce i casi DB/REDIS secondo necessità
|
||||
connDb.checkMicroStato(idxMacchina, newVal, dataOraEvento, contatore);
|
||||
//}!!!FARE!!!
|
||||
// processo OGNI macchina a stati dell'impianto... (KEY: IdxMacchina / IdxMacchina#qualcosa, Val = IdxFamIn)
|
||||
foreach (var item in mTabMSMI(idxMacchina))
|
||||
{
|
||||
newVal = preProcInput(item.Key, valore);
|
||||
// ora processo e salvo il valore del microstato... INTERNAMENTE gestisce i casi DB/REDIS secondo necessità
|
||||
connDb.checkMicroStato(item.Key, newVal, dataOraEvento, contatore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -595,7 +596,7 @@ namespace MapoDb
|
||||
// effettuo eventuale esplosione in BIT esclusivi
|
||||
if (ExplodeBit)
|
||||
{
|
||||
newValInt = 1 << newValInt;
|
||||
newValInt = Convert.ToInt32(1 << newValInt);
|
||||
}
|
||||
// riconverto a STRING HEX!!!
|
||||
newVal = newValInt.ToString("X");
|
||||
@@ -637,6 +638,15 @@ namespace MapoDb
|
||||
{
|
||||
return mHash(string.Format("hSMI:{0}", idxFamIn));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati Macchine Multi SM Ingressi
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina">Macchina PRINCIPALE</param>
|
||||
/// <returns></returns>
|
||||
public static string hMSMI(string IdxMacchina)
|
||||
{
|
||||
return mHash(string.Format("hMSMI:{0}", IdxMacchina));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -855,6 +865,74 @@ namespace MapoDb
|
||||
|
||||
#region gestione State Machine Ingressi
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP
|
||||
/// key: IdxMacchina
|
||||
/// value: IdxFamigliaIngresso
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyValuePair<string, string>[] mTabMSMI(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[1];
|
||||
// iniziualizzo con un valore... 0/0
|
||||
answ[0] = new KeyValuePair<string, string>("0", "0");
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
string currHash = hMSMI(idxMacchina);
|
||||
answ = memLayer.ML.redGetHash(currHash);
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (answ.Length == 0)
|
||||
{
|
||||
answ = resetMSMI(idxMacchina);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in compilazione Tabella Multi State Machine Ingressi x Redis:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resetta (rileggendo) i dati della State Machine multi ingressi nel formato
|
||||
/// key: IdxMacchina
|
||||
/// value: IdxFamigliaIngresso
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyValuePair<string, string>[] resetMSMI(string idxMacchina)
|
||||
{
|
||||
string currHash = hMSMI(idxMacchina);
|
||||
DS_applicazione.MSFDDataTable tabMSMI = new DS_applicazione.MSFDDataTable();
|
||||
// 2017.09.13: inserisco gestione singleton condizionale
|
||||
if (memLayer.ML.CRB("disable_singleton"))
|
||||
{
|
||||
// instanzio un nuovo oggetto MapoDb
|
||||
MapoDb connDb = new MapoDb();
|
||||
tabMSMI = connDb.taMSFD.getMulti();
|
||||
}
|
||||
else
|
||||
{
|
||||
// leggo DB da singleton
|
||||
tabMSMI = MapoDb.obj.taMSFD.getMulti();
|
||||
}
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[tabMSMI.Count];
|
||||
// salvo tutti i valori StateMachineIngressi...
|
||||
int i = 0;
|
||||
foreach (var item in tabMSMI)
|
||||
{
|
||||
answ[i] = new KeyValuePair<string, string>(item.IdxMacchina, item.IdxFamigliaIngresso.ToString());
|
||||
i++;
|
||||
}
|
||||
// verifico il timeout (default 60 sec...)
|
||||
int tOut = (memLayer.ML.cdvi("TmOut.MSMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.MSMI");
|
||||
// salvo in redis!
|
||||
memLayer.ML.redSaveHash(currHash, answ, tOut);
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi della State Machine ingressi nel formato
|
||||
/// key: cState_nVal (current MICRO-STATE + "_" + new Value)
|
||||
@@ -920,7 +998,7 @@ namespace MapoDb
|
||||
answ[i] = new KeyValuePair<string, string>(key, val);
|
||||
i++;
|
||||
}
|
||||
// verifico il timeout (default 60 sec...
|
||||
// verifico il timeout (default 60 sec...)
|
||||
int tOut = (memLayer.ML.cdvi("TmOut.SMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.SMI");
|
||||
// salvo in redis!
|
||||
memLayer.ML.redSaveHash(currHash, answ, tOut);
|
||||
|
||||
Reference in New Issue
Block a user