diff --git a/src/main/java/ai/AIBlockConnAttrib.java b/src/main/java/ai/AIBlockConnAttrib.java index c0bd4aaccc3ade974d648d9cdc4697167469d834..c8e53d8317d55202b92b28adaba64b84750b9446 100644 --- a/src/main/java/ai/AIBlockConnAttrib.java +++ b/src/main/java/ai/AIBlockConnAttrib.java @@ -114,10 +114,12 @@ public class AIBlockConnAttrib extends AIInteract { boolean done = false; int cpt = 0; + int cptStage = 0; // Blocks and attributes while (!done && cpt < 20) { cpt++; + cptStage ++; boolean ok = makeQuestion(questionT); if (!ok) { done = true; @@ -155,7 +157,7 @@ public class AIBlockConnAttrib extends AIInteract { "the full specification at once."); } - if ((errors != null) && (errors.size() > 0)) { + if ((errors != null) && (errors.size() > 0) && (cptStage < 8)) { questionT = "Your answer was not correct because of the following errors:"; for (String s : errors) { questionT += "\n- " + s; @@ -163,13 +165,14 @@ public class AIBlockConnAttrib extends AIInteract { } else { //TraceManager.addDev(" Avatar spec=" + specification); stage++; + cptStage = 0; if (stage == KNOWLEDGE_STAGES.length) { done = true; } else { makeKnowledge(stage); questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + chatData.lastQuestion.trim(); if (namesOfBlocks.length() > 0) { - questionT += "\nThe blocks to be used are: " + namesOfBlocks.trim(); + questionT += "\nThe blocks to use are: " + namesOfBlocks.trim(); } } } diff --git a/src/main/java/ai/AIBlockConnAttribWithSlicing.java b/src/main/java/ai/AIBlockConnAttribWithSlicing.java index 3dbb5dd975541b4aeb666878659444ef2ce95276..1e9b0f95f37700fc26bc431d3e05675be546249c 100644 --- a/src/main/java/ai/AIBlockConnAttribWithSlicing.java +++ b/src/main/java/ai/AIBlockConnAttribWithSlicing.java @@ -92,10 +92,12 @@ public class AIBlockConnAttribWithSlicing extends AIInteract { public static String[] KNOWLEDGE_STAGES = {KNOWLEDGE_ON_JSON_FOR_BLOCKS, KNOWLEDGE_ON_JSON_FOR_CONNECTIONS, KNOWLEDGE_ON_JSON_FOR_ATTRIBUTES}; AvatarSpecification specification, specification0; - private String[] QUESTION_IDENTIFY_SYSTEM_BLOCKS = {"From the following system specification, using the specified JSON format, identify the " + + private String[] QUESTION_IDENTIFY_SYSTEM_BLOCKS = {"From the provided system specification, using the specified JSON format, identify the " + "typical system blocks. Do respect the JSON format, and provide only JSON (no explanation before or after).\n", - "From the following system specification, using the specified JSON format, identify the " + + + "From the provided system specification, using the specified JSON format, identify the " + "typical system blocks and their connections. Do respect the JSON format, and provide only JSON (no explanation before or after).\n", + "From the previous JSON and system specification, find the typical attributes of all blocks by imagining all the necessary attributes " + "that would be needed for the state machine diagram of each block. "}; @@ -110,9 +112,9 @@ public class AIBlockConnAttribWithSlicing extends AIInteract { int stage = 0; String systemSpec = chatData.lastQuestion.trim(); String json = ""; - String questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + "\n" + chatData.lastQuestion.trim() + "\n"; + String questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] ; initKnowledge(); - makeKnowledge(stage); + makeKnowledge(stage, systemSpec); boolean done = false; int cpt = 0; @@ -174,13 +176,13 @@ public class AIBlockConnAttribWithSlicing extends AIInteract { done = true; } else { initKnowledge(); - makeKnowledge(stage); + makeKnowledge(stage, systemSpec); if (stage == 1) { questionT = - "The system specification is: " + systemSpec + ".\n" + QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + ". Blocks are to " + - "use are" + namesOfBlocks; + QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + ". Blocks to " + + "use are: " + namesOfBlocks + "\n"; } else { - questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + chatData.lastQuestion.trim(); + questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage]; // + chatData.lastQuestion.trim(); } if (namesOfBlocks.length() > 0) { questionT += "\nThe blocks to be used are: " + namesOfBlocks.trim(); @@ -223,10 +225,9 @@ public class AIBlockConnAttribWithSlicing extends AIInteract { } if (_spec != null) { - for(String s: know) { - TraceManager.addDev("\nKnowledge added: " + s); - chatData.aiinterface.addKnowledge("The system specification is: " + _spec, "ok"); - } + TraceManager.addDev("\nKnowledge added: " + _spec); + chatData.aiinterface.addKnowledge("The system specification is: " + _spec, "ok"); + } diff --git a/src/main/java/avatartranslator/AvatarBlock.java b/src/main/java/avatartranslator/AvatarBlock.java index 638b6447d77ffa97b9e4657852a0a0f64b2ae044..c255635edd1201c01e9494167ee978ab13274be7 100644 --- a/src/main/java/avatartranslator/AvatarBlock.java +++ b/src/main/java/avatartranslator/AvatarBlock.java @@ -1191,7 +1191,8 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne String variableName = action.substring(0, index).trim(); AvatarAttribute aa = getAvatarAttributeWithName(variableName); if (aa == null) { - TraceManager.addDev("The following action is not valid: " + action + " because it contains an attribute " + + TraceManager.addDev("The following action is not valid: " + action + + " because it contains an attribute " + variableName + " which is not declared in the block " + getName()); errors.add("The following action is not valid: " + action + " because it contains an attribute " + variableName + " which is not declared in the block " + getName()); @@ -1284,10 +1285,11 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne if (forceIfIncorrectExpression) { at.addAction(action); } else { - TraceManager.addDev("The following action is not valid: " + action + ". It must contain either the affectation of a " + - "variable or a signal send/receive"); - errors.add("The following action is not valid: " + action + ". It must contain either the affectation of a " + + TraceManager.addDev("The following action is not valid: " + action + ". It must contain either the " + + "setting of a " + "variable or a signal send/receive"); + errors.add("The following action is not valid: " + action + ". It must contain either the setting " + + "of a " + "variable or a signal send/receive"); } } } diff --git a/src/main/java/avatartranslator/AvatarSpecification.java b/src/main/java/avatartranslator/AvatarSpecification.java index db8c8855f0ccf8b192695d10c75ec7862be06970..54acb5662b825eb8bd4e326d7f1c136056d0f101 100644 --- a/src/main/java/avatartranslator/AvatarSpecification.java +++ b/src/main/java/avatartranslator/AvatarSpecification.java @@ -566,7 +566,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec { if (at == AvatarType.UNDEFINED) { jsonErrors.add("In block " + newBlock.getName() + " attribute " + nameA + " is invalid because " + - "its type is invalid."); + "\"" + typeA + "\"is an invalid type (only int or bool)."); } if (tryToCorrectErrors) { @@ -598,7 +598,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec { AvatarType at = AvatarType.getType(typeA); if (at == AvatarType.UNDEFINED) { jsonErrors.add("In block " + newBlock.getName() + " attribute " + nameA + " is invalid because " + - "its type is invalid."); + "\"" + typeA + "\"is an invalid type (only int or bool)."); } AvatarAttribute aa; diff --git a/src/main/java/avatartranslator/tosysmlv2/AVATAR2SysMLV2.java b/src/main/java/avatartranslator/tosysmlv2/AVATAR2SysMLV2.java index 6dea5719841e824e7102abd0ed6d8030cc62384b..22f948363f58f7acb9d7e005ccaf8e8b68601979 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AVATAR2SysMLV2.java +++ b/src/main/java/avatartranslator/tosysmlv2/AVATAR2SysMLV2.java @@ -55,7 +55,7 @@ import myutil.Plugin; import myutil.TraceManager; /** - * Class AVATAR2CPOSIX + * Class AVATAR2SysMLV2 * Creation: 21/09/2021 * * @author Ludovic APVRILLE