예제 #1
0
		public TransitionWrapper(string key, StateWrapper to, StateWrapper parent, int order)
		{
			Key = key;
			To = to;
			Parent = parent;
			Order = order;
		}
예제 #2
0
 public CustomNode()
 {
     this.DataContext = this;
     //create instance of the state
     m_state = new StateWrapper();
     initPlugs();
 }
예제 #3
0
파일: CustomNode.cs 프로젝트: giordi91/FSM
 public CustomNode()
 {
     this.DataContext = this;
     //create instance of the state
     m_state = new StateWrapper();
     initPlugs();
 }
예제 #4
0
        public static State GetStateNode(StateWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <State>(objWrap.objState);

            State   objState   = objWrap.objState;
            Country objCountry = objWrap.objCountry;
            State   retState   = null;

            var result = Neo4jController.m_graphClient.Cypher
                         .Match("(A:" + objCountry.getLabel() + " { Name : {countryName }})")
                         .Match("(B:" + objState.getLabel() + " { Name : {stateName }})")
                         .Match("(A)-[r:" + Rel_Country.country_state + "]->(B)")
                         .WithParams(new
            {
                countryName = objCountry.Name,
                stateName   = objState.Name
            })
                         .Return(B => B.As <State>())
                         .Results;

            if (result.Count() > 0)
            {
                Logger.WriteToLogFile("State found");
                retState = result.ElementAt(0);
            }
            else
            {
                Logger.WriteToLogFile("State not found");
            }

            return(retState);
        }
예제 #5
0
 public Recorder()
 {
     recordedEvents = new Queue <Event>();
     tracker        = new StateWrapper <TStateId, string>(
         beforeOnEnter: s => RecordEnter(s.name),
         beforeOnLogic: s => RecordLogic(s.name),
         beforeOnExit: s => RecordExit(s.name)
         );
 }
예제 #6
0
        public static void AddState(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

            Excel.Worksheet sheet = ExcelController.GetWorkSheet(sheetName);

            Excel.Range usedRange = sheet.UsedRange;

            StateWrapper objWrap    = new StateWrapper();
            Country      objCountry = new Country();

            //Do not consider row 1 as its the header
            for (int Row = 2; Row <= usedRange.Rows.Count; Row++)
            {
                State objState = new State();

                for (int Col = 1; Col <= usedRange.Columns.Count; Col++)
                {
                    string name  = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2;
                    string value = null;

                    if ((usedRange.Cells[Row, Col] as Excel.Range).Value2 != null)
                    {
                        value = (usedRange.Cells[Row, Col] as Excel.Range).Value2.ToString();
                    }
                    else
                    {
                        continue;
                    }

                    if (name.CompareTo(ExcelSheets.EXCELSHEET_COUNTRY) == 0)
                    {
                        objCountry.Name = value;
                        continue;
                    }
                    ExcelUtilities.PopulateStructure <State>(name, value, ref objState);
                }

                //Add the country in the Neo4j Database

                objWrap.objState   = objState;
                objWrap.objCountry = objCountry;

                DBAddinterface.CreateStateNode(objWrap);
            }
        }
예제 #7
0
        public static void CreateStateNode(StateWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <State>(objWrap.objState);

            Country objcountry = objWrap.objCountry;
            State   objState   = objWrap.objState;

            if (objcountry == null)
            {
                throw new Exception("Country is null");
            }


            var result = Neo4jController.
                         m_graphClient.Cypher
                         .Match("(A:" + objcountry.getLabel() + " { id : {id} })")
                         .Merge("(A)-[R:" + Rel_Country.country_state + "]->(B:" + objState.getLabel() + " { Name : {StateName}})")
                         .OnCreate()
                         .Set("B = {objState}")
                         .OnMatch()
                         .Set("B = {objState}")
                         .WithParams(new
            {
                id        = objcountry.id,
                objState  = objState,
                StateName = objState.Name
            })
                         .Return((B, R) => new
            {
                StateCount    = B.Count(),
                RelationCount = R.Count()
            })
                         .Results
                         .Single();

            if (result.StateCount == 1)
            {
                Logger.WriteToLogFile("Successfully created State");
            }
            else
            {
                Logger.WriteToLogFile("Unable to create State");
            }
        }
예제 #8
0
        public static City GetCityNode(CityWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <City>(objWrap.objCity);

            StateWrapper objStateWrapper = new StateWrapper();

            objStateWrapper.objCountry = objWrap.objCountry;
            objStateWrapper.objState   = objWrap.objState;
            City objCity = objWrap.objCity;

            State objState = GetStateNode(objStateWrapper);

            if (objState == null)
            {
                return(null);
            }

            City retCity = null;

            var result = Neo4jController.m_graphClient.Cypher
                         .Match("(A:" + objState.getLabel() + " { id : {Stateid }})")
                         .Match("(B:" + objCity.getLabel() + " { Name : {CityName }})")
                         .Match("(A)-[r:" + Rel_State.state_city + "]->(B)")
                         .WithParams(new
            {
                Stateid  = objState.id,
                CityName = objCity.Name
            })
                         .Return(B => B.As <City>())
                         .Results;

            if (result.Count() > 0)
            {
                Logger.WriteToLogFile("City found");
                retCity = result.ElementAt(0);
            }
            else
            {
                Logger.WriteToLogFile("City not found");
            }

            return(retCity);
        }
예제 #9
0
 public static void Save(IValueSink sink, StateWrapper value)
 {
     Value<EventState>.Save(sink, value.Item);
 }
예제 #10
0
파일: CustomNode.cs 프로젝트: giordi91/FSM
 public CustomNode(StateWrapper state)
 {
     this.DataContext = this;
     m_state = state;
     initPlugs();
 }
예제 #11
0
 public static void Save(IValueSink sink, StateWrapper value)
 {
     Value <EventState> .Save(sink, value.Item);
 }
예제 #12
0
        // Constructor.

        public ObjectState()
        {
            wrapper = new StateWrapper(this);
        }
예제 #13
0
 public CustomNode(StateWrapper state)
 {
     this.DataContext = this;
     m_state          = state;
     initPlugs();
 }
예제 #14
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);
                        }
                    }
                }
            }
        }