Ejemplo n.º 1
0
        public DataOperationPrefix(Event e, Expression assignment, Process process, string[] localvar)
        {
            Event = e;
            AssignmentExpr = assignment;
            Process = process;
            LocalVariables = localvar;

            ProcessID = DataStore.DataManager.InitializeProcessID(Event.GetID() + "{" + AssignmentExpr.ExpressionID + "}" + Constants.EVENTPREFIX + Process.ProcessID);
        }
Ejemplo n.º 2
0
 //string[] localvar,
 public PNTransition(Event e, ParallelDefinition[] selects, Expression guard, Expression assignment, PNPlace from, PNPlace to)
 {
     Event = e;
     Selects = selects;
     ProgramBlock = assignment;
     GuardCondition = guard;
     FromPNPlace = from;
     ToPNPlace = to;
 }
Ejemplo n.º 3
0
        //Assumption: the expression list of event can only contain process parameters, which mean after constant clearance, the expression must be a constant.
        public virtual Event ClearConstant(Dictionary<string, Expression> constMapping)
        {
            if (EventID == null)
            {
                string newID = BaseName;
                string newName = BaseName;
                int size = (ExpressionList == null) ? 0 : ExpressionList.Length;
                List<Expression> newExpressionList = new List<Expression>(size);
                bool hasVar = false;

                for (int i = 0; i < size; i++)
                {
                    Expression tempExp = ExpressionList[i].ClearConstant(constMapping);

                    //if there is no variables inside tempExp, then evaluate expression
                    if (!tempExp.HasVar)
                    {
                        ExpressionValue v = EvaluatorDenotational.Evaluate(tempExp, null);
                        if (v != null)
                        {
                            newID += "." + v.ExpressionID;
                            newName += "." + v.ToString();
                            newExpressionList.Add(v);
                        }
                        else
                        {
                            throw new RuntimeException("Expression " + tempExp + " has no value! Please make sure it has a value when used in event!");
                        }
                    }
                    //otherwise simplely display the variable names.
                    else
                    {
                        hasVar = true;
                        newExpressionList.Add(tempExp);
                    }
                }

                if (hasVar)
                {
                    Event newEvt = new Event(BaseName);
                    newEvt.ExpressionList = newExpressionList.ToArray();
                    return newEvt;
                }
                else
                {
                    Event newEvt = new Event(BaseName);
                    //no need to set since it is null anyway
                    //newEvt.ExpressionList = null;
                    newEvt.EventID = newID;
                    newEvt.EventName = newName;
                    return newEvt;
                }
            }
            //if full name is not null, then there is nothing to be changed, so we can safely return the event itself.

            return this;
        }
Ejemplo n.º 4
0
 //string[] localvar,
 public Transition(Event e, ParallelDefinition[] selects, Expression Guard, Expression assignment, State from, State to)
 {
     Event = e;
     Selects = selects;
     ProgramBlock = assignment;
     //LocalVariables = localvar;
     GuardCondition = Guard;
     FromState = from;
     ToState = to;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the expression list from event.
        /// Event.a.b return [a, b]
        /// Event.1.2 return [1, 2]
        /// </summary>
        /// <param name="Event"></param>
        /// <returns></returns>
        public List<Expression> GetParaExpInEvent(Event Event)
        {
            List<Expression> parameters = new List<Expression>();

            if (Event.ExpressionList != null)
            {
                parameters = new List<Expression>(Event.ExpressionList);
            }
            else if (Event.EventID != null && Event.EventID.Contains("."))
            {
                string[] temp = Event.EventID.Split('.');

                for (int i = 1; i < temp.Length; i++)
                {
                    parameters.Add(new IntConstant(int.Parse(temp[i])));
                }
            }

            //
            return parameters;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Return the update event expression when the Event is an Event object
        /// </summary>
        /// <param name="Event"></param>
        /// <returns></returns>
        public Expression GetEventExpression(Event Event)
        {
            List<Expression> parameters = this.GetParaExpInEvent(Event);

            int eventIndex = this.GetEventIndex(Event.BaseName, parameters.Count);

            Expression eventUpdateExpression = new Assignment(Model.EVENT_NAME, new IntConstant(eventIndex));

            if (parameters.Count > 0)
            {
                for (int i = 0; i < parameters.Count; i++)
                {
                    eventUpdateExpression = new Sequence(eventUpdateExpression, new Assignment(this.model.eventParameterVariables[i], parameters[i]));
                }
            }

            return eventUpdateExpression;
        }
Ejemplo n.º 7
0
 public IndexedEvent(List<ParallelDefinition> definitions, Event evt)
 {
     Definitions = definitions;
     Event = evt;
 }
Ejemplo n.º 8
0
 public EventPrefix(Event e, Process process)
 {
     Event = e;
     Process = process;
     ProcessID = DataStore.DataManager.InitializeProcessID(Event.GetID() + Constants.EVENTPREFIX + Process.ProcessID);
 }