Skip to content

Commit

Permalink
Merge pull request #85 from UoY-RoboStar/fix-83
Browse files Browse the repository at this point in the history
Fixes for issues 28, 83 and 84.
  • Loading branch information
alvarohm authored Aug 5, 2024
2 parents c42054d + e42e9aa commit b63f57a
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 35 deletions.
2 changes: 1 addition & 1 deletion circus.robocalc.robochart.textual.tests/robochart-tests
Submodule robochart-tests updated 43 files
+18 −0 robochart-fail/opcall-scope-fail/.project
+10 −0 robochart-fail/opcall-scope-fail/main.rct
+9 −0 robochart-fail/opcall-scope-fail/representations.aird
+18 −0 robochart-fail/operationInputOpRefTimed/.project
+42 −0 robochart-fail/operationInputOpRefTimed/operationInputOpRef.rct
+615 −0 robochart-fail/operationInputOpRefTimed/representations.aird
+18 −0 robochart-fail/operationInputStmRefTimed/.project
+44 −0 robochart-fail/operationInputStmRefTimed/operationInputStmRef.rct
+615 −0 robochart-fail/operationInputStmRefTimed/representations.aird
+18 −0 robochart-fail/operationInputTimed/.project
+41 −0 robochart-fail/operationInputTimed/operationInput.rct
+570 −0 robochart-fail/operationInputTimed/representations.aird
+18 −0 robochart-fail/operationOutputOpRefTimed/.project
+45 −0 robochart-fail/operationOutputOpRefTimed/operationOutputOpRef.rct
+646 −0 robochart-fail/operationOutputOpRefTimed/representations.aird
+18 −0 robochart-fail/operationOutputStmRefTimed/.project
+44 −0 robochart-fail/operationOutputStmRefTimed/operationOutputStmRef.rct
+646 −0 robochart-fail/operationOutputStmRefTimed/representations.aird
+18 −0 robochart-fail/operationOutputTimed/.project
+42 −0 robochart-fail/operationOutputTimed/operationOutput.rct
+601 −0 robochart-fail/operationOutputTimed/representations.aird
+6 −1 robochart/clocks5/clocks5.assertions
+1 −1 robochart/multi_final_state/main.assertions
+1 −1 robochart/ops1/ops1.assertions
+18 −0 robochart/rp-var-visible-uses/.project
+29 −0 robochart/rp-var-visible-uses/main.assertions
+81 −0 robochart/rp-var-visible-uses/main.rct
+10 −0 robochart/rp-var-visible-uses/representations.aird
+18 −0 robochart/rp-var-visible/.project
+29 −0 robochart/rp-var-visible/main.assertions
+72 −0 robochart/rp-var-visible/main.rct
+10 −0 robochart/rp-var-visible/representations.aird
+5 −1 robochart/test1/test1.assertions
+1 −1 robochart/test14/test14.assertions
+1 −1 robochart/test15/test15.assertions
+1 −1 robochart/test15/test15.rct
+27 −3 robochart/test2/test2.assertions
+5 −1 robochart/test5/test5.assertions
+5 −1 robochart/test6/test6.assertions
+154 −73 robochart/test8/representations.aird
+9 −8 robochart/test8/test8.assertions
+25 −25 robochart/test8/test8.rct
+5 −1 robochart/test9/test9.assertions
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,26 @@ class IntegrationTest {
TestRoboChartModel(dir)
}

@Test
def void testRPVarVisible() {
val dir = top_dir+"robochart/rp-var-visible"
TestRoboChartModel(dir)
}

@Test
def void testRPVarVisibleUses() {
val dir = top_dir+"robochart/rp-var-visible-uses"
TestRoboChartModel(dir)
}

@Test
def void testCallScopeFail() {
val dir = top_dir+"robochart-fail/opcall-scope-fail"
val file = "main.rct"
val errorMessage = "Couldn't resolve reference to OperationSig 'op'"
TestRoboChartModelError(dir, file, Literals.CALL, "org.eclipse.xtext.diagnostics.Diagnostic.Linking", errorMessage)
}

