示例#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
 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
 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);
                        }
                    }
                }
            }
        }