コード例 #1
0
        private void SetTraceState(TraceState state)
        {
            string buttonContent = "";
            string stateMsg      = "";

            switch (state)
            {
            case TraceState.Start:
                buttonContent = "Stop Trace";
                stateMsg      = "( Tracing... )";
                break;

            case TraceState.Stop:
                buttonContent = "Start Trace";
                stateMsg      = "";
                break;

            case TraceState.Processing:
                buttonContent = "Processing...";
                stateMsg      = "( Processing... )";
                break;
            }

            TraceButton.Content = buttonContent;
            Title       = "WinTraceCmd " + stateMsg;
            mTraceState = state;
        }
コード例 #2
0
        private void CopyTraceStatesForAllAgents(List <Agent> agents, Agent agent, TraceState recievedState, List <TraceState> sentStates, int val)
        {
            bool found = false;

            foreach (Agent other in agents)
            {
                if (other.Equals(agent))
                {
                    found = true;
                    continue;
                }

                bool imTheSender = recievedState.senderID == other.getID();

                TraceState rec = AlterState(recievedState, other, true, imTheSender, val);

                List <TraceState> traceStates = new List <TraceState>();
                foreach (TraceState state in sentStates)
                {
                    TraceState temp = AlterState(state, other, false, imTheSender, val);
                    traceStates.Add(temp);
                }

                traces[other].AddStates(rec, traceStates);
            }
            if (!found)
            {
                throw new Exception("Agent not found");
            }
        }
コード例 #3
0
        public async Task NewTraceTestWithPojo()
        {
            var sdk = GetSdk <StateExample>();

            Dictionary <string, object> data = new Dictionary <string, object>
            {
                ["weight"]    = "123",
                ["valid"]     = true,
                ["operators"] = new string[] { "1", "2" },
                ["operation"] = "my new operation 1"
            };

            DataClass d = new DataClass()
            {
                f11 = 1,
                f22 = data
            };

            NewTraceInput <DataClass> input = new NewTraceInput <DataClass>(ACTION_KEY, d);

            TraceState <StateExample, DataClass> state = await sdk.NewTraceAsync <DataClass>(input);

            someTraceState = state;

            Assert.NotNull(state.TraceId);
        }
コード例 #4
0
        private List <TraceState> getRevealerSentStates(Agent agent, List <Action> actionsAffected, int val, int recievedStateID)
        {
            int diff = 1;
            List <TraceState> sentStates = new List <TraceState>();

            foreach (Action action in actionsAffected)
            {
                Dictionary <Predicate, int> publicEffectsOfAffected = getPublicEffects(action.HashEffects);
                List <int> sentStateVals  = GetVals(null, agent, val, publicEffectsOfAffected);
                int        sentSenderID   = agent.getID();
                int        sentStateID    = TraceState.GetNextStateID();
                int        sentParentID   = recievedStateID;
                int        sentIParentID  = -1;
                int        sentCost       = 1;
                int        sentHeuristic  = 1;
                List <int> sentPrivateIDs = GetIDs(recievedStateID, agents, agent, diff);
                string     sentContext    = "sending";
                TraceState sentState      = new TraceState(agent.getID(), sentSenderID, sentStateID, sentParentID, sentIParentID, sentCost, sentHeuristic, sentPrivateIDs, sentStateVals, sentContext);

                sentStates.Add(sentState);

                diff++;
            }

            return(sentStates);
        }
コード例 #5
0
        public async Task AppendLinkTestWithPojo()
        {
            var sdk = GetSdk <StateExample>();

            await NewTraceTestWithPojo();

            Assert.IsNotNull(someTraceState);
            Dictionary <string, object> data;
            string json = "{ operation: \"XYZ shipment departed port for ABC\"," + "    destination: \"ABC\", " + "    customsCheck: true, "
                          + "    eta: \"2019-07-02T12:00:00.000Z\"" + "  }";

            data = JsonHelper.ObjectToMap(json);

            DataClass d = new DataClass()
            {
                f11 = 1,
                f22 = data
            };


            AppendLinkInput <DataClass>          appLinkInput = new AppendLinkInput <DataClass>(FORM_ID, d, someTraceState.TraceId);
            TraceState <StateExample, DataClass> state        = await sdk.AppendLinkAsync <DataClass>(appLinkInput);

            Assert.IsNotNull(state.TraceId);
        }
