fix return sui for necessari e reset variabile controllo inversione bit
This commit is contained in:
@@ -121,6 +121,7 @@ namespace SMGen.Pages
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(sz_file2Write))
|
||||
{
|
||||
sw.WriteLine("IdxFamigliaIngresso;IdxMicroStato;ValoreIngresso;IdxTipoEvento;next_IdxMicroStato");
|
||||
string sz_actual_state = "";
|
||||
string sz_actual_bit = "";
|
||||
string sz_line = "";
|
||||
@@ -133,25 +134,30 @@ namespace SMGen.Pages
|
||||
bool[] b_bit = new bool[20];
|
||||
bool b_invert = false;
|
||||
//ciclo negli stati
|
||||
for (var i = 0; i < n_states - 1; i++)
|
||||
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++)
|
||||
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++)
|
||||
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
|
||||
@@ -164,24 +170,40 @@ namespace SMGen.Pages
|
||||
//cerca il nome del bit e ne trova l' indice da 0
|
||||
n_bit = Bits.FindIndex(x => x == sz_actual_bit);
|
||||
|
||||
//TODO: gestire errore in caso non trovi indice (quindi -1)
|
||||
|
||||
if (((!b_invert) && b_bit[n_bit]) || (b_invert && (!b_bit[n_bit])))
|
||||
if (n_bit == -1)
|
||||
{
|
||||
sz_line = "";
|
||||
exitFor = true;
|
||||
}
|
||||
|
||||
//eseguo solo se diverso dallo stato corrente
|
||||
if (States.IndexOf(act_rule.next_state) != i)
|
||||
if (!exitFor)
|
||||
{
|
||||
if (((!b_invert) && b_bit[n_bit]) || (b_invert && (!b_bit[n_bit])))
|
||||
{
|
||||
sz_line = "";
|
||||
|
||||
sz_line = $"{n_state_machine_index};{i};{n_input};{Events_to_send.IndexOf(act_rule.event_to_send)};{States.IndexOf(act_rule.next_state)}";
|
||||
//eseguo solo se diverso dallo stato corrente
|
||||
if (States.IndexOf(act_rule.next_state) != i)
|
||||
{
|
||||
|
||||
sw.WriteLine(sz_line);
|
||||
sz_line = $"{n_state_machine_index}" +
|
||||
$";" +
|
||||
$"{i}" +
|
||||
$";" +
|
||||
$"{n_input}" +
|
||||
$";" +
|
||||
$"{Events_to_send.IndexOf(act_rule.event_to_send)}" +
|
||||
$";" +
|
||||
$"{States.IndexOf(act_rule.next_state)}";
|
||||
|
||||
sw.WriteLine(sz_line);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// sz_line = $"----{n_state_machine_index};{i};{n_input};{Events_to_send.IndexOf(act_rule.event_to_send)};{States.IndexOf(act_rule.next_state)}";
|
||||
//}
|
||||
exitFor = true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// sz_line = $"----{n_state_machine_index};{i};{n_input};{Events_to_send.IndexOf(act_rule.event_to_send)};{States.IndexOf(act_rule.next_state)}";
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+705
-7737
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user