diff --git a/SMGen.Data/Data/RuleClass.cs b/SMGen.Data/Data/RuleClass.cs index 0f8eafe..263a1b3 100644 --- a/SMGen.Data/Data/RuleClass.cs +++ b/SMGen.Data/Data/RuleClass.cs @@ -2,9 +2,12 @@ { public class RuleClass { + public int id_state { get; set; } = 0; public string state { get; set; } = ""; public string expression { get; set; } = ""; + public int id_next_state { get; set; } = 0; public string next_state { get; set; } = ""; public string event_to_send { get; set; } = ""; + public int id_event_to_send { get; set; } = 0; } } diff --git a/SMGen.Data/Services/SMGDataService.cs b/SMGen.Data/Services/SMGDataService.cs index c143040..e952e9d 100644 --- a/SMGen.Data/Services/SMGDataService.cs +++ b/SMGen.Data/Services/SMGDataService.cs @@ -228,7 +228,7 @@ namespace SMGen.Data.Services } private List Bits { get; set; } = new List(); - private List Events_to_send { get; set; } = new List(); + private Dictionary Events_to_send { get; set; } = new Dictionary(); public List events2Add { get; set; } = new List(); private List Rules { get; set; } = new List(); private List States { get; set; } = new List(); @@ -304,7 +304,7 @@ namespace SMGen.Data.Services break; case "$EVENT": - Events_to_send.Add(sz_tokens[2].Trim().ToUpper()); + Events_to_send.Add(sz_tokens[2].Trim().ToUpper(), int.Parse(sz_tokens[1].Trim().ToUpper())); var newEvent = new AnagEventiModelTemp() { IdxTipo = int.Parse(sz_tokens[1].Trim().ToUpper()), @@ -351,10 +351,13 @@ namespace SMGen.Data.Services { var temp_rule = new RuleClass() { + id_state = StatesAll[sz_temp.Trim().ToUpper()], 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() + id_next_state = StatesAll[sz_temp.Trim().ToUpper()], + event_to_send = sz_tokens[3].Trim().ToUpper(), + id_event_to_send = Events_to_send[sz_tokens[3].Trim().ToUpper()] }; Rules.Add(temp_rule); @@ -429,7 +432,7 @@ namespace SMGen.Data.Services break; case "$EVENT": - Events_to_send.Add(sz_tokens[2].Trim().ToUpper()); + Events_to_send.Add(sz_tokens[2].Trim().ToUpper(), int.Parse(sz_tokens[1].Trim().ToUpper())); var newEvent = new AnagEventiModelTemp() { IdxTipo = int.Parse(sz_tokens[1].Trim().ToUpper()), @@ -465,7 +468,9 @@ namespace SMGen.Data.Services { state = state, event_to_send = event_to_send, - next_state = next_state + next_state = next_state, + id_next_state = StatesAll[next_state], + id_event_to_send = Events_to_send[event_to_send] }; Rules.Add(temp_rule); States2Rules.Add(next_state); @@ -575,7 +580,7 @@ namespace SMGen.Data.Services $";" + $"{n_input}" + $";" + - $"{Events_to_send.IndexOf(act_rule.event_to_send)}" + + $"{Events_to_send[act_rule.event_to_send]}" + $";" + $"{nextState}"; @@ -586,7 +591,7 @@ namespace SMGen.Data.Services IdxFamigliaIngresso = int.Parse(n_state_machine_index), IdxMicroStato = i, ValoreIngresso = n_input, - IdxTipoEvento = Events_to_send.IndexOf(act_rule.event_to_send), + IdxTipoEvento = Events_to_send[act_rule.event_to_send], next_IdxMicroStato = States.IndexOf(act_rule.next_state) }; @@ -644,6 +649,9 @@ namespace SMGen.Data.Services } } + Events_to_send = Events_to_send.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); + Rules = Rules.OrderBy(x => x.id_event_to_send).ToList(); + //ciclo negli stati try { @@ -678,7 +686,7 @@ namespace SMGen.Data.Services $";" + $"{item.Value}" + $";" + - $"{Events_to_send.IndexOf(act_rule.event_to_send)}" + + $"{Events_to_send[act_rule.event_to_send]}" + $";" + $"{nextState}"; sb.AppendLine(sz_line); @@ -687,7 +695,7 @@ namespace SMGen.Data.Services { IdxFamigliaIngresso = int.Parse(n_state_machine_index), IdxMicroStato = item.Value, - IdxTipoEvento = Events_to_send.IndexOf(act_rule.event_to_send), + IdxTipoEvento = Events_to_send[act_rule.event_to_send], next_IdxMicroStato = nextState }; diff --git a/SMGen/Temp/Rules/PROCESSED/BIT/12_FAMIGLIA_JETCO_NEW.csv b/SMGen/Temp/Rules/PROCESSED/BIT/12_FAMIGLIA_JETCO_NEW.csv new file mode 100644 index 0000000..4daa081 --- /dev/null +++ b/SMGen/Temp/Rules/PROCESSED/BIT/12_FAMIGLIA_JETCO_NEW.csv @@ -0,0 +1,775 @@ +IdxFamiglia;IdxStato;IdxTipo;next_IdxStato +12;0;1;13 +12;0;2;2 +12;0;3;3 +12;0;4;4 +12;0;5;5 +12;0;6;6 +12;0;7;7 +12;0;8;8 +12;0;9;9 +12;0;10;10 +12;0;12;11 +12;0;14;11 +12;0;19;30 +12;0;26;27 +12;0;31;31 +12;0;32;32 +12;0;37;33 +12;0;38;34 +12;0;39;35 +12;0;40;34 +12;0;49;49 +12;0;50;50 +12;2;1;13 +12;2;3;3 +12;2;4;4 +12;2;5;5 +12;2;6;6 +12;2;7;7 +12;2;8;8 +12;2;9;9 +12;2;10;10 +12;2;12;11 +12;2;14;11 +12;2;19;30 +12;2;26;27 +12;2;28;26 +12;2;31;31 +12;2;32;32 +12;2;37;33 +12;2;38;34 +12;2;39;35 +12;2;40;34 +12;2;49;49 +12;2;50;50 +12;3;1;13 +12;3;2;2 +12;3;4;4 +12;3;5;5 +12;3;6;6 +12;3;7;7 +12;3;8;8 +12;3;9;9 +12;3;10;10 +12;3;12;11 +12;3;14;11 +12;3;19;30 +12;3;26;27 +12;3;28;26 +12;3;31;31 +12;3;32;32 +12;3;37;33 +12;3;38;34 +12;3;39;35 +12;3;40;34 +12;3;49;49 +12;3;50;50 +12;4;1;13 +12;4;2;2 +12;4;3;3 +12;4;5;5 +12;4;6;6 +12;4;7;7 +12;4;8;8 +12;4;9;9 +12;4;10;10 +12;4;12;11 +12;4;14;11 +12;4;19;30 +12;4;26;27 +12;4;28;26 +12;4;31;31 +12;4;32;32 +12;4;37;33 +12;4;38;34 +12;4;39;35 +12;4;40;34 +12;4;49;49 +12;4;50;50 +12;5;1;13 +12;5;2;2 +12;5;3;3 +12;5;4;4 +12;5;6;6 +12;5;7;7 +12;5;8;8 +12;5;9;9 +12;5;10;10 +12;5;12;11 +12;5;14;11 +12;5;19;30 +12;5;26;27 +12;5;28;26 +12;5;31;31 +12;5;32;32 +12;5;37;33 +12;5;38;34 +12;5;39;35 +12;5;40;34 +12;5;49;49 +12;5;50;50 +12;6;1;13 +12;6;2;2 +12;6;3;3 +12;6;4;4 +12;6;5;5 +12;6;7;7 +12;6;8;8 +12;6;9;9 +12;6;10;10 +12;6;12;11 +12;6;14;11 +12;6;19;30 +12;6;26;27 +12;6;28;26 +12;6;31;31 +12;6;32;32 +12;6;37;33 +12;6;38;34 +12;6;39;35 +12;6;40;34 +12;6;49;49 +12;6;50;50 +12;7;1;13 +12;7;2;2 +12;7;3;3 +12;7;4;4 +12;7;5;5 +12;7;6;6 +12;7;8;8 +12;7;9;9 +12;7;10;10 +12;7;12;11 +12;7;14;11 +12;7;19;30 +12;7;26;27 +12;7;28;26 +12;7;31;31 +12;7;32;32 +12;7;37;33 +12;7;38;34 +12;7;39;35 +12;7;40;34 +12;7;49;49 +12;7;50;50 +12;8;1;13 +12;8;2;2 +12;8;3;3 +12;8;4;4 +12;8;5;5 +12;8;6;6 +12;8;7;7 +12;8;9;9 +12;8;10;10 +12;8;12;11 +12;8;14;11 +12;8;19;30 +12;8;26;27 +12;8;28;26 +12;8;31;31 +12;8;32;32 +12;8;37;33 +12;8;38;34 +12;8;39;35 +12;8;40;34 +12;8;49;49 +12;8;50;50 +12;9;1;13 +12;9;2;2 +12;9;3;3 +12;9;4;4 +12;9;5;5 +12;9;6;6 +12;9;7;7 +12;9;8;8 +12;9;10;10 +12;9;12;11 +12;9;14;11 +12;9;19;30 +12;9;26;27 +12;9;28;26 +12;9;31;31 +12;9;32;32 +12;9;37;33 +12;9;38;34 +12;9;39;35 +12;9;40;34 +12;9;49;49 +12;9;50;50 +12;10;1;13 +12;10;2;2 +12;10;3;3 +12;10;4;4 +12;10;5;5 +12;10;6;6 +12;10;7;7 +12;10;8;8 +12;10;9;9 +12;10;12;11 +12;10;14;11 +12;10;19;30 +12;10;26;27 +12;10;28;26 +12;10;31;31 +12;10;32;32 +12;10;37;33 +12;10;38;34 +12;10;39;35 +12;10;40;34 +12;10;49;49 +12;10;50;50 +12;11;1;13 +12;11;2;2 +12;11;3;3 +12;11;4;4 +12;11;5;5 +12;11;6;6 +12;11;7;7 +12;11;8;8 +12;11;9;9 +12;11;10;10 +12;11;15;12 +12;11;16;13 +12;11;17;14 +12;11;18;15 +12;11;19;30 +12;11;20;14 +12;11;21;13 +12;11;22;14 +12;11;23;23 +12;11;24;24 +12;11;25;25 +12;11;26;27 +12;11;29;28 +12;11;30;29 +12;11;31;31 +12;11;32;32 +12;11;33;15 +12;11;35;13 +12;11;36;14 +12;11;37;33 +12;11;38;34 +12;11;39;35 +12;11;40;34 +12;11;49;49 +12;11;50;50 +12;12;1;13 +12;12;2;2 +12;12;3;3 +12;12;4;4 +12;12;5;5 +12;12;6;6 +12;12;7;7 +12;12;8;8 +12;12;9;9 +12;12;10;10 +12;12;12;11 +12;12;14;11 +12;12;16;13 +12;12;18;15 +12;12;19;30 +12;12;21;13 +12;12;23;23 +12;12;24;24 +12;12;25;25 +12;12;26;27 +12;12;28;26 +12;12;29;28 +12;12;30;29 +12;12;31;31 +12;12;32;32 +12;12;33;15 +12;12;35;13 +12;12;37;33 +12;12;38;34 +12;12;39;35 +12;12;40;34 +12;12;49;49 +12;12;50;50 +12;13;2;2 +12;13;3;3 +12;13;4;4 +12;13;5;5 +12;13;6;6 +12;13;7;7 +12;13;8;8 +12;13;9;9 +12;13;10;10 +12;13;12;11 +12;13;14;11 +12;13;15;12 +12;13;18;15 +12;13;19;30 +12;13;23;23 +12;13;24;24 +12;13;25;25 +12;13;26;27 +12;13;27;12 +12;13;28;26 +12;13;29;28 +12;13;30;29 +12;13;31;31 +12;13;32;32 +12;13;33;15 +12;13;37;33 +12;13;38;34 +12;13;39;35 +12;13;40;34 +12;13;49;49 +12;13;50;50 +12;14;1;13 +12;14;2;2 +12;14;3;3 +12;14;4;4 +12;14;5;5 +12;14;6;6 +12;14;7;7 +12;14;8;8 +12;14;9;9 +12;14;10;10 +12;14;12;11 +12;14;14;11 +12;14;15;12 +12;14;16;13 +12;14;18;15 +12;14;19;30 +12;14;21;13 +12;14;23;23 +12;14;24;24 +12;14;25;25 +12;14;26;27 +12;14;28;26 +12;14;29;28 +12;14;30;29 +12;14;31;31 +12;14;32;32 +12;14;33;15 +12;14;35;13 +12;14;37;33 +12;14;38;34 +12;14;39;35 +12;14;40;34 +12;14;49;49 +12;14;50;50 +12;15;1;13 +12;15;2;2 +12;15;3;3 +12;15;4;4 +12;15;5;5 +12;15;6;6 +12;15;7;7 +12;15;8;8 +12;15;9;9 +12;15;10;10 +12;15;12;11 +12;15;14;11 +12;15;15;12 +12;15;16;13 +12;15;19;30 +12;15;21;13 +12;15;23;23 +12;15;24;24 +12;15;25;25 +12;15;26;27 +12;15;28;26 +12;15;29;28 +12;15;30;29 +12;15;31;31 +12;15;32;32 +12;15;35;13 +12;15;37;33 +12;15;38;34 +12;15;39;35 +12;15;40;34 +12;15;49;49 +12;15;50;50 +12;23;1;13 +12;23;2;2 +12;23;3;3 +12;23;4;4 +12;23;5;5 +12;23;6;6 +12;23;7;7 +12;23;8;8 +12;23;9;9 +12;23;10;10 +12;23;12;11 +12;23;14;11 +12;23;15;12 +12;23;16;13 +12;23;17;14 +12;23;18;15 +12;23;19;30 +12;23;20;14 +12;23;21;13 +12;23;22;14 +12;23;24;24 +12;23;25;25 +12;23;26;27 +12;23;28;26 +12;23;29;28 +12;23;30;29 +12;23;31;31 +12;23;32;32 +12;23;33;15 +12;23;35;13 +12;23;36;14 +12;23;37;33 +12;23;38;34 +12;23;39;35 +12;23;40;34 +12;23;49;49 +12;23;50;50 +12;24;1;13 +12;24;2;2 +12;24;3;3 +12;24;4;4 +12;24;5;5 +12;24;6;6 +12;24;7;7 +12;24;8;8 +12;24;9;9 +12;24;10;10 +12;24;12;11 +12;24;14;11 +12;24;15;12 +12;24;16;13 +12;24;18;15 +12;24;19;30 +12;24;21;13 +12;24;23;23 +12;24;25;25 +12;24;26;27 +12;24;28;26 +12;24;29;28 +12;24;30;29 +12;24;31;31 +12;24;32;32 +12;24;33;15 +12;24;35;13 +12;24;37;33 +12;24;38;34 +12;24;39;35 +12;24;40;34 +12;24;49;49 +12;24;50;50 +12;25;1;13 +12;25;2;2 +12;25;3;3 +12;25;4;4 +12;25;5;5 +12;25;6;6 +12;25;7;7 +12;25;8;8 +12;25;9;9 +12;25;10;10 +12;25;12;11 +12;25;14;11 +12;25;16;13 +12;25;17;14 +12;25;18;15 +12;25;19;30 +12;25;20;14 +12;25;21;13 +12;25;22;14 +12;25;23;23 +12;25;24;24 +12;25;26;27 +12;25;28;26 +12;25;29;28 +12;25;30;29 +12;25;31;31 +12;25;32;32 +12;25;33;15 +12;25;35;13 +12;25;36;14 +12;25;37;33 +12;25;38;34 +12;25;39;35 +12;25;40;34 +12;25;49;49 +12;25;50;50 +12;26;1;13 +12;26;2;2 +12;26;3;3 +12;26;4;4 +12;26;5;5 +12;26;6;6 +12;26;7;7 +12;26;8;8 +12;26;9;9 +12;26;10;10 +12;26;12;11 +12;26;14;11 +12;26;15;12 +12;26;16;13 +12;26;17;14 +12;26;18;15 +12;26;19;30 +12;26;20;14 +12;26;21;13 +12;26;22;14 +12;26;23;23 +12;26;24;24 +12;26;25;25 +12;26;26;27 +12;26;29;28 +12;26;30;29 +12;26;31;31 +12;26;32;32 +12;26;33;15 +12;26;35;13 +12;26;36;14 +12;26;37;33 +12;26;38;34 +12;26;39;35 +12;26;40;34 +12;26;49;49 +12;26;50;50 +12;27;1;13 +12;27;2;2 +12;27;3;3 +12;27;4;4 +12;27;5;5 +12;27;6;6 +12;27;7;7 +12;27;8;8 +12;27;9;9 +12;27;10;10 +12;27;12;11 +12;27;14;11 +12;27;19;30 +12;27;28;26 +12;27;31;31 +12;27;32;32 +12;27;37;33 +12;27;38;34 +12;27;39;35 +12;27;40;34 +12;27;49;49 +12;27;50;50 +12;28;1;13 +12;28;2;2 +12;28;3;3 +12;28;4;4 +12;28;5;5 +12;28;6;6 +12;28;7;7 +12;28;8;8 +12;28;9;9 +12;28;10;10 +12;28;12;11 +12;28;14;11 +12;28;16;13 +12;28;19;30 +12;28;26;27 +12;28;31;31 +12;28;32;32 +12;28;37;33 +12;28;38;34 +12;28;39;35 +12;28;40;34 +12;28;49;49 +12;28;50;50 +12;29;1;13 +12;29;2;2 +12;29;3;3 +12;29;4;4 +12;29;5;5 +12;29;6;6 +12;29;7;7 +12;29;8;8 +12;29;9;9 +12;29;10;10 +12;29;12;11 +12;29;14;11 +12;29;16;13 +12;29;19;30 +12;29;24;24 +12;29;26;27 +12;29;31;31 +12;29;32;32 +12;29;37;33 +12;29;38;34 +12;29;39;35 +12;29;40;34 +12;29;49;49 +12;29;50;50 +12;30;1;13 +12;30;2;2 +12;30;3;3 +12;30;4;4 +12;30;5;5 +12;30;6;6 +12;30;7;7 +12;30;8;8 +12;30;9;9 +12;30;10;10 +12;30;12;11 +12;30;14;11 +12;30;26;27 +12;30;31;31 +12;30;32;32 +12;30;37;33 +12;30;38;34 +12;30;39;35 +12;30;40;34 +12;30;49;49 +12;30;50;50 +12;31;1;13 +12;31;2;2 +12;31;3;3 +12;31;4;4 +12;31;5;5 +12;31;6;6 +12;31;7;7 +12;31;8;8 +12;31;9;9 +12;31;10;10 +12;31;12;11 +12;31;14;11 +12;31;19;30 +12;31;26;27 +12;31;28;26 +12;31;32;32 +12;31;37;33 +12;31;38;34 +12;31;39;35 +12;31;40;34 +12;31;49;49 +12;31;50;50 +12;32;1;13 +12;32;2;2 +12;32;3;3 +12;32;4;4 +12;32;5;5 +12;32;6;6 +12;32;7;7 +12;32;8;8 +12;32;9;9 +12;32;10;10 +12;32;12;11 +12;32;14;11 +12;32;19;30 +12;32;26;27 +12;32;28;26 +12;32;31;31 +12;32;37;33 +12;32;38;34 +12;32;39;35 +12;32;40;34 +12;32;49;49 +12;32;50;50 +12;33;1;13 +12;33;2;2 +12;33;3;3 +12;33;4;4 +12;33;5;5 +12;33;6;6 +12;33;7;7 +12;33;8;8 +12;33;9;9 +12;33;10;10 +12;33;12;11 +12;33;14;11 +12;33;19;30 +12;33;26;27 +12;33;28;26 +12;33;31;31 +12;33;32;32 +12;33;38;34 +12;33;39;35 +12;33;40;34 +12;33;49;49 +12;33;50;50 +12;34;1;13 +12;34;2;2 +12;34;3;3 +12;34;4;4 +12;34;5;5 +12;34;6;6 +12;34;7;7 +12;34;8;8 +12;34;9;9 +12;34;10;10 +12;34;12;11 +12;34;14;11 +12;34;15;12 +12;34;16;13 +12;34;19;30 +12;34;24;24 +12;34;26;27 +12;34;28;26 +12;34;31;31 +12;34;32;32 +12;34;37;33 +12;34;39;35 +12;34;49;49 +12;34;50;50 +12;35;1;13 +12;35;2;2 +12;35;3;3 +12;35;4;4 +12;35;5;5 +12;35;6;6 +12;35;7;7 +12;35;8;8 +12;35;9;9 +12;35;10;10 +12;35;12;11 +12;35;14;11 +12;35;19;30 +12;35;26;27 +12;35;28;26 +12;35;31;31 +12;35;32;32 +12;35;37;33 +12;35;38;34 +12;35;40;34 +12;35;49;49 +12;35;50;50 +12;49;1;13 +12;49;2;2 +12;49;3;3 +12;49;4;4 +12;49;5;5 +12;49;6;6 +12;49;7;7 +12;49;8;8 +12;49;9;9 +12;49;10;10 +12;49;12;11 +12;49;14;11 +12;49;19;30 +12;49;26;27 +12;49;28;26 +12;49;31;31 +12;49;32;32 +12;49;37;33 +12;49;38;34 +12;49;39;35 +12;49;40;34 +12;49;50;50 +12;50;1;13 +12;50;2;2 +12;50;3;3 +12;50;4;4 +12;50;5;5 +12;50;6;6 +12;50;7;7 +12;50;8;8 +12;50;9;9 +12;50;10;10 +12;50;12;11 +12;50;14;11 +12;50;19;30 +12;50;26;27 +12;50;28;26 +12;50;31;31 +12;50;32;32 +12;50;37;33 +12;50;38;34 +12;50;39;35 +12;50;40;34 +12;50;49;49