Beispiel #1
0
        public override void run()
        {
            int compid = Convert.ToInt32(compId);



            Console.WriteLine("Computing action " + action_id + " of port " + port_id + " of component " + compid
                              + " whose handleid informed is " + handleId);
            ITaskBindingKind v = (ITaskBindingKind)Certifier.services.getPort(port_id);


            //Certifier.verify_actions.TryGetValue(compid, out v);
            //v.invoke (IVerify.VERIFY_PERFORM);
            v.invoke(action_id);
            IActionFutureSet future_iteration = null;

            IActionFuture future_conclusive = null;

            //v.invoke (IVerify.VERIFY_CONCLUSIVE, out future_conclusive);
            v.invoke("verify_conclusive", out future_conclusive);
            future_iteration = future_conclusive.createSet();

            IActionFuture future_inconclusive = null;

            //v.invoke (IVerify.VERIFY_INCONCLUSIVE, out future_inconclusive);
            v.invoke("verify_inconclusive", out future_inconclusive);
            future_iteration.addAction(future_inconclusive);

            IActionFuture r = future_iteration.waitAny();

            result = r == future_conclusive ? CerificationResult.Conclusive : CerificationResult.Inconclusive;
        }
Beispiel #2
0
        public bool visit(SWLWorkflowChoice <bool> node)
        {
            IActionFutureSet future_list = null;
            IDictionary <IActionFuture, SWLWorkflow <bool> > dict_action_alt = new Dictionary <IActionFuture, SWLWorkflow <bool> > ();

            for (int i = 0; i < node.action_list.Length; i++)
            {
                string port_name   = node.guard_list [i].Item1;
                string action_name = node.guard_list [i].Item2;

                ITaskBindingKind action_port = port(port_name);
                IActionFuture    future_handle;
                action_port.invoke(action_name, out future_handle);
                if (future_list == null)
                {
                    future_list = future_handle.createSet();
                }
                else
                {
                    future_list.addAction(future_handle);
                }

                dict_action_alt [future_handle] = node.action_list [i];
            }

            IActionFuture ready_action = future_list.waitAny();

            dict_action_alt [ready_action].accept(this);

            return(true);
        }
Beispiel #3
0
        public bool visit(SWLWorkflowStart <bool> node)
        {
            string port_name   = node.port_name;
            string action_name = node.action_name;
            string handle      = node.handle;

            ITaskBindingKind action_port = port(port_name);

            IActionFuture future_handle;

            action_port.invoke(action_name, out future_handle);

            if (handle != null)
            {
                dict_async_invocations [handle] = future_handle;
            }

            return(true);
        }
        public bool visit(SWLWorkflowInvoke <bool> node)
        {
            string port_name   = node.port_name;
            string action_name = node.action_name;

            Console.WriteLine("BEGIN INVOKE port_name={0} action_name={1}", port_name, action_name);


            switch (action_name)
            {
            case Constants.LIFECYCLE_RESOLVE:
                perform_resolve(port_name);
                break;

            case Constants.LIFECYCLE_CERTIFY:
                try_certify(port_name);
                break;

            case Constants.LIFECYCLE_DEPLOY:
                perform_deploy(port_name);
                break;

            case Constants.LIFECYCLE_INSTANTIATE:
                perform_instantiate(port_name);
                break;

            case Constants.LIFECYCLE_RUN:
                perform_run(port_name);
                break;

            default:
                ITaskBindingKind action_port = port(port_name);
                action_port.invoke(action_name);
                break;
            }

            Console.WriteLine("END INVOKE port_name={0} action_name={1}", port_name, action_name);

            return(true);
        }
        private bool Terminate(SWLWorkflowIterate <bool> node)
        {
            if (node.exit_clause == null && node.enter_clause == null)
            {
                return(false);
            }

            Console.WriteLine("TERMINATE 1");

            IActionFutureSet fs = new ActionFutureSet();

            IActionFuture[] future_list       = new IActionFuture[node.exit_clause.Length];
            string[]        enter_action_list = new string[node.exit_clause.Length];
            string[]        exit_action_list  = new string[node.exit_clause.Length];

            for (int i = 0; i < node.exit_clause.Length; i++)
            {
                Console.WriteLine("TERMINATE 2 {0}", i);

                string exit_action = node.exit_clause[i].action;
                string exit_port   = node.exit_clause[i].id_port;

                string enter_action = node.enter_clause[i].action;
                string enter_port   = node.enter_clause[i].id_port;

                Console.WriteLine("TERMINATE 3 {0} / {1}.{2} -- {3}.{4}", i, exit_port, exit_action, enter_port, enter_action);

                // It is supposed that both exit and enter action ports are the same;
                ITaskBindingKind action_port_exit  = port(exit_port);
                ITaskBindingKind action_port_enter = port(enter_port);

                Debug.Assert(action_port_exit == action_port_enter, "ITERATION: EXIT and ENTER action ports are distinct ! Check !");

                Console.WriteLine("TERMINATE 4 {0} {1}", action_port_exit == null, action_port_enter == null);

                IActionFuture f;
                action_port_enter.invoke(new string[2] {
                    exit_action, enter_action
                }, out f);
                fs.addAction(f);

                Console.WriteLine("TERMINATE 5 {0}", i);

                future_list[i]       = f;
                enter_action_list[i] = enter_action;
                exit_action_list[i]  = exit_action;
            }

            Console.WriteLine("TERMINATE 6 -- BEFORE WAIT ALL");
            fs.waitAll();
            Console.WriteLine("TERMINATE 7 -- AFTER WAIT ALL");

            int end_iteration = 0;             //unknown=0; enter=1; exit=2

            for (int i = 0; i < future_list.Length; i++)
            {
                string action_result = (string)future_list[i].Action;

                Console.WriteLine("TERMINATE 8 i={0} -- result={1}", i, action_result);

                if (action_result.Equals(enter_action_list[i]) && end_iteration == 0)
                {
                    end_iteration = 1;
                }

                else if (action_result.Equals(exit_action_list[i]) && end_iteration == 0)
                {
                    end_iteration = 2;
                }

                else if (action_result.Equals(enter_action_list[i]) && end_iteration == 2)
                {
                    throw new Exception("ITERATE: Conflict in termination clause !");
                }

                else if (action_result.Equals(exit_action_list[i]) && end_iteration == 1)
                {
                    throw new Exception("ITERATE: Conflict in termination clause !");
                }

                Console.WriteLine("TERMINATE 9 i={0} -- end_iteration={1}", i, end_iteration);
            }

            return(end_iteration == 2);
        }