Ejemplo n.º 1
0
        private void add_connection_create_click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("creating");
            //create double var conditions
            if (m_cond_type == 0)
            {
                Console.WriteLine(m_data_type);
                if (m_data_type == 1)
                {
                    var cond = FSMWrapper.DoubleConditionFactory <float> .Create <float>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed float");
                }
                else if (m_data_type == 0)
                {
                    var cond = FSMWrapper.DoubleConditionFactory <int> .Create <int>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed int");
                }
                else if (m_data_type == 2)
                {
                    var cond = FSMWrapper.DoubleConditionFactory <bool> .Create <bool>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);
                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed bool");
                }
            }
            //create typed conditions
            if (m_cond_type == 1)
            {
                Console.WriteLine(m_data_type);
                if (m_data_type == 1)
                {
                    var cond = FSMWrapper.ConditionFactory <float> .Create <float>(m_model.m_fsm, "foo", 12.2f, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed float");
                }
                else if (m_data_type == 0)
                {
                    var cond = FSMWrapper.ConditionFactory <int> .Create <int>(m_model.m_fsm, "foo", 2, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed int");
                }
                else if (m_data_type == 2)
                {
                    var cond = FSMWrapper.ConditionFactory <bool> .Create <bool>(m_model.m_fsm, "foo", 0, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);
                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed bool");
                }
            }

            this.Close();
        }
Ejemplo n.º 2
0
        public void read_from_file(string path)
        {
            m_rectangles.Clear();
            m_connections.Clear();
            m_fsm.from_file(path);
            var count = m_fsm.get_state_count();


            var state_map = new Dictionary<string, CustomNode>();
            for (int i = 0; i < count; i++)
            {
                StateWrapper w = m_fsm.get_state_at_index(i);
                var n = new CustomNode(w);
                n.NodeName = w.get_name();
                m_rectangles.Add(n);
                state_map[n.NodeName] = n;
            }

            for (int i = 0; i < count; i++)
            {
                var node = Rectangles[i];
                var state = node.m_state;
                var conn_count = state.get_connection_count();
                Console.WriteLine(conn_count);
                for (int c = 0; c < conn_count; ++c)
                {

                    var conn = state.get_connection_at_index(c);
                    string endName = conn.get_destination_name();
                    CustomNode endNode = state_map[endName];
                    StateWrapper endState = endNode.m_state;
                    var connShape = new Connection();
                    connShape.conn = conn;
                    var outp = node.OutPlug;
                    var inp = endNode.InPlug;
                    outp.IsSelected = true;
                    inp.IsSelected = true;
                    //TODO FIX RADIUSSS
                    outp.AddConnection(connShape);
                    inp.AddConnection(connShape);
                    connShape.StartPlug = inp;
                    connShape.EndPlug = outp;
                    var r = 10;
                    connShape.EndPoint= new Point(outp.X+r, outp.Y+r);
                    connShape.StartPoint= new Point(inp.X+r, inp.Y+r);
                    Connections.Add(connShape);

                    int cond_count = conn.get_condition_count();
                    for (int cnd = 0; cnd < cond_count; cnd++)
                    {
                        var t = conn.get_condition_type_at_index(cnd);
                        int templ_type = conn.get_condition_template_type_at_index(cnd);
                        if (t == "TypedCondition")
                        {
                            TypedConditionBinding binding;
                            if (templ_type == 0)
                            {
                                var cond = conn.get_Typed_at_index<int>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            else if (templ_type == 1)
                            {
                                var cond = conn.get_Typed_at_index<float>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            else
                            {
                                var cond = conn.get_Typed_at_index<bool>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            connShape.Conditions.Add(binding);
                        }
                        else
                        {
                            DoubleConditionBinding binding;
                            if (templ_type == 0)
                            {
                                var cond = conn.get_Double_at_index<int>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            else if (templ_type == 1)
                            {
                                var cond = conn.get_Typed_at_index<float>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            else
                            {
                                var cond = conn.get_Typed_at_index<bool>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            connShape.Conditions.Add(binding);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void add_connection_create_click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("creating");
            //create double var conditions 
            if (m_cond_type == 0)
            {
                Console.WriteLine(m_data_type);
                if (m_data_type == 1)
                {
                    var cond =  FSMWrapper.DoubleConditionFactory<float>.Create<float>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed float");
                }
                else if (m_data_type == 0)
                {
                    var cond =  FSMWrapper.DoubleConditionFactory<int>.Create<int>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed int");
                }
                else if (m_data_type == 2)
                {
                    var cond =  FSMWrapper.DoubleConditionFactory<bool>.Create<bool>(m_model.m_fsm, "foo", "bar", 0);

                    var bind = new DoubleConditionBinding(cond);
                    m_conn.Conditions.Add(bind);
                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed bool");
                }

            }
            //create typed conditions
            if (m_cond_type == 1)
            {
                Console.WriteLine(m_data_type);
                if (m_data_type == 1)
                {
                    var cond =  FSMWrapper.ConditionFactory<float>.Create<float>(m_model.m_fsm, "foo", 12.2f, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed float");
                }
                else if (m_data_type == 0)
                {
                    var cond =  FSMWrapper.ConditionFactory<int>.Create<int>(m_model.m_fsm, "foo", 2, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);

                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed int");
                }
                else if (m_data_type == 2)
                {
                    var cond =  FSMWrapper.ConditionFactory<bool>.Create<bool>(m_model.m_fsm, "foo", 0, 0);

                    var bind = new TypedConditionBinding(cond);
                    m_conn.Conditions.Add(bind);
                    m_conn.conn.add_conditions(cond);
                    Console.WriteLine("creating typed bool");
                }

            }
            
            this.Close();
        }
Ejemplo n.º 4
0
        public void read_from_file(string path)
        {
            m_rectangles.Clear();
            m_connections.Clear();
            m_fsm.from_file(path);
            var count = m_fsm.get_state_count();


            var state_map = new Dictionary <string, CustomNode>();

            for (int i = 0; i < count; i++)
            {
                StateWrapper w = m_fsm.get_state_at_index(i);
                var          n = new CustomNode(w);
                n.NodeName = w.get_name();
                m_rectangles.Add(n);
                state_map[n.NodeName] = n;
            }

            for (int i = 0; i < count; i++)
            {
                var node       = Rectangles[i];
                var state      = node.m_state;
                var conn_count = state.get_connection_count();
                Console.WriteLine(conn_count);
                for (int c = 0; c < conn_count; ++c)
                {
                    var          conn      = state.get_connection_at_index(c);
                    string       endName   = conn.get_destination_name();
                    CustomNode   endNode   = state_map[endName];
                    StateWrapper endState  = endNode.m_state;
                    var          connShape = new Connection();
                    connShape.conn = conn;
                    var outp = node.OutPlug;
                    var inp  = endNode.InPlug;
                    outp.IsSelected = true;
                    inp.IsSelected  = true;
                    //TODO FIX RADIUSSS
                    outp.AddConnection(connShape);
                    inp.AddConnection(connShape);
                    connShape.StartPlug = inp;
                    connShape.EndPlug   = outp;
                    var r = 10;
                    connShape.EndPoint   = new Point(outp.X + r, outp.Y + r);
                    connShape.StartPoint = new Point(inp.X + r, inp.Y + r);
                    Connections.Add(connShape);

                    int cond_count = conn.get_condition_count();
                    for (int cnd = 0; cnd < cond_count; cnd++)
                    {
                        var t          = conn.get_condition_type_at_index(cnd);
                        int templ_type = conn.get_condition_template_type_at_index(cnd);
                        if (t == "TypedCondition")
                        {
                            TypedConditionBinding binding;
                            if (templ_type == 0)
                            {
                                var cond = conn.get_Typed_at_index <int>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            else if (templ_type == 1)
                            {
                                var cond = conn.get_Typed_at_index <float>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            else
                            {
                                var cond = conn.get_Typed_at_index <bool>(cnd);
                                binding = new TypedConditionBinding(cond);
                            }
                            connShape.Conditions.Add(binding);
                        }
                        else
                        {
                            DoubleConditionBinding binding;
                            if (templ_type == 0)
                            {
                                var cond = conn.get_Double_at_index <int>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            else if (templ_type == 1)
                            {
                                var cond = conn.get_Typed_at_index <float>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            else
                            {
                                var cond = conn.get_Typed_at_index <bool>(cnd);
                                binding = new DoubleConditionBinding(cond);
                            }
                            connShape.Conditions.Add(binding);
                        }
                    }
                }
            }
        }