コード例 #1
0
ファイル: Sequence.cs プロジェクト: llenroc/KinectScan
        void scanner_RawFrameIn(object sender, Scanner.RawFrameEventArgs e)
        {
            if (SequenceRecording && e.FrameID % SequenceInterval == 0)
            {
                string path = WorkingDirectory + '\\' + SequenceLabel + '_' + SequenceCounter.ToString("D5");
                switch (e.FrameType)
                {
                case Scanner.FrameTypes.Depth:
                    SetSequenceCounter(SequenceCounter + 1);
                    path += ".rwd";
                    break;

                case Scanner.FrameTypes.Color:
                    path += ".rwc";
                    break;
                }
                SequenceTasks.Enqueue(new SequenceTask()
                {
                    Data     = e.Data,
                    FileName = path
                });

                for (int i = 0; i < SaveAREs.Length; i++)
                {
                    SaveAREs[i].Set();
                }
            }
        }
コード例 #2
0
    private bool SetupQuestPhases(string phaseLine)
    {
        string[] mainParts = phaseLine.Split(':');
        if (mainParts.Length != 2 ||
            mainParts[0] != "Quests")
        {
            return(false);
        }

        _ambassador.SequenceCounters = new List <SequenceCounter>();

        string[] itemParts = mainParts[1].Split('|');
        foreach (string current in itemParts)
        {
            string[] sequenceParts = current.Split(',');

            string[] phaseParts    = sequenceParts[0].Split('>');
            int      phaseProgress = Convert.ToInt32(phaseParts[1]);

            string[] detailParts = sequenceParts[1].Split('>');

            SequenceCounter newCounter = new SequenceCounter {
                Name         = phaseParts[0],
                Phase        = phaseProgress,
                QuestTitle   = detailParts[0],
                QuestDetails = detailParts[1]
            };

            _ambassador.SequenceCounters.Add(newCounter);
        }

        return(true);
    }
コード例 #3
0
        public async Task ExecuteAsync(GenerateNextNumberCommand command, IExecutionContext executionContext)
        {
            using (var scope = TransactionScopeManager.Create(DbContext))
            {
                // Lock this counter to avoid concurrent requests both getting a read of the same counter value
                // - It may though fail the very first time when the counter doesn't exist yet. I'll live with that.
                string tableName = DbConstants.DefaultAppSchema + ".SequenceCounter";
                await DbContext.Database.ExecuteSqlRawAsync($"SELECT TOP 1 * FROM {tableName} WITH(HOLDLOCK,UPDLOCK) WHERE [Name] = {{0}} ", command.CounterName);

                SequenceCounter counter = await DbContext.Counters.FindAsync(command.CounterName);

                if (counter == null)
                {
                    counter = new SequenceCounter {
                        Name = command.CounterName, Counter = 1
                    };
                    await DbContext.Counters.AddAsync(counter);
                }
                else
                {
                    counter.Counter++;
                }

                command.OutputValue = counter.Counter;

                await DbContext.SaveChangesAsync();

                await scope.CompleteAsync();
            }
        }
コード例 #4
0
        public void DualCounterTest()
        {
            string filePath = "c:\\temp\\test";

            DocCounter      docCounter      = new DocCounter(filePath);
            SequenceCounter sequenceCounter = new SequenceCounter(filePath);

            docCounter.Reset();
            sequenceCounter.Reset();

            long docCount = docCounter.Get();

            Assert.AreEqual(0, docCount);
            docCount = docCounter.Next();
            Assert.AreEqual(1, docCount);

            long sequenceCount = sequenceCounter.Get();

            Assert.AreEqual(0, sequenceCount);
            sequenceCount = sequenceCounter.Next();
            Assert.AreEqual(1, sequenceCount);

            docCounter.Close();

            docCounter = new DocCounter(filePath);
            docCount   = docCounter.Get();
            Assert.AreEqual(1, docCount);
        }
コード例 #5
0
    public bool CheckThreadProgress(string name, int progress)
    {
        SequenceCounter arg = new SequenceCounter {
            Name = name, Phase = progress
        };

        return(CheckThreadProgress(arg));
    }
コード例 #6
0
        public void Test_increment_IncrementsTheCounter()
        {
            SequenceCounter counter = new SequenceCounter();

            Assert.Equal("0", counter.AsString());

            counter.Increment();
            Assert.Equal("1", counter.AsString());

            counter.Increment();
            Assert.Equal("2", counter.AsString());
        }
コード例 #7
0
 internal void EndParallelSequence(bool endAllParallelSequencesAndContinueNumbering)
 {
     if (endAllParallelSequencesAndContinueNumbering)
     {
         int sequence = _counter.Sequence;
         _counter          = _counter.Parent;
         _counter.Sequence = sequence;
     }
     else
     {
         _counter = _counter.Parent;
     }
 }