コード例 #6
0
        public async Task PushTraceTestWithPojo()
        {
            var sdk = GetSdk <StateExample>();

            await NewTraceTestWithPojo();

            Assert.IsNotNull(someTraceState);
            Dictionary <string, object> data = new Dictionary <string, object>()
            {
                { "why", "because im testing the pushTrace 2" }
            };

            DataClass d = new DataClass()
            {
                f11 = 1,
                f22 = data
            };


            PushTransferInput <DataClass> push = new PushTransferInput <DataClass>(someTraceState.TraceId, "86", d, null);

            someTraceState = await sdk.PushTraceAsync <DataClass>(push);

            Assert.IsNotNull(push.TraceId);
        }
コード例 #7
0
        public async Task changeGroupTest()
        {
            await NewTraceTestWithPojo();

            Assert.NotNull(initTraceState);
            Assert.Equal(initTraceState.UpdatedByGroupId, config.MY_GROUP);
            Sdk <StateExample> sdk = GetSdk <StateExample>();
            // Appendlink
            CommentClass dataMap = new CommentClass()
            {
                comment = "commment"
            };

            AppendLinkInput <CommentClass> appLinkInput = new AppendLinkInput <CommentClass>(
                config.COMMENT_ACTION_KEY, dataMap, initTraceState.TraceId);

            // change group for action
            appLinkInput.GroupLabel = config.OTHER_GROUP_LABEL;
            TraceState <StateExample, CommentClass> state = await sdk.AppendLinkAsync(appLinkInput);

            // should equal group2 id
            Assert.Equal(state.UpdatedByGroupId, config.OTHER_GROUP);
            AppendLinkInput <CommentClass> appLinkInputWithGroupLabel = new AppendLinkInput <CommentClass>(
                config.COMMENT_ACTION_KEY, dataMap, initTraceState.TraceId);

            appLinkInputWithGroupLabel.GroupLabel = config.MY_GROUP_LABEL;
            state = await sdk.AppendLinkAsync(appLinkInputWithGroupLabel);

            // should equal group2 id
            Assert.Equal(state.UpdatedByGroupId, config.MY_GROUP);
        }
コード例 #8
0
ファイル: SdkAllTest.cs プロジェクト: stratumn/sdk-csharp
        public async Task changeGroupTest()
        {
            await NewTraceTest();

            Assert.NotNull(someTraceState);
            Assert.Equal(someTraceState.UpdatedByGroupId, config.MY_GROUP);
            Sdk <Object> sdk = GetSdk();
            // Appendlink
            Dictionary <string, object> dataMap = new Dictionary <string, object>
            {
                ["comment"] = "commment"
            };

            AppendLinkInput <Dictionary <string, object> > appLinkInput = new AppendLinkInput <Dictionary <string, object> >(
                config.COMMENT_ACTION_KEY, dataMap, someTraceState.TraceId);

            // change group for action
            appLinkInput.GroupLabel = config.OTHER_GROUP_LABEL;
            TraceState <Object, Dictionary <string, object> > state = await sdk.AppendLinkAsync(appLinkInput);

            // should equal group2 id
            Assert.Equal(state.UpdatedByGroupId, config.OTHER_GROUP);
            AppendLinkInput <Dictionary <string, object> > appLinkInputWithGroupLabel = new AppendLinkInput <Dictionary <string, object> >(
                config.COMMENT_ACTION_KEY, dataMap, someTraceState.TraceId);

            appLinkInputWithGroupLabel.GroupLabel = config.MY_GROUP_LABEL;
            state = await sdk.AppendLinkAsync(appLinkInputWithGroupLabel);

            // should equal group2 id
            Assert.Equal(state.UpdatedByGroupId, config.MY_GROUP);
        }
