Exemple #1
0
        private static CaseLine assignStatusAndSyncToACommVariable(Module module, Variable variable)
        {
            CaseLine commCaseLine = new CaseLine();
            OperExp  result       = new OperExp();

            result.Exp        = new InstancedExp(module.Instance.Name, variable.Name).ToString();
            result.Oper.Value = MathOper.ADD;
            //if it has copy var, then add  var + var_cp
            string res = "";

            if (module.isVariableExist(SMVPreFix.getCopyName(variable)))
            {
                res += new InstancedExp(module.Instance.Name, SMVPreFix.getCopyName(variable));
            }
            foreach (var connectedInstance in module.Instance.ConnectedTo)
            {
                if (connectedInstance.Module.isVariableExist(SMVPreFix.getConnectedCopyCommVarName(variable, module)))
                {
                    if (!string.IsNullOrWhiteSpace(res))
                    {
                        res += " + ";
                    }

                    res += new InstancedExp(connectedInstance.Name, SMVPreFix.getConnectedCopyCommVarName(variable, module));
                }
            }
            result.Result = new Expression(res);

            //(c1.status = _ACTIVE)
            CompoundBoolExpression statusAndSync = getInstancedStatusAndSyncCondition(module);

            ICondition boundCondition = getBoundCondition(variable, result);

            ICondition compound = new CompoundBoolExpression(statusAndSync, BinaryOperator.AND, boundCondition);

            CommunicationRule rule = new CommunicationRule();

            rule.Condition = compound;
            //commCaseLine.Rule.Condition = compound;
            commCaseLine.Rule   = rule;
            commCaseLine.Result = result;
            return(commCaseLine);
        }
Exemple #2
0
        private static CaseLine trueCaseLine(IVar variable)
        {
            CaseLine caseLine = new CaseLine();

            NuSMV.Rule rule = new NuSMV.Rule();
            rule.Condition = new TruthValue(Truth.TRUE);
            IExp exp = null;

            if (variable.Behaviour == VariableBehaviour.COMMUNICATION || variable.Behaviour == VariableBehaviour.DIVISION)
            {
                exp = new InstancedExp(variable.Name);
            }
            else
            {
                exp = new Expression(variable.Name);
            }
            caseLine.Rule   = rule;
            caseLine.Result = exp;
            return(caseLine);
        }