コード例 #8
0
        public void Test_counter_WhenThereIsOneParent()
        {
            SequenceCounter parent = new SequenceCounter();

            parent.Increment();
            Assert.AreEqual("1", parent.AsString());

            SequenceCounter child = new SequenceCounter(parent);

            child.Increment();
            Assert.AreEqual("1.1", child.AsString());

            child.Increment();
            Assert.AreEqual("1.2", child.AsString());
        }
コード例 #9
0
    public bool CheckThreadProgress(SequenceCounter requiredCounter)
    {
        SequenceCounter counter = SequenceCounters.FirstOrDefault(c => c.Name == requiredCounter.Name);
        if(counter == default(SequenceCounter))
        {
            if(DebugMode)
                Debug.LogWarning("Could not find quest thread " + name + "; definently NOT on that quest!");

            return false;
        }

        bool correctProgress = counter.Phase == requiredCounter.Phase;
        if(DebugMode)
            Debug.Log("The player " + (correctProgress ? "has" : "does not have") + " the right progress for quest " + name);

        return correctProgress;
    }
コード例 #10
0
        internal SequenceCounter Clone()
        {
            SequenceCounter counter;

            if (Parent == null)
            {
                counter = new SequenceCounter();
            }
            else
            {
                counter = new SequenceCounter(Parent.Clone());
            }

            counter.Sequence = Sequence;

            return(counter);
        }
コード例 #11
0
ファイル: NetTraffic.cs プロジェクト: ashoulson/MiniUDP
        internal NetTraffic(long creationTime)
        {
            this.payloadLoss = new SequenceCounter(true);
              this.payloadDrop = new SequenceCounter(false);
              this.outgoingPing = new PingCounter();
              this.pingWindow = new int[NetConfig.PING_SMOOTHING_WINDOW];
              this.creationTime = creationTime;

              this.lastPayloadSeq = ushort.MaxValue; // "-1"
              this.notificationAck = 0;
              this.pingWindowIndex = 0;

              this.lastPacketRecvTime = creationTime;
              this.lastPayloadRecvTime = creationTime;
              this.lastNotificationRecvTime = creationTime;
              this.lastPongRecvTime = creationTime;

              for (int i = 0; i < this.pingWindow.Length; i++)
            this.pingWindow[i] = -1;
        }
コード例 #12
0
        public void Test_counter_WhenThereAreTwoParents()
        {
            SequenceCounter parent = new SequenceCounter();

            parent.Increment();
            Assert.AreEqual("1", parent.AsString());

            SequenceCounter child = new SequenceCounter(parent);

            child.Increment();
            Assert.AreEqual("1.1", child.AsString());

            SequenceCounter grandchild = new SequenceCounter(child);

            grandchild.Increment();
            Assert.AreEqual("1.1.1", grandchild.AsString());

            grandchild.Increment();
            Assert.AreEqual("1.1.2", grandchild.AsString());
        }
コード例 #13
0
ファイル: TitleGUI.cs プロジェクト: facybenbook/HerosJourney
    private void ResetPhases()
    {
        _ambassador.SequenceCounters = new List <SequenceCounter>();

        SequenceCounter main = new SequenceCounter {
            Name         = "Main",
            Phase        = 0,
            QuestTitle   = "Main Quest",
            QuestDetails = "Talk to King Aylea XXXIII"
        };

        SequenceCounter side = new SequenceCounter {
            Name         = "Goldensage",
            Phase        = 0,
            QuestTitle   = "Side Quest",
            QuestDetails = "Talk to everyone to find the side quest."
        };

        _ambassador.SequenceCounters.Add(main);
        _ambassador.SequenceCounters.Add(side);
    }
コード例 #14
0
ファイル: CommonService.cs プロジェクト: windygu/shangpincms
        public int GetNextCounterId(string sequenceKey)
        {
            int             i     = 1;
            SequenceCounter model = DapperUtil.Query <SequenceCounter>("ComBeziCommon_SequenceCounter_Read", new { SequenceKey = sequenceKey }).FirstOrDefault();

            if (model == null)
            {
                SequenceCounter sc = new SequenceCounter();
                sc.SequenceKey = sequenceKey;
                sc.CounterId   = i;
                DapperUtil.Insert <SequenceCounter>(sc, false);//true 返回插入数据的主键,false则不返回
            }
            else
            {
                i = model.CounterId;
                model.CounterId   = i + 1;
                model.SequenceKey = sequenceKey;
                DapperUtil.Update(model);
            }
            return(i);
        }
コード例 #15
0
ファイル: NetTraffic.cs プロジェクト: slango0513/Papagei
        internal NetTraffic(long creationTime)
        {
            payloadLoss       = new SequenceCounter(true);
            payloadDrop       = new SequenceCounter(false);
            outgoingPing      = new PingCounter();
            pingWindow        = new int[NetConfig.PING_SMOOTHING_WINDOW];
            this.creationTime = creationTime;

            lastPayloadSeq  = ushort.MaxValue; // "-1"
            notificationAck = 0;
            pingWindowIndex = 0;

            lastPacketRecvTime       = creationTime;
            lastPayloadRecvTime      = creationTime;
            lastNotificationRecvTime = creationTime;
            lastPongRecvTime         = creationTime;

            for (int i = 0; i < pingWindow.Length; i++)
            {
                pingWindow[i] = -1;
            }
        }