コード例 #9
0
 internal DistributedTracingData(string traceId, string parentId, bool flagRecorded, TraceState traceState = null)
 {
     TraceId      = traceId;
     ParentId     = parentId;
     FlagRecorded = flagRecorded;
     TraceState   = traceState;
 }
コード例 #10
0
        public override void PublishGoalState(MapsVertex goalVertex, MapsAgent goalFinder)
        {
            //int senderID = goalFinder.GetID();
            int stateID = TraceState.GetNextStateID();
            Dictionary <string, int> newIParents = new Dictionary <string, int>(goalVertex.publicParent.agent2iparent);

            TraceState parentState = goalVertex.publicParent.traceStateForPublicRevealedState;
            //int parentID = parentState.stateID;
            int    cost      = goalVertex.g;
            int    heuristic = goalVertex.h_when_sent;
            string context   = TraceState.GoalVerifiedMessage;

            foreach (MapsAgent agent in MapsPlanner.name2mapsAgent.Values)
            {
                int parentID = -1;
                if (agent.Equals(goalFinder))
                {
                    parentID = parentState.stateID; //In the json, only the goal finder needs to have a value of the parent of the last state
                }
                int senderID = agent.GetID();
                int iparent  = GetIParent(goalVertex, agent);
                newIParents[agent.name] = iparent;

                iparent = -1; //The json of goal state needs to be with iparent of -1...
                WriteStateToTrace(goalVertex, agent, context, parentID, iparent, stateID, senderID, cost, heuristic, newIParents);
            }
        }
コード例 #11
0
        public override void publishState(MapsVertex vertex, MapsAgent senderAgent)
        {
            if (!gotToRealStartState)
            {
                // Only when we got to the real start state, we will start publishing regular states...
                return;
            }
            //int senderID = senderAgent.GetID();
            int        senderID    = -1; //The json of sent state needs to be with senderID of -1...
            int        stateID     = TraceState.GetNextStateID();
            TraceState parentState = vertex.publicParent.traceStateForPublicRevealedState;
            int        iparent     = GetIParent(vertex, senderAgent);
            Dictionary <string, int> newIParents = new Dictionary <string, int>(vertex.publicParent.agent2iparent); //as a sender, I will change the iParents dictionary to be a new dictionary.

            //newIParents[senderAgent.name] = iparent;
            newIParents[senderAgent.name] = stateID;

            string context   = TraceState.SendingMessage;
            int    parentID  = parentState.stateID;
            int    cost      = vertex.g;
            int    heuristic = vertex.h_when_sent;

            iparent = -1; //The json of sent state needs to be with iparent of -1...

            WriteStateToTrace(vertex, senderAgent, context, parentID, iparent, stateID, senderID, cost, heuristic, newIParents);
        }
コード例 #12
0
ファイル: SdkTest.cs プロジェクト: step-stp/sdk-csharp
        public async Task NewTraceTestWithGenericType()
        {
            var sdk = GetSdk <StateExample>();


            Dictionary <string, object> data = new Dictionary <string, object>
            {
                ["weight"]    = "123",
                ["valid"]     = true,
                ["operators"] = new string[] { "1", "2" },
                ["operation"] = "my new operation 1"
            };

            SomeClass d = new SomeClass()
            {
                f11 = 1,
                f22 = data
            };

            NewTraceInput <SomeClass> input = new NewTraceInput <SomeClass>(FORM_ID, d);

            TraceState <StateExample, SomeClass> state = await sdk.NewTraceAsync <SomeClass>(input);

            someTraceState2 = state;



            Assert.IsNotNull(state.TraceId);
        }
