Exemple #1
0
    private void  initStates()
    {
        takeState = Take.Start;
        activateState = Activate.Start;
        deactivateState = Deactivate.Start;
        releaseState = Release.Start;
        tasteState = Taste.Start;
        smellState = Smell.Start;

        /*openDoorState = OpenDoor.Start;
        closeDoorState = CloseDoor.Start;*/
        moveState = Move.Start;
        rotateState = Rotate.Start;
        turnState = Turn.Start;
        commandStatus = CommandStatus.Running;
        headFocusState = HeadFocus.Start;
        headResetState = HeadReset.Start;
        lookForState = LookFor.Start;

        speakState = Speak.Start;

        cancelState = Cancel.Start;
        getSensesState = GetSenses.Start;

        reset = true;           
    }
Exemple #2
0
 private void end()
 {
     switch (action)
     {
         case Action.Take:
             takeState = Take.End;
             break;
         case Action.Activate:
             activateState = Activate.End;
             break;
         case Action.Deactivate:
             deactivateState = Deactivate.End;
             break;
         case Action.Release:
             releaseState = Release.End;
             break;
         case Action.Taste:
             tasteState = Taste.End;
             break;
         case Action.Smell:
             smellState = Smell.End;
             break;
         case Action.Move:
             moveState = Move.End;
             break;                
         case Action.Rotate:
             rotateState = Rotate.End;
             break;
         case Action.Turn:
               turnState = Turn.End;
               break;
         case Action.HeadFocus:
             headFocusState = HeadFocus.End;
             break;
         case Action.HeadReset:
             headResetState = HeadReset.End;
             break;
         case Action.LookFor:
             lookForState = LookFor.End;
             break;
         case Action.Speak:
             speakState = Speak.End;
             break;
         case Action.Cancel:
             cancelState = Cancel.End;
             break;
         case Action.GetSenses:
             getSensesState = GetSenses.End;
             break;
         default:
             break; ;
     }   
 }
Exemple #3
0
        /// <inheritdoc />
        protected override void ExecuteJob(CancellationToken token)
        {
            while (true)
            {
                try
                {
                    //gets an upgradable read only lock
                    using (var lck = _valueList.UpgradableRoLock(token))
                    {
                        (bool terminationConditionFound, string message, int itemsConsidered) =
                            DoesTerminationApply(in lck);
                        if (terminationConditionFound)
                        {
                            int insertionIndex = _rGen.Next(0, lck.Count);
                            //use the lock like you would a vault (i.e. call .Lock() ) to upgrade to an exclusive
                            //write lock
                            using var writeLock = lck.Lock(token);
                            writeLock.Insert(insertionIndex, in LookFor);

                            _helper.WriteLine("At {0} Arbiter wrote {1} at index {2} making the last index of the array to consider at validation time: {3}",
                                              CgTimeStampSource.Now.ToString("O"), LookFor.ToString(),
                                              insertionIndex.ToString(), lck.Count - 1);
                            _helper.WriteLine(message);
                            return; //the write lock is released, then the upgradable read lock.
                        }
                    }
                }
                catch (TimeoutException ex) //log timeout exception, but it isn't a fault (I've not observed it yet here)
                {
                    _helper.WriteLine("Arbiter thread timed out with ex: [{0}].",
                                      ex);
                }
                catch (OperationCanceledException) //cancel the thread (not a fault, but terminates)
                {
                    _helper.WriteLine("Arbiter thread cancelled.");
                    throw;
                }
                catch (Exception ex) //faulting exception
                {
                    _helper.WriteLine("Arbiter faulted with ex: [{0}]", ex);
                    throw;
                }
            }
        }
        public static ClientInfo[] GetInSystem(LookFor look = LookFor.Evrywere)
        {
            var    inf = new Hashtable(32);
            string dir;

            if (look.HasFlag(LookFor.UOQuint))   // look for client for uoQuint server
            {
                dir = Utils.GetRegistryKey <string>(@"Quintessence\Ultima Online", "InstallPath");
                if (Directory.Exists(dir))
                {
                    foreach (var file in Directory.GetFiles(dir, "*.exe"))
                    {
                        inf[file] = inf[file] ?? Get(file);
                    }
                }
            }

            if (look.HasFlag(LookFor.Classic))   // look for osi classic clients
            {
                foreach (var key in _KnownRegkeys)
                {
                    foreach (var name in _KnownRegNames)
                    {
                        dir = Utils.GetRegistryKey <string>(key, name);

                        if (File.Exists(dir) && Path.GetExtension(dir) == ".exe")
                        {
                            dir = Path.GetDirectoryName(dir);
                        }

                        if (Directory.Exists(dir))
                        {
                            foreach (var file in Directory.GetFiles(dir, "*.exe"))
                            {
                                inf[file] = inf[file] ?? Get(file);
                            }
                        }
                    }
                }
            }

            return(inf.Values.OfType <ClientInfo>().Where(t => t != null).Distinct().ToArray());
        }
