Ejemplo n.º 1
0
 public void BeforeEach()
 {
     this.baseGrid         = this.getMockCubeGrid("base grid", true);
     this.programableBlock = new MockProgrammableBlock {
         CubeGrid    = this.baseGrid,
         CustomData  = "[solar-manager]\nkeyword=solar",
         CustomName  = "main pb",
         EntityId    = GetId(),
         ProgramType = typeof(Program)
     };
     this.gts = new MockGridTerminalSystem {
         this.programableBlock
     };
     this.program      = null;
     this.run          = null;
     this.solarManager = null;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to retrieve the update type for this block.
        /// </summary>
        /// <param name="ticks">The tick count to get the update type for</param>
        /// <param name="pb"></param>
        /// <param name="updateType">The detected update type</param>
        /// <returns><c>true</c> if this block is scheduled for a later run, <c>false</c> otherwise.</returns>
        protected virtual bool ScheduleProgrammableBlock(long ticks, MockProgrammableBlock pb, out UpdateType updateType)
        {
            updateType = UpdateType.None;
            var runtime = pb.Runtime;

            if (runtime == null || runtime.UpdateFrequency == UpdateFrequency.None)
            {
                return(false);
            }

            if ((runtime.UpdateFrequency & UpdateFrequency.Once) != 0)
            {
                updateType |= UpdateType.Once;
                runtime.UpdateFrequency &= ~UpdateFrequency.Once;
                if (runtime.UpdateFrequency == UpdateFrequency.None)
                {
                    return(false);
                }
            }

            if ((runtime.UpdateFrequency & UpdateFrequency.Update1) != 0)
            {
                updateType |= UpdateType.Update1;
            }

            if ((runtime.UpdateFrequency & UpdateFrequency.Update10) != 0 && ticks % 10 == 0)
            {
                updateType |= UpdateType.Update10;
            }

            if ((runtime.UpdateFrequency & UpdateFrequency.Update100) != 0 && ticks % 100 == 0)
            {
                updateType |= UpdateType.Update100;
            }

            return(true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Runs the given programmable block
 /// </summary>
 /// <param name="pb"></param>
 /// <param name="argument"></param>
 /// <param name="updateType"></param>
 protected virtual void RunProgrammableBlock(MockProgrammableBlock pb, string argument, UpdateType updateType)
 {
     pb.Run(argument, updateType);
 }
Ejemplo n.º 4
0
 public static void RunUntil(MockProgrammableBlock programmableBlock, Func <Program, Boolean> predicate)
 => RunUntil(programmableBlock.Program as Program, predicate);
Ejemplo n.º 5
0
 public static void RunCycle(MockProgrammableBlock programmableBlock)
 => RunCycle(programmableBlock.Program as Program);