コード例 #13
0
        public async Task RejectTransferTestWithPojo()
        {
            PaginationInfo paginationInfo = new PaginationInfo(10, null, null, null);

            var sdk = GetSdk <StateExample>();

            TracesState <StateExample, DataClass> tracesIn = await sdk.GetIncomingTracesAsync <DataClass>(paginationInfo);

            string traceId = null;

            if (tracesIn.TotalCount == 0)
            {
                await PushTraceTestWithPojo();

                traceId = someTraceState.TraceId;
            }
            else
            {
                someTraceState = tracesIn.Traces[0];
                traceId        = someTraceState.TraceId;
            }
            TransferResponseInput <DataClass>    trInput     = new TransferResponseInput <DataClass>(traceId, null, null);
            TraceState <StateExample, DataClass> stateReject = await GetOtherGroupSdk <StateExample>().RejectTransferAsync <DataClass>(trInput);

            Assert.NotNull(stateReject.TraceId);
        }
コード例 #14
0
        public async Task GetTraceStateTestWithPojo()
        {
            Sdk <StateExample> sdk   = GetSdk <StateExample>();
            GetTraceStateInput input = new GetTraceStateInput(config.TRACE_ID);
            TraceState <StateExample, StateExample> state = await sdk.GetTraceStateAsync <StateExample>(input);

            Assert.Equal(state.TraceId, config.TRACE_ID);
        }
コード例 #15
0
 private void Flush()
 {
     OnOrderCompleted?.Invoke(this, new OrderCloseEventArgs {
         Order = _order
     });
     _order = null;
     TraceState.FlushOrderNumber();
     ChangeState(AttendantState.Idle);
 }
コード例 #16
0
        public async Task CancelTransferTestWithPojo()
        {
            await PushTraceTestWithPojo();

            TransferResponseInput <Object>    responseInput = new TransferResponseInput <Object>(someTraceState.TraceId, new Object(), null);
            TraceState <StateExample, Object> statecancel   = await GetSdk <StateExample>().CancelTransferAsync <Object>(responseInput);

            Assert.NotNull(statecancel.TraceId);
        }
コード例 #17
0
ファイル: SdkTest.cs プロジェクト: step-stp/sdk-csharp
        public async Task GetTraceStateTest()
        {
            Sdk <object>                sdk     = GetSdk();
            string                      traceId = "a41257f9-2d9d-4d42-ab2a-fd0c83ea31df";
            GetTraceStateInput          input   = new GetTraceStateInput(traceId);
            TraceState <object, object> state   = await sdk.GetTraceStateAsync <object>(input);

            Assert.AreEqual(state.TraceId, traceId);
        }
コード例 #18
0
        public async Task AcceptTransferTestWithPojo()
        {
            await PushTraceTestWithPojo();

            TransferResponseInput <Object>    trInput     = new TransferResponseInput <Object>(someTraceState.TraceId, new Object(), null);
            TraceState <StateExample, Object> stateAccept = await GetOtherGroupSdk <StateExample>().AcceptTransferAsync <Object>(trInput);

            Assert.NotNull(stateAccept.TraceId);
        }
コード例 #19
0
        public async Task AcceptTransferTest()
        {
            await PushTraceTest();

            TransferResponseInput <Object> trInput     = new TransferResponseInput <Object>(someTraceState.TraceId, null, null);
            TraceState <Object, Object>    stateAccept = await GetOtherGroupSdk().AcceptTransferAsync(trInput);

            Assert.NotNull(stateAccept.TraceId);
        }
コード例 #20
0
        public async Task CancelTransferTest()
        {
            await PushTraceTest();

            TransferResponseInput <Object> responseInput = new TransferResponseInput <Object>(someTraceState.TraceId, null, null);
            TraceState <Object, Object>    statecancel   = await GetSdk().CancelTransferAsync(responseInput);

            Assert.NotNull(statecancel.TraceId);
        }
コード例 #21
0
ファイル: SdkAllTest.cs プロジェクト: stratumn/sdk-csharp
        public async Task GetTraceStateTest()
        {
            Sdk <object>                sdk     = GetSdk();
            string                      traceId = config.TRACE_ID;
            GetTraceStateInput          input   = new GetTraceStateInput(traceId);
            TraceState <object, object> state   = await sdk.GetTraceStateAsync <object>(input);

            Assert.Equal(state.TraceId, traceId);
        }