Exemple #5
0
 public ContestOperationCheckAttribute(ContestOperation op, LookFor lookFor = LookFor.SmartAss, string param = "id")
 {
     this.op      = op;
     this.lookFor = lookFor;
     this.param   = param;
 }
        public void SetOppositeDirection(IEnumerable <Command> commands, ISetOppositeDirection currrentDirection, LookFor lookFor)
        {
            if (currrentDirection.CurrentDirection)
            {
                foreach (Command command in commands)
                {
                    if (command is Left)
                    {
                        command.DoIIt = true;
                    }

                    if (command is Right)
                    {
                        command.DoIIt = false;
                    }
                }
                lookFor.Found = true;
            }
        }
Exemple #7
0
 private void changeStatus(int value)
 {
     if (commandStatus != CommandStatus.Fail && commandStatus != CommandStatus.Success)
     {
         switch (action)
         {
             case Action.Take:
                 if (takeState != Take.End)
                     takeState+=value;
                 break;
             case Action.Activate:
                 if (activateState != Activate.End)
                     activateState += value;
                 break;
             case Action.Deactivate:
                 if (deactivateState != Deactivate.End)
                     deactivateState += value;
                 break;
             case Action.Release:
                 if (releaseState != Release.End)
                     releaseState += value;
                 break;
             case Action.Taste:
                 if (tasteState != Taste.End)
                     tasteState += value;
                 break;
             case Action.Smell:
                 if (smellState != Smell.End)
                     smellState += value;
                 break;
             case Action.Move:
                 if (moveState != Move.End)
                     moveState+=value;
                 break;
             case Action.Rotate:
                  if (rotateState != Rotate.End)
                     rotateState+=value;
                 break;
             case Action.Turn:
                 if (turnState != Turn.End)
                      turnState+=value;
                break;
             case Action.HeadFocus:
                 if (headFocusState != HeadFocus.End)
                     headFocusState+=value;
                 break;
             case Action.HeadReset:
                 if (headResetState != HeadReset.End)
                     headResetState+=value;
                 break;
             case Action.LookFor:
                 if (lookForState != LookFor.End)
                     lookForState += value;
                 break;
             case Action.Speak:
                 if (speakState != Speak.End)
                    speakState += value;
                 break;
             case Action.Cancel:
                 if (cancelState != Cancel.End)
                     cancelState += value;
                 break;
             case Action.GetSenses:
                 if (getSensesState != GetSenses.End)
                     getSensesState += value;
                 break;
             default:
                 break;
         }
         commandStatus = CommandStatus.Running;
     }
 }
Exemple #8
0
        /// <summary>
        /// Main entrypoint for each of the threads
        /// </summary>
        void                    ThreadMain()
        {
            try
            {
                while (true)
                {
                    LookFor toSearch = (LookFor)m_foldersToDo.Remove();

                    if (toSearch == null)
                    {
                        continue;
                    }

                    //
                    // Add the subdirectories if necessary
                    //
                    if (Recurse)
                    {
                        string[] subDirs = Directory.GetDirectories(toSearch.Folder);

                        foreach (string subdir in subDirs)
                        {
                            m_foldersToDo.Add(new LookFor(subdir, toSearch.Expression), false);
                        }
                    }

                    //
                    // Show the folders if no expression
                    //
                    if (toSearch.Expression == "*")
                    {
                        foreach (string folder in Directory.GetDirectories(toSearch.Folder))
                        {
                            string replaced = folder.Replace(':', '$');

                            // Prepend the machine name
                            if (replaced.StartsWith(@"\\"))
                            {
                                Console.WriteLine(replaced);
                            }
                            else
                            {
                                Console.WriteLine(@"\\{0}\{1}", Environment.MachineName, replaced);
                            }
                        }
                    }

                    //
                    // Look for files on this fodlder
                    //

                    foreach (string filePath in Directory.GetFiles(toSearch.Folder, toSearch.Expression))
                    {
                        if (LocalPath)
                        {
                            Console.WriteLine(filePath);
                        }
                        else
                        {
                            string replaced = filePath.Replace(':', '$');

                            // Prepend the machine name
                            if (replaced.StartsWith(@"\\"))
                            {
                                Console.WriteLine(replaced);
                            }
                            else
                            {
                                Console.WriteLine(@"\\{0}\{1}", Environment.MachineName, replaced);
                            }
                        }
                    }
                }
            }
            catch (NoMoreException)
            {
                ;                 // Standard exit
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.Message + "\n" + exp.StackTrace, "Error");
            }
            finally
            {
                m_foldersToDo.RemoveProducer();
            }
        }
        public static string[] GetDataPath(LookFor look = LookFor.Evrywere)
        {
            var cinf = GetInSystem(look);

            return(cinf.Select(i => i.DirectoryPath).Distinct().ToArray());
        }