コード例 #16
0
        public void SequenceCounterTest()
        {
            string filePath = "c:\\temp\\test";

            SequenceCounter counter = new SequenceCounter(filePath);

            counter.Reset();
            long count = counter.Get();

            Assert.AreEqual(0, count);
            count = counter.Next();
            Assert.AreEqual(1, count);
            count = counter.Next();
            Assert.AreEqual(2, count);
            counter.Close();

            counter = null;

            counter = new SequenceCounter(filePath);
            count   = counter.Get();
            Assert.AreEqual(2, count);
        }
コード例 #17
0
    public bool CheckThreadProgress(SequenceCounter requiredCounter)
    {
        SequenceCounter counter = SequenceCounters.FirstOrDefault(c => c.Name == requiredCounter.Name);

        if (counter == default(SequenceCounter))
        {
            if (DebugMode)
            {
                Debug.LogWarning("Could not find quest thread " + name + "; definently NOT on that quest!");
            }

            return(false);
        }

        bool correctProgress = counter.Phase == requiredCounter.Phase;

        if (DebugMode)
        {
            Debug.Log("The player " + (correctProgress ? "has" : "does not have") + " the right progress for quest " + name);
        }

        return(correctProgress);
    }
コード例 #18
0
    public void UpdateThread(string name, int progress, string questName = "", string questDetail = "")
    {
        SequenceCounter counter = SequenceCounters.FirstOrDefault(c => c.Name == name);

        if (counter == default(SequenceCounter))
        {
            if (DebugMode)
            {
                Debug.LogWarning("Could not find Quest Thread " + name);
            }

            return;
        }

        if (DebugMode)
        {
            Debug.Log("Updating Quest Thread " + name + " to progress Lv." + progress);
        }

        counter.Phase        = progress;
        counter.QuestTitle   = questName;
        counter.QuestDetails = questDetail;
    }
コード例 #19
0
    private string FormatPhaseLine()
    {
        StringBuilder builder = new StringBuilder("Quests:");

        // Format of line:
        // Quests:A>n,T>d|B>n,T>d|C>n,T>d
        for (int i = 0; i < _ambassador.SequenceCounters.Count; i++)
        {
            SequenceCounter current = _ambassador.SequenceCounters[i];
            if (DebugMode)
            {
                Debug.Log("Serializing Sequence Counter #" + i + Environment.NewLine
                          + current.ToString());
            }

            builder.Append(current.Name);
            builder.Append(">");
            builder.Append(current.Phase);
            builder.Append(",");
            builder.Append(current.QuestTitle);
            builder.Append(">");
            builder.Append(current.QuestDetails);

            if (i < _ambassador.SequenceCounters.Count - 1)
            {
                builder.Append("|");
            }
        }

        if (DebugMode)
        {
            Debug.Log("Resulting phsae line:" + builder.ToString());
        }

        return(builder.ToString());
    }
コード例 #20
0
ファイル: SequenceNumber.cs プロジェクト: fhchina/dotnet-1
 internal void StartChildSequence()
 {
     _counter = new SequenceCounter(_counter);
 }
コード例 #21
0
 public bool CheckThreadProgress(string name, int progress)
 {
     SequenceCounter arg = new SequenceCounter{ Name = name, Phase = progress };
     return CheckThreadProgress(arg);
 }
コード例 #22
0
 internal ParallelSequenceCounter(SequenceCounter parent) : base(parent)
 {
     Sequence = Parent.Sequence;
 }
コード例 #23
0
 public bool EligibleForUse(SequenceCounter phase)
 {
     return(phase.Name == RequiredPhase.Name &&
            phase.Phase == RequiredPhase.Phase);
 }
コード例 #24
0
 internal SequenceCounter(SequenceCounter parent)
 {
     Parent = parent;
 }
コード例 #25
0
 public bool EligibleForUse(SequenceCounter phase)
 {
     return phase.Name == RequiredPhase.Name
            && phase.Phase == RequiredPhase.Phase;
 }
コード例 #26
0
ファイル: SequenceNumber.cs プロジェクト: fhchina/dotnet-1
 internal void EndParallelSequence()
 {
     _counter = ((ParallelSequenceCounter)_counter).Root;
 }
コード例 #27
0
ファイル: SequenceNumber.cs プロジェクト: fhchina/dotnet-1
 internal void StartParallelSequence()
 {
     _counter = new ParallelSequenceCounter(_counter);
 }
コード例 #28
0
 internal ParallelSequenceCounter(SequenceCounter parent) : base(parent)
 {
     Root     = parent.Clone();
     Sequence = Parent.Sequence;
 }
コード例 #29
0
ファイル: SequenceNumber.cs プロジェクト: fhchina/dotnet-1
 internal void EndChildSequence()
 {
     _counter = _counter.Parent;
 }