コード例 #22
0
        public async Task GetTraceStateTestWithPojo()
        {
            Sdk <StateExample> sdk     = GetSdk <StateExample>();
            string             traceId = "5ef3faed-9445-434e-acd5-a20cfa0284b1";
            GetTraceStateInput input   = new GetTraceStateInput(traceId);
            TraceState <StateExample, HeadLinkData> state = await sdk.GetTraceStateAsync <HeadLinkData>(input);

            Assert.AreEqual(state.TraceId, traceId);
        }
コード例 #23
0
        /// <summary>
        /// Raise the TraceMade event.
        /// </summary>
        /// <param name="trace">Trace entity.</param>
        private static void OnTraceMade(string source, string message, TraceState state)
        {
            EventHandler <TraceEventArgs> tmp = TraceMade;

            if (tmp != null)
            {
                Trace trace = new Trace(source, message, state);
                TraceMade(null, new TraceEventArgs(trace));
            }
        }
コード例 #24
0
        /// <summary>
        /// check capture & reference error
        /// </summary>
        /// <param name="state"></param>
        private void Visit(ref TraceState state)
        {
            List <object> seq = state.Exp.SyntaxTree.Sequence;

            for (int i = state.Index; i < seq.Count; i++)
            {
                if (seq[i] is Capture)
                {
                    Capture cap = seq[i] as Capture;
                    if (!cap.Anonymous)
                    {
                        Assign(cap.CapName, state.Exp);
                    }
                    else // annoy cap number start at 1
                    {
                        _anonys.Add(cap, _anonys.Keys.Count + 1);
                    }
                }
                else if (seq[i] is Reference)
                {
                    Reference refer = seq[i] as Reference;
                    // handle rename of annoy refer
                    if (refer.CapName.IsNumber)
                    {
                        // get real cap number for annoy cap.
                        int capnum;
                        if (refer.CapName.Source.Anonymous)
                        {
                            capnum = _anonys[refer.CapName.Source];
                        }
                        else
                        {
                            capnum = refer.CapName.Number;
                        }
                        if (_capnums.ContainsKey(capnum) && _capnums[capnum] != state.Exp)
                        {
                            _errorinfos.Add(new ReferenceErrorInfo(Traceback, refer, _capnums[capnum]));
                        }
                    }
                    else
                    {
                        string capname = refer.CapName.Name;
                        if (_capnames.ContainsKey(capname) && _capnames[capname] != state.Exp)
                        {
                            _errorinfos.Add(new ReferenceErrorInfo(Traceback, refer, _capnames[capname]));
                        }
                    }
                }
                else if (seq[i] is Expression)
                {
                    return;
                }
                state.Index++;
            }
        }
コード例 #25
0
    // Use this for initialization
    void Start()
    {
        enemyFsm = new FsmSystem();
        FsmStateBase patrol = new PatrolState(player, transform, enemyFsm);
        FsmStateBase trace  = new TraceState(player, transform, enemyFsm);
        FsmStateBase attack = new AttackState(player, transform, enemyFsm);

        enemyFsm.AddState(patrol);
        enemyFsm.AddState(trace);
        enemyFsm.AddState(attack);
    }
コード例 #26
0
        public async Task PushTraceTest()
        {
            await NewTraceTest();

            Assert.NotNull(someTraceState);

            PushTransferInput <object> push = new PushTransferInput <object>(someTraceState.TraceId, OTHER_GROUP, new object(), null);

            someTraceState = await GetSdk().PushTraceAsync <object>(push);

            Assert.NotNull(push.TraceId);
        }
コード例 #27
0
        public void StartOrder(Action <OrderBuilder> setupOrder)
        {
            ChangeState(AttendantState.Busy);
            Order = setupOrder?.CreateTargetAndInvoke().Build();

            TraceState.SetOrderNumber(Order.Number);

            if (Order.Obtaining == GoodsObtainingMethod.Dispensing && _dispenser == null)
            {
                CompleteOrder();
                throw new Exception("Unable to find a dispenser");
            }
        }
