pulizia generale
This commit is contained in:
@@ -22,9 +22,6 @@ namespace SMGen.Data
|
||||
|
||||
public int TotCount { get; set; } = 0;
|
||||
|
||||
public Dictionary<string, bool> FilesStatus { get; set; } = new Dictionary<string, bool>() ;
|
||||
public Dictionary<string, string> Files2Download { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
@@ -58,12 +55,6 @@ namespace SMGen.Data
|
||||
if (CurrPage != item.CurrPage)
|
||||
return false;
|
||||
|
||||
if (FilesStatus != item.FilesStatus)
|
||||
return false;
|
||||
|
||||
if (Files2Download != item.Files2Download)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace SMGen.Data.Services
|
||||
string line = "";
|
||||
while ((line = await sr.ReadLineAsync().ConfigureAwait(false)) != null)
|
||||
{
|
||||
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line))
|
||||
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line) && line.Length >= 3)
|
||||
{
|
||||
if (line.Contains("#"))
|
||||
{
|
||||
@@ -289,7 +289,7 @@ namespace SMGen.Data.Services
|
||||
return currFile;
|
||||
}
|
||||
/// <summary>
|
||||
/// Valuta un file di ruoles x ingressi 2 eventi e restituisce esito
|
||||
/// Valuta un file di ruoles x ingressi 2 Stati e restituisce esito
|
||||
/// </summary>
|
||||
/// <param name="currFile">Path file *.rul da processare</param>
|
||||
/// <param name="saveToDb">Indica se salvare sul DB</param>
|
||||
|
||||
@@ -51,16 +51,6 @@ namespace SMGen.Components
|
||||
get => currFilter.NumRec;
|
||||
set => currFilter.NumRec = value;
|
||||
}
|
||||
private Dictionary<string, bool> FilesStatus
|
||||
{
|
||||
get => currFilter.FilesStatus;
|
||||
set => currFilter.FilesStatus = value;
|
||||
}
|
||||
private Dictionary<string, string> Files2Download
|
||||
{
|
||||
get => currFilter.Files2Download;
|
||||
set => currFilter.Files2Download = value;
|
||||
}
|
||||
private int _totalCount { get; set; } = 0;
|
||||
private int totalCount
|
||||
{
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
<div>
|
||||
<InputFile OnChange="@LoadFiles" multiple />
|
||||
</div>
|
||||
<div>
|
||||
@if (Files.Count > 0)
|
||||
{
|
||||
<button @onclick="()=>Read_rule_file_transitions()">Process</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="false"></FilesList>
|
||||
|
||||
@@ -23,70 +23,25 @@ namespace SMGen.Pages
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected bool b_rules_definition { get; set; } = false;
|
||||
|
||||
protected bool calcEmptyState
|
||||
{
|
||||
get => conf.GetValue<bool>("SetupOptions:DoCalcEmptyState");
|
||||
}
|
||||
|
||||
protected bool calcItself
|
||||
{
|
||||
get => conf.GetValue<bool>("SetupOptions:DoCalcItself");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration conf { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IWebHostEnvironment env { get; set; } = null!;
|
||||
|
||||
protected List<string> Events_to_send { get; set; } = new List<string>();
|
||||
|
||||
protected List<AnagEventiModelTemp> events2Add { get; set; } = new List<AnagEventiModelTemp>();
|
||||
|
||||
protected List<string> fileLines { get; set; } = new List<string>();
|
||||
|
||||
protected Dictionary<string, string> files2Read { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
protected string n_state_machine_index { get; set; } = "";
|
||||
|
||||
protected int n_states { get; set; } = 0;
|
||||
|
||||
protected string pathDir { get; set; } = "";
|
||||
|
||||
protected string pathFile { get; set; } = "";
|
||||
|
||||
protected string procRootDir
|
||||
{
|
||||
get => conf.GetValue<string>("ServerConf:ProcCsvRootPath");
|
||||
}
|
||||
|
||||
protected List<RuleClass> Rules { get; set; } = new List<RuleClass>();
|
||||
protected Dictionary<string, FilesClass> Files { get; set; } = new Dictionary<string, FilesClass>();
|
||||
|
||||
[Inject]
|
||||
protected SMGDataService SMGDService { get; set; } = null!;
|
||||
|
||||
protected List<string> States2Rules { get; set; } = new List<string>();
|
||||
|
||||
protected Dictionary<string, int> StatesAll { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
protected Dictionary<string, int> StatesAll2 { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
protected string statiCsvPath
|
||||
{
|
||||
get => conf.GetValue<string>("ServerConf:StatiCsvPath");
|
||||
}
|
||||
|
||||
//protected string sz_file2Read { get; set; } = "D:\\Repo\\Mapo-IOB\\StateMachine\\_DEFAULT\\60_STD_MACHINE.rul";
|
||||
protected string sz_file2Read { get; set; } = "";
|
||||
|
||||
protected string sz_file2Write { get; set; } = "prova.csv";
|
||||
|
||||
protected string sz_state_machine_name { get; set; } = "";
|
||||
|
||||
protected List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -98,125 +53,6 @@ namespace SMGen.Pages
|
||||
await SMGDService.ExecFlushRedisPattern(Constants.FILES_TO_PROC);
|
||||
}
|
||||
|
||||
protected bool checkDirExist(string dir)
|
||||
{
|
||||
bool answ = false;
|
||||
var dirEx = Directory.Exists(dir);
|
||||
if (dirEx)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dirCreate = Directory.CreateDirectory(dir);
|
||||
if (dirCreate != null)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = false;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async void evaluate_transitions(string sz_file2Write, string origFileName)
|
||||
{
|
||||
TranInList2add.Clear();
|
||||
//events2Add.Clear();
|
||||
using (StreamWriter sw = new StreamWriter(sz_file2Write))
|
||||
{
|
||||
sw.WriteLine("IdxFamiglia;IdxStato;IdxTipo;next_IdxStato");
|
||||
int sz_actual_state = 0;
|
||||
string sz_line = "";
|
||||
|
||||
foreach (var item in States2Rules)
|
||||
{
|
||||
if (!StatesAll2.ContainsKey(item))
|
||||
{
|
||||
StatesAll2.Add(item, StatesAll[item]);
|
||||
StatesAll2 = StatesAll2.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
}
|
||||
|
||||
//ciclo negli stati
|
||||
try
|
||||
{
|
||||
foreach (var item in StatesAll2)
|
||||
{
|
||||
sz_actual_state = item.Value;
|
||||
|
||||
foreach (var act_rule in Rules)
|
||||
{
|
||||
var exitFor = false;
|
||||
if ((act_rule.state == "ALL_STATES") || (act_rule.state == StatesAll.Where(x => x.Value == sz_actual_state).FirstOrDefault().Key))
|
||||
{
|
||||
//DA RESETTARE A FALSE (errore da principianti...)
|
||||
|
||||
int nextState = StatesAll2[act_rule.next_state];
|
||||
|
||||
if (!exitFor)
|
||||
{
|
||||
sz_line = "";
|
||||
//eseguo solo se diverso dallo stato corrente
|
||||
// || calcItself
|
||||
if (nextState != item.Value || calcItself)
|
||||
{
|
||||
if (nextState < 0)
|
||||
{
|
||||
nextState = 0;
|
||||
}
|
||||
|
||||
if ((nextState == 0 && calcEmptyState) || (nextState > 0))
|
||||
{
|
||||
sz_line = $"{n_state_machine_index}" +
|
||||
$";" +
|
||||
$"{item.Value}" +
|
||||
$";" +
|
||||
$"{Events_to_send.IndexOf(act_rule.event_to_send)}" +
|
||||
$";" +
|
||||
$"{nextState}";
|
||||
|
||||
sw.WriteLine(sz_line);
|
||||
|
||||
var newTranIn = new TransizioneIngressiModelTemp()
|
||||
{
|
||||
IdxFamigliaIngresso = int.Parse(n_state_machine_index),
|
||||
IdxMicroStato = item.Value,
|
||||
IdxTipoEvento = Events_to_send.IndexOf(act_rule.event_to_send),
|
||||
next_IdxMicroStato = nextState
|
||||
};
|
||||
|
||||
TranInList2add.Add(newTranIn);
|
||||
}
|
||||
}
|
||||
exitFor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//await SMGDService.AnagEventinInsert(events2Add);
|
||||
await Task.Delay(1);
|
||||
Files[origFileName].isOk = true;
|
||||
Files[origFileName].DLoadFileName = sz_file2Write;
|
||||
|
||||
await SMGDService.FileUpdate(origFileName, Files[origFileName]);
|
||||
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
// await SMGDService.TranInInsert(TranInList2add, int.Parse(n_state_machine_index));
|
||||
|
||||
//files2Download.Add(origFileName, sz_file2Write);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Files[origFileName].isOk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
@@ -239,100 +75,6 @@ namespace SMGen.Pages
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task Read_rule_file_transitions()
|
||||
{
|
||||
//files2Read = await SMGDService.FilesGetAll();
|
||||
|
||||
Files = await SMGDService.FilesGetAll();
|
||||
|
||||
foreach (var item in Files)
|
||||
{
|
||||
sz_file2Read = item.Value.tempFileName;
|
||||
|
||||
using (StreamReader sr = new StreamReader(sz_file2Read))
|
||||
{
|
||||
StatesAll.Clear();
|
||||
Events_to_send.Clear();
|
||||
Rules.Clear();
|
||||
string line = "";
|
||||
while ((line = await sr.ReadLineAsync().ConfigureAwait(false)) != null)
|
||||
{
|
||||
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line))
|
||||
{
|
||||
if (line.Contains("#"))
|
||||
{
|
||||
var lineSplit = line.Split("#");
|
||||
line = lineSplit[0];
|
||||
}
|
||||
var sz_tokens = line.Split(":");
|
||||
|
||||
var sz_temp = sz_tokens[0].Trim();
|
||||
switch (sz_temp)
|
||||
{
|
||||
case "$DEFINITIONS":
|
||||
b_rules_definition = false;
|
||||
break;
|
||||
|
||||
case "$NAME":
|
||||
sz_state_machine_name = sz_tokens[1].Trim();
|
||||
break;
|
||||
|
||||
case "$IDX":
|
||||
n_state_machine_index = sz_tokens[1].Trim();
|
||||
break;
|
||||
|
||||
case "$STATE":
|
||||
StatesAll.Add(sz_tokens[2].Trim().ToUpper(), int.Parse(sz_tokens[1].Trim().ToUpper()));
|
||||
break;
|
||||
|
||||
case "$EVENT":
|
||||
Events_to_send.Add(sz_tokens[2].Trim().ToUpper());
|
||||
var newEvent = new AnagEventiModelTemp()
|
||||
{
|
||||
IdxTipo = int.Parse(sz_tokens[1].Trim().ToUpper()),
|
||||
Nome = sz_tokens[2].Trim().ToUpper()
|
||||
};
|
||||
|
||||
events2Add.Add(newEvent);
|
||||
break;
|
||||
|
||||
case "$RULES":
|
||||
b_rules_definition = true;
|
||||
break;
|
||||
|
||||
case "$DO":
|
||||
b_rules_definition = false;
|
||||
var isOk = checkDirExist(Path.Combine(procRootDir, statiCsvPath));
|
||||
if (isOk)
|
||||
{
|
||||
var fileName = $"{item.Key.Split(".")[0]}.csv";
|
||||
evaluate_transitions($"{Path.Combine(procRootDir, statiCsvPath, fileName)}", item.Key);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (b_rules_definition)
|
||||
{
|
||||
var state = sz_temp.Trim().ToUpper();
|
||||
var event_to_send = sz_tokens[1].Trim().ToUpper();
|
||||
var next_state = sz_tokens[2].Trim().ToUpper();
|
||||
|
||||
var temp_rule = new RuleClass()
|
||||
{
|
||||
state = state,
|
||||
event_to_send = event_to_send,
|
||||
next_state = next_state
|
||||
};
|
||||
Rules.Add(temp_rule);
|
||||
States2Rules.Add(next_state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task updateFilter(SelectSMIn2EvParams newParams)
|
||||
{
|
||||
@@ -359,18 +101,6 @@ namespace SMGen.Pages
|
||||
set => currFilter.CurrPage = value;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> files2Download
|
||||
{
|
||||
get => currFilter.Files2Download;
|
||||
set => currFilter.Files2Download = value;
|
||||
}
|
||||
|
||||
private Dictionary<string, bool> filesStatus
|
||||
{
|
||||
get => currFilter.FilesStatus;
|
||||
set => currFilter.FilesStatus = value;
|
||||
}
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get => currFilter.NumRec;
|
||||
@@ -413,8 +143,6 @@ namespace SMGen.Pages
|
||||
long maxFileSize = 1024 * 50;
|
||||
int maxAllowedFiles = 150;
|
||||
loadedFiles.Clear();
|
||||
filesStatus.Clear();
|
||||
files2Read.Clear();
|
||||
|
||||
foreach (var file in e.GetMultipleFiles(maxAllowedFiles))
|
||||
{
|
||||
|
||||
@@ -24,12 +24,6 @@
|
||||
<div>
|
||||
<InputFile OnChange="@LoadFiles" multiple />
|
||||
</div>
|
||||
<div>
|
||||
@if (Files.Count > 0)
|
||||
{
|
||||
<button @onclick="()=>Read_rule_file_transitions()">Process</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="true"></FilesList>
|
||||
|
||||
@@ -24,13 +24,6 @@ namespace SMGen.Pages
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected bool b_rules_definition { get; set; } = false;
|
||||
|
||||
protected string bitCsvPath
|
||||
{
|
||||
get => conf.GetValue<string>("ServerConf:BitCsvPath");
|
||||
}
|
||||
|
||||
protected List<string> Bits { get; set; } = new List<string>();
|
||||
|
||||
protected string circleCssColor
|
||||
@@ -60,207 +53,21 @@ namespace SMGen.Pages
|
||||
[Inject]
|
||||
protected IWebHostEnvironment env { get; set; } = null!;
|
||||
|
||||
protected List<string> Events_to_send { get; set; } = new List<string>();
|
||||
protected List<AnagEventiModelTemp> events2Add { get; set; } = new List<AnagEventiModelTemp>();
|
||||
protected List<string> fileLines { get; set; } = new List<string>();
|
||||
protected Dictionary<string, FilesClass> Files { get; set; } = new Dictionary<string, FilesClass>();
|
||||
protected Dictionary<string, string> files2Read { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
protected int maxAllowedFiles { get; set; } = 100;
|
||||
protected int n_bits { get; set; } = 0;
|
||||
|
||||
protected string n_state_machine_index { get; set; } = "";
|
||||
|
||||
protected int n_states { get; set; } = 0;
|
||||
|
||||
protected string pathDir { get; set; } = "";
|
||||
|
||||
protected string pathFile { get; set; } = "";
|
||||
|
||||
protected string procRootDir
|
||||
{
|
||||
get => conf.GetValue<string>("ServerConf:ProcCsvRootPath");
|
||||
}
|
||||
|
||||
protected List<RuleClass> Rules { get; set; } = new List<RuleClass>();
|
||||
|
||||
[Inject]
|
||||
protected SMGDataService SMGDService { get; set; } = null!;
|
||||
|
||||
//protected Dictionary<string, string> files2Download { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
protected List<string> States { get; set; } = new List<string>();
|
||||
|
||||
//protected string sz_file2Read { get; set; } = "D:\\Repo\\Mapo-IOB\\StateMachine\\_DEFAULT\\60_STD_MACHINE.rul";
|
||||
protected string sz_file2Read { get; set; } = "";
|
||||
|
||||
protected string sz_file2Write { get; set; } = "prova.csv";
|
||||
|
||||
protected string sz_state_machine_name { get; set; } = "";
|
||||
protected List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected bool checkDirExist(string dir)
|
||||
{
|
||||
bool answ = false;
|
||||
var dirEx = Directory.Exists(dir);
|
||||
if (dirEx)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dirCreate = Directory.CreateDirectory(dir);
|
||||
if (dirCreate != null)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = false;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async Task evaluate_transitions(string sz_file2Write, string origFileName)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
|
||||
TranInList2add.Clear();
|
||||
//events2Add.Clear();
|
||||
|
||||
if (File.Exists(sz_file2Write))
|
||||
{
|
||||
File.Delete(sz_file2Write);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("IdxFamigliaIngresso;IdxMicroStato;ValoreIngresso;IdxTipoEvento;next_IdxMicroStato");
|
||||
string sz_actual_state = "";
|
||||
string sz_actual_bit = "";
|
||||
string sz_line = "";
|
||||
//int i = 0;
|
||||
int n_input = 0;
|
||||
//int n = 0;
|
||||
int n_mask = 0;
|
||||
int n_bit = 0;
|
||||
|
||||
bool[] b_bit = new bool[20];
|
||||
bool b_invert = false;
|
||||
//ciclo negli stati
|
||||
try
|
||||
{
|
||||
for (var i = 0; i <= n_states - 1; i++)
|
||||
{
|
||||
sz_actual_state = States.ToArray()[i];
|
||||
|
||||
//ciclo negli ingressi
|
||||
for (n_input = 0; n_input <= (Math.Pow(2, n_bits) - 1); n_input++)
|
||||
{
|
||||
n_mask = 1;
|
||||
for (var n = 0; n <= n_bits - 1; n++)
|
||||
{
|
||||
b_bit[n] = Convert.ToBoolean(n_input & n_mask);
|
||||
n_mask = n_mask << 1;
|
||||
}
|
||||
|
||||
var exitFor = false;
|
||||
|
||||
foreach (var act_rule in Rules)
|
||||
{
|
||||
n_bit = -1;
|
||||
if ((act_rule.state == "ALL_STATES") || (act_rule.state == sz_actual_state))
|
||||
{
|
||||
//DA RESETTARE A FALSE (errore da principianti...)
|
||||
b_invert = false;
|
||||
|
||||
sz_actual_bit = act_rule.expression;
|
||||
|
||||
//controllo se la riga contiene l'istruzione per negare il bit
|
||||
if (sz_actual_bit.Trim().StartsWith("NOT"))
|
||||
{
|
||||
//inverto il bit
|
||||
b_invert = true;
|
||||
sz_actual_bit = sz_actual_bit.Replace("NOT ", "").Trim();
|
||||
}
|
||||
//cerca il nome del bit e ne trova l' indice da 0
|
||||
n_bit = Bits.FindIndex(x => x == sz_actual_bit);
|
||||
|
||||
if (n_bit == -1)
|
||||
{
|
||||
exitFor = true;
|
||||
}
|
||||
|
||||
int nextState = States.IndexOf(act_rule.next_state);
|
||||
|
||||
if (!exitFor)
|
||||
{
|
||||
if (((!b_invert) && b_bit[n_bit]) || (b_invert && (!b_bit[n_bit])))
|
||||
{
|
||||
sz_line = "";
|
||||
//eseguo solo se diverso dallo stato corrente
|
||||
if (States.IndexOf(act_rule.next_state) != i)
|
||||
{
|
||||
if (nextState < 0)
|
||||
{
|
||||
nextState = 0;
|
||||
}
|
||||
|
||||
sz_line = $"{n_state_machine_index}" +
|
||||
$";" +
|
||||
$"{i}" +
|
||||
$";" +
|
||||
$"{n_input}" +
|
||||
$";" +
|
||||
$"{Events_to_send.IndexOf(act_rule.event_to_send)}" +
|
||||
$";" +
|
||||
$"{nextState}";
|
||||
|
||||
sb.AppendLine(sz_line);
|
||||
|
||||
var newTranIn = new TransizioneIngressiModelTemp()
|
||||
{
|
||||
IdxFamigliaIngresso = int.Parse(n_state_machine_index),
|
||||
IdxMicroStato = i,
|
||||
ValoreIngresso = n_input,
|
||||
IdxTipoEvento = Events_to_send.IndexOf(act_rule.event_to_send),
|
||||
next_IdxMicroStato = States.IndexOf(act_rule.next_state)
|
||||
};
|
||||
|
||||
TranInList2add.Add(newTranIn);
|
||||
}
|
||||
exitFor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(sz_file2Write))
|
||||
{
|
||||
sw.Write(sb.ToString());
|
||||
}
|
||||
await Task.Delay(1);
|
||||
Files[origFileName].isOk = true;
|
||||
Files[origFileName].DLoadFileName = sz_file2Write;
|
||||
|
||||
await SMGDService.FileUpdate(origFileName, Files[origFileName]);
|
||||
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Files[origFileName].isOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
@@ -277,6 +84,7 @@ namespace SMGen.Pages
|
||||
await SMGDService.ExecFlushRedisPattern(Constants.FILES_TO_PROC);
|
||||
}
|
||||
|
||||
|
||||
protected async Task pgResetReq(bool doReset)
|
||||
{
|
||||
if (doReset)
|
||||
@@ -288,126 +96,6 @@ namespace SMGen.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task Read_rule_file_transitions()
|
||||
{
|
||||
Files = await SMGDService.FilesGetAll();
|
||||
foreach (var item in Files)
|
||||
{
|
||||
//await Task.Delay(10);
|
||||
sz_state_machine_name = "";
|
||||
n_state_machine_index = "";
|
||||
n_states = 0;
|
||||
n_bits = 0;
|
||||
States.Clear();
|
||||
Bits.Clear();
|
||||
Events_to_send.Clear();
|
||||
Rules.Clear();
|
||||
sz_file2Read = item.Value.tempFileName;
|
||||
|
||||
using (StreamReader sr = new StreamReader(sz_file2Read))
|
||||
{
|
||||
string line = "";
|
||||
while ((line = await sr.ReadLineAsync().ConfigureAwait(false)) != null)
|
||||
{
|
||||
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line))
|
||||
{
|
||||
if (line.Contains("#"))
|
||||
{
|
||||
var lineSplit = line.Split("#");
|
||||
line = lineSplit[0];
|
||||
}
|
||||
|
||||
var sz_tokens = line.Split(":");
|
||||
|
||||
var sz_temp = sz_tokens[0].Trim();
|
||||
switch (sz_temp)
|
||||
{
|
||||
case "$DEFINITIONS":
|
||||
b_rules_definition = false;
|
||||
break;
|
||||
|
||||
case "$NAME":
|
||||
sz_state_machine_name = sz_tokens[1].Trim();
|
||||
break;
|
||||
|
||||
case "$IDX":
|
||||
n_state_machine_index = sz_tokens[1].Trim();
|
||||
break;
|
||||
|
||||
case "$N_STATES":
|
||||
n_states = int.Parse(sz_tokens[1].Trim());
|
||||
break;
|
||||
|
||||
case "$N_BITS":
|
||||
n_bits = int.Parse(sz_tokens[1].Trim());
|
||||
break;
|
||||
|
||||
case "$BIT":
|
||||
Bits.Add(sz_tokens[2].Trim().ToUpper());
|
||||
break;
|
||||
|
||||
case "$STATE":
|
||||
States.Add(sz_tokens[2].Trim().ToUpper());
|
||||
break;
|
||||
|
||||
case "$EVENT":
|
||||
Events_to_send.Add(sz_tokens[2].Trim().ToUpper());
|
||||
var newEvent = new AnagEventiModelTemp()
|
||||
{
|
||||
IdxTipo = int.Parse(sz_tokens[1].Trim().ToUpper()),
|
||||
Nome = sz_tokens[2].Trim().ToUpper()
|
||||
};
|
||||
|
||||
events2Add.Add(newEvent);
|
||||
break;
|
||||
|
||||
case "$RULES":
|
||||
b_rules_definition = true;
|
||||
break;
|
||||
|
||||
case "$DO":
|
||||
b_rules_definition = false;
|
||||
var isOk = checkDirExist(procRootDir);
|
||||
if (isOk)
|
||||
{
|
||||
var fileName = $"{item.Key.Split(".")[0]}.csv";
|
||||
evaluate_transitions($"{Path.Combine(procRootDir, bitCsvPath, fileName)}", item.Key);
|
||||
await SMGDService.AnagEventinInsert(events2Add);
|
||||
await Task.Delay(1);
|
||||
filesStatus[item.Key] = await SMGDService.TranInInsert(TranInList2add, int.Parse(n_state_machine_index));
|
||||
|
||||
if (!files2Download.ContainsKey(item.Key))
|
||||
{
|
||||
files2Download.Add(item.Key, sz_file2Write);
|
||||
}
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (b_rules_definition)
|
||||
{
|
||||
var temp_rule = new RuleClass()
|
||||
{
|
||||
state = sz_temp.Trim().ToUpper(),
|
||||
expression = sz_tokens[1].Trim().ToUpper(),
|
||||
next_state = sz_tokens[2].Trim().ToUpper(),
|
||||
event_to_send = sz_tokens[3].Trim().ToUpper()
|
||||
};
|
||||
|
||||
Rules.Add(temp_rule);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//fileLines.Add(lineSplit[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task updateFilter(SelectSMIn2EvParams newParams)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
@@ -433,19 +121,6 @@ namespace SMGen.Pages
|
||||
set => currFilter.CurrPage = value;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> files2Download
|
||||
{
|
||||
get => currFilter.Files2Download;
|
||||
set => currFilter.Files2Download = value;
|
||||
}
|
||||
|
||||
//protected Dictionary<string, bool> filesStatus { get; set; } = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> filesStatus
|
||||
{
|
||||
get => currFilter.FilesStatus;
|
||||
set => currFilter.FilesStatus = value;
|
||||
}
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get => currFilter.NumRec;
|
||||
@@ -487,8 +162,6 @@ namespace SMGen.Pages
|
||||
List<IBrowserFile> loadedFiles = new();
|
||||
long maxFileSize = 1024 * 1024;
|
||||
loadedFiles.Clear();
|
||||
filesStatus.Clear();
|
||||
files2Read.Clear();
|
||||
Files.Clear();
|
||||
|
||||
foreach (var file in e.GetMultipleFiles(maxAllowedFiles))
|
||||
|
||||
Reference in New Issue
Block a user