@Test
def void operationInputTest() {
val dir = top_dir+"robochart-fail/operationInput"
Expand All @@ -334,6 +354,14 @@ class IntegrationTest {
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationInputTestTimed() {
val dir = top_dir+"robochart-fail/operationInputTimed"
val file = "operationInput.rct"
val errorMessage = "inputEvent on OperationInputSTM is used as the end of a unidirectional connection, but OperationInputSTM outputs on inputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationInputOpRefTest() {
val dir = top_dir+"robochart-fail/operationInputOpRef"
Expand All @@ -342,13 +370,29 @@ class IntegrationTest {
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationInputOpRefTestTimed() {
val dir = top_dir+"robochart-fail/operationInputOpRefTimed"
val file = "operationInputOpRef.rct"
val errorMessage = "inputEvent on OperationInputSTM is used as the end of a unidirectional connection, but OperationInputSTM outputs on inputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationInputStmRefTest() {
val dir = top_dir+"robochart-fail/operationInputStmRef"
val file = "operationInputStmRef.rct"
val errorMessage = "inputEvent on OperationInputSTM is used as the end of a unidirectional connection, but OperationInputSTM outputs on inputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationInputStmRefTestTimed() {
val dir = top_dir+"robochart-fail/operationInputStmRefTimed"
val file = "operationInputStmRef.rct"
val errorMessage = "inputEvent on OperationInputSTM is used as the end of a unidirectional connection, but OperationInputSTM outputs on inputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputTest() {
Expand All @@ -358,6 +402,14 @@ class IntegrationTest {
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputTestTimed() {
val dir = top_dir+"robochart-fail/operationOutputTimed"
val file = "operationOutput.rct"
val errorMessage = "outputEvent on OperationOutputSTM is used as the start of a unidirectional connection, but OperationOutputSTM receives input on outputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputOpRefTest() {
val dir = top_dir+"robochart-fail/operationOutputOpRef"
Expand All @@ -366,6 +418,14 @@ class IntegrationTest {
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputOpRefTestTimed() {
val dir = top_dir+"robochart-fail/operationOutputOpRefTimed"
val file = "operationOutputOpRef.rct"
val errorMessage = "outputEvent on OperationOutputSTM is used as the start of a unidirectional connection, but OperationOutputSTM receives input on outputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputStmRefTest() {
val dir = top_dir+"robochart-fail/operationOutputStmRef"
Expand All @@ -374,6 +434,14 @@ class IntegrationTest {
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void operationOutputStmRefTestTimed() {
val dir = top_dir+"robochart-fail/operationOutputStmRefTimed"
val file = "operationOutputStmRef.rct"
val errorMessage = "outputEvent on OperationOutputSTM is used as the start of a unidirectional connection, but OperationOutputSTM receives input on outputEvent via the operation Op"
TestRoboChartModelError(dir, file, Literals.CONNECTION, errorMessage)
}

@Test
def void transitionsOutsideNodeContainer() {
val dir = top_dir+"robochart-fail/transitionsOutsideNodeContainer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class RoboChartScopeProvider extends AbstractRoboChartScopeProvider {
} else if (context instanceof Call) {
if (reference === CALL__OPERATION) {
//changed the parent scope to avoid accepting OperationDefs being in the scope for Calls
val s = delegateGetScope(context, reference) //IScope::NULLSCOPE
val s = IScope::NULLSCOPE //delegateGetScope(context, reference) //IScope::NULLSCOPE
return context.operationsDeclared(s)
}
} else if (context instanceof CallExp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ import java.util.ArrayList
import circus.robocalc.robochart.Clock
import circus.robocalc.robochart.Communication
import circus.robocalc.robochart.CommunicationStmt
import circus.robocalc.robochart.TimedStatement

/**
* This class contains custom validation rules.
Expand Down Expand Up @@ -651,26 +652,25 @@ class RoboChartValidator extends AbstractRoboChartValidator {
@Check
def roboticPlatformWFC(RoboticPlatformDef rp) {
/* RP1 */
for (i : rp.RInterfaces) {
for (var it = rp.RInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

error(
rp.name + ' is a robotic platform and cannot require interface ' + i.name,
RoboChartPackage.Literals.CONTEXT__RINTERFACES,
RoboChartPackage.Literals.CONTEXT__RINTERFACES, index,
'RPNoRequiredInterfaces'
)
}
/* RP2 */
for (Interface i : rp.interfaces) {
if (i.variableList.size > 0)
error(
getName(rp) + ' cannot define interface ' + i.name + ' because it contains variables',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
'UsedInterfaceWithOnlyEvents'
)
for (var it = rp.interfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.clocks.size > 0)
error(
getName(rp) + ' cannot define interface ' + i.name + ' because it contains clocks',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__INTERFACES, index,
'UsedInterfaceWithOnlyEvents'
)
}
Expand All @@ -688,10 +688,14 @@ class RoboChartValidator extends AbstractRoboChartValidator {
@Check
/* O1:STM1 */
def operationDefWFC(OperationDef o) {
for (i : o.PInterfaces) {

for (var it = o.PInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

error(
o.name + ' is an operation definition and cannot provide interface ' + i.name,
RoboChartPackage.Literals.CONTEXT__PINTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'OperationNoProvidedInterfaces'
)
}
Expand All @@ -700,41 +704,50 @@ class RoboChartValidator extends AbstractRoboChartValidator {
@Check
def requiredWFC(Context c) {
/* I1 */
for (i : c.RInterfaces) {
for (var it = c.RInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.events.size > 0) {
error(
getName(c) + ' cannot require interface ' + i.name + ' because it contains events',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__RINTERFACES, index,
'RequiredInterfaceWithEvents'
)
}
}

/* I1 */
for (i : c.PInterfaces) {
for (var it = c.PInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.events.size > 0) {
error(
getName(c) + ' cannot provide interface ' + i.name + ' because it contains events',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'ProvidedInterfaceWithEvents'
)
}

if (i.clocks.size > 0) {
error(
getName(c) + ' cannot provide interface ' + i.name + ' because it contains clocks',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'ProvidedInterfaceWithClocks'
)
}
}

/* I2, together with I2 implies STM2 and (because OperationDef is a Context) O1:STM2 */
for (Interface i : c.interfaces) {
for (var it = c.interfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.operations.size > 0)
error(
getName(c) + ' cannot define interface ' + i.name + ' because it contains operations',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__INTERFACES, index,
'UsedInterfaceWithOnlyEvents'
)
}
Expand All @@ -760,10 +773,13 @@ class RoboChartValidator extends AbstractRoboChartValidator {


/* C2 */
for (i : c.PInterfaces) {
for (var it = c.PInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

error(
c.name + ' is a controller and cannot provide interface ' + i.name,
RoboChartPackage.Literals.CONTEXT__PINTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'ControllerNoRequiredInterfaces'
)
}
Expand Down Expand Up @@ -905,21 +921,27 @@ class RoboChartValidator extends AbstractRoboChartValidator {
}

/* C10 */
for (i : c.interfaces) {
for (var it = c.interfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.clocks.size > 0)
error(
c.name + ' is a controller and cannot define interface ' + i.name + ' because it contains clocks',
RoboChartPackage.Literals.CONTEXT__INTERFACES,
RoboChartPackage.Literals.CONTEXT__INTERFACES, index,
'ControllerNoDefinedInterfacesWithClocks'
)
}

/* C11 */
for (i : c.RInterfaces) {
for (var it = c.RInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.clocks.size > 0)
error(
c.name + ' is a controller and cannot require interface ' + i.name + ' because it contains clocks',
RoboChartPackage.Literals.CONTEXT__RINTERFACES,
RoboChartPackage.Literals.CONTEXT__RINTERFACES, index,
'ControllerNoRequiredInterfacesWithClocks'
)
}
Expand Down Expand Up @@ -1029,10 +1051,14 @@ class RoboChartValidator extends AbstractRoboChartValidator {
/* STM1, together with I2 implies STM2 and (because OperationDef is a Context) O1:STM2 */
@Check
def stmWFC(StateMachineDef c) {
for (i : c.PInterfaces) {

for (var it = c.PInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

error(
c.name + ' is a state machine and cannot provide interface ' + i.name,
RoboChartPackage.Literals.CONTEXT__PINTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'StateMachineNoProvidedInterfaces'
)
}
Expand Down Expand Up @@ -1130,11 +1156,14 @@ class RoboChartValidator extends AbstractRoboChartValidator {
}

/* STM7 */
for (i : c.RInterfaces) {
for (var it = c.RInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.clocks.size > 0)
error(
c.name + ' is a state machine and cannot require interface ' + i.name + ' because it contains clocks',
RoboChartPackage.Literals.CONTEXT__RINTERFACES,
RoboChartPackage.Literals.CONTEXT__RINTERFACES, index,
'StateMachineNoRequiredInterfacesWithClocks'
)
}
Expand Down Expand Up @@ -1423,19 +1452,26 @@ class RoboChartValidator extends AbstractRoboChartValidator {
/* I1 */
@Check
def interfaceEitherEventsOrOthers(Context d) {
for (Interface i : d.RInterfaces) {

for (var it = d.RInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.events.size > 0)
error(
getName(d) + ' cannot require interface ' + i.name + ' because it contains events',
RoboChartPackage.Literals.CONTEXT__RINTERFACES,
RoboChartPackage.Literals.CONTEXT__RINTERFACES, index,
'RequiredInterfaceWithoutEvents'
)
}
for (Interface i : d.PInterfaces) {
for (var it = d.PInterfaces.listIterator; it.hasNext; ) {
var index = it.nextIndex
var i = it.next

if (i.events.size > 0)
error(
getName(d) + ' cannot provide interface ' + i.name + ' because it contains events',
RoboChartPackage.Literals.CONTEXT__PINTERFACES,
RoboChartPackage.Literals.CONTEXT__PINTERFACES, index,
'ProvidedInterfaceWithoutEvents'
)
}
Expand Down Expand Up @@ -2470,6 +2506,8 @@ https://github.com/UoY-RoboStar/robochart-csp-gen/issues/39',
} else if (s instanceof IfStmt) {
outputs.addAll(statementOutputSet(s.getThen))
outputs.addAll(statementOutputSet(s.getElse))
} else if (s instanceof TimedStatement) {
outputs.addAll(statementOutputSet(s.stmt))
}

outputs
Expand Down Expand Up @@ -2549,6 +2587,8 @@ https://github.com/UoY-RoboStar/robochart-csp-gen/issues/39',
} else if (s instanceof IfStmt) {
inputs.addAll(statementInputSet(s.getThen))
inputs.addAll(statementInputSet(s.getElse))
} else if (s instanceof TimedStatement) {
inputs.addAll(statementInputSet(s.stmt))
}

inputs
Expand Down

1 comment on commit b63f57a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.