コード例 #28
0
        public async Task NewTraceUploadInClassTest()
        {
            await NewTraceTestWithPojo();

            UploadDocumentsClass data = new UploadDocumentsClass();

            data.documents = new Identifiable[] { FileWrapper.FromFilePath(GetTestFilePath()) };
            data.comment   = "upload comment";

            AppendLinkInput <UploadDocumentsClass>          appLinkInput = new AppendLinkInput <UploadDocumentsClass>(config.UPLOAD_DOCUMENTS_ACTION_KEY, data, initTraceState.TraceId);
            TraceState <StateExample, UploadDocumentsClass> state        = await GetOtherGroupSdk <StateExample>().AppendLinkAsync(appLinkInput);

            Assert.NotNull(state.TraceId);
        }
コード例 #29
0
ファイル: SdkAllTest.cs プロジェクト: stratumn/sdk-csharp
        public async Task AppendLinkTest()
        {
            await NewTraceTest();

            Assert.NotNull(someTraceState);
            Dictionary <string, object> data = new Dictionary <string, object>
            {
                ["comment"] = "comment"
            };
            AppendLinkInput <object>    appLinkInput = new AppendLinkInput <object>(config.COMMENT_ACTION_KEY, data, someTraceState.TraceId);
            TraceState <object, object> state        = await GetSdk().AppendLinkAsync(appLinkInput);

            Assert.NotNull(state.TraceId);
        }
コード例 #30
0
ファイル: SdkAllTest.cs プロジェクト: stratumn/sdk-csharp
        public async Task NewTraceUploadTest()
        {
            await NewTraceTest();

            IDictionary <string, object> data = new Dictionary <string, object>();

            data.Add("documents", new Identifiable[] { FileWrapper.FromFilePath(GetTestFilePath()) });

            AppendLinkInput <object>    appLinkInput = new AppendLinkInput <object>(config.UPLOAD_DOCUMENTS_ACTION_KEY, data, someTraceState.TraceId);
            TraceState <object, object> state        = await GetOtherGroupSdk().AppendLinkAsync <object>(appLinkInput);

            Assert.NotNull(state.TraceId);
            traceStateWithFile = state;
        }
コード例 #31
0
ファイル: BenchmarkResult.cs プロジェクト: WrongDog/Profiler
        void traceDB_OnStateChanged(TraceState newstate)
        {
            if (newstate == TraceState.Stopped)
            {
                DataSet handlerresult = handler.Result;
                handlerresult.WriteXml("BenchmarkHandler" + DateTime.UtcNow.ToString().Replace(":", "_").Replace(@"/", "_") + ".xml", XmlWriteMode.WriteSchema);

                Dictionary<string, decimal> result = new Dictionary<string, decimal>();

                foreach (DataRow spdr in handlerresult.Tables[0].Rows)
                {
                    decimal weight = 0;
                    foreach (DataRow opdr in handlerresult.Tables[1].Select(" Object ='" + spdr["Object"].ToString() + "'"))
                    {
                        decimal tableweight = 0;
                        decimal operationweight = 0;
                        if (tableWeight.ContainsKey(opdr["Table"].ToString())) tableWeight.TryGetValue(opdr["Table"].ToString(), out tableweight);
                        if (operationWeight.ContainsKey(opdr["Operation"].ToString())) operationWeight.TryGetValue(opdr["Operation"].ToString(), out operationweight);
                        weight += tableweight * operationweight * Convert.ToInt32(opdr["Count"].ToString());
                    }
                    weight = weight / Convert.ToInt32(spdr["Count"].ToString());
                    result.Add(spdr["Object"].ToString(), weight);
                    //result.Rows.Add(new object[] { spdr["Object"].ToString(), weight });
                }

                if (ResultUpdated != null) ResultUpdated(result);

            }
        }