public void UpdateDesiredProductionSpeedTestThreeMachinesWithMiddleStorageOutputDisabled()
        {
            Reset();
            List <Machine> machines = new List <Machine>();

            Machine m1 = CreateMachine(0, 1);

            m1._maximumItemsPerSecond = 5;

            Machine m2 = CreateMachine(1, 1);

            m2._maximumItemsPerSecond = 3;
            m2._storageCapacity       = 1000;
            m2._itemsInStorage        = 1000;
            m2._maximumItemsPerSecond = 1000;

            Machine m3 = CreateMachine(1, 0);

            m3._maximumItemsPerSecond = 4;
            m3._storageCapacity       = 1000;
            m3._storageMode           = Machine.StorageModes.In;

            MachineManager.ConnectMachines(m1, 0, m2, 0);
            MachineManager.ConnectMachines(m2, 0, m3, 0);

            Assert.AreEqual(m1._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m1._itemsPerSecondToStorage, 0);

            Assert.AreEqual(m2._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m2._itemsPerSecondToStorage, 0);

            Assert.AreEqual(m3._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m3._itemsPerSecondToStorage, 3);
        }
Ejemplo n.º 2
0
    public void TryRefreshConnectors()
    {
        List <Tuple <MachineConnector, MachineConnector> > lostConnections = new List <Tuple <MachineConnector, MachineConnector> >();

        foreach (MachineConnector m in _outputs)
        {
            if (m._conveyor != null)
            {
                lostConnections.Add(new Tuple <MachineConnector, MachineConnector>(m._conveyor._output, m._conveyor._input));
                MachineManager.DisconnectMachines(m._conveyor);
            }
        }

        foreach (MachineConnector m in _inputs)
        {
            if (m._conveyor != null)
            {
                lostConnections.Add(new Tuple <MachineConnector, MachineConnector>(m._conveyor._output, m._conveyor._input));
                MachineManager.DisconnectMachines(m._conveyor);
            }
        }

        foreach (Tuple <MachineConnector, MachineConnector> c in lostConnections)
        {
            MachineManager.ConnectMachines(c.Item1, c.Item2);
        }

        MachineManager.UpdateRecipes();
    }
Ejemplo n.º 3
0
 public static void CreateInstance()
 {
     if (_instance == null)
     {
         _instance = new MachineManager();
     }
 }
        public void UpdateDesiredProductionSpeedTestOutputStorageLimited()
        {
            Reset();
            List <Machine> machines = new List <Machine>();

            Machine m1 = CreateMachine(0, 1);

            m1._maximumItemsPerSecond = Single.PositiveInfinity;
            m1._storageCapacity       = 1000;
            m1._itemsInStorage        = 1000;
            m1._storageMode           = Machine.StorageModes.Out;

            Machine m2 = CreateMachine(1, 0);

            m2._maximumItemsPerSecond = 5;
            m2._storageCapacity       = 1000;
            m2._itemsInStorage        = 997;
            m2._storageMode           = Machine.StorageModes.In;

            MachineManager.ConnectMachines(m1, 0, m2, 0);

            Assert.AreEqual(m1._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m1._itemsPerSecondToStorage, -3);

            Assert.AreEqual(m2._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m2._itemsPerSecondToStorage, 3);
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Generates the variables for press
    /// </summary>
    override public void GenerateVariables(MachineManager manager)
    {
        if (m_isGenerated)         //if the machine's already had variables generated, don't do it again
        {
            return;
        }

        //set manager
        m_machineManager = manager;

        //Create interactables
        m_secondBolt.Create(this, PressInteractableType.SECOND_BOLT, m_incorrectTime);
        m_thirdBolt.Create(this, PressInteractableType.THIRD_BOLT, m_incorrectTime);
        m_tightenInk.Create(this, PressInteractableType.TIGHTEN_INK, m_incorrectTime);
        m_loosenInk.Create(this, PressInteractableType.LOOSEN_INK, m_incorrectTime);
        m_yellowLever.Create(this, PressInteractableType.YELLOW_LEVER, m_incorrectTime);
        m_orangeLever.Create(this, PressInteractableType.ORANGE_LEVER, m_incorrectTime);
        m_restartButton.Create(this, PressInteractableType.RESTART_BUTTON, m_incorrectTime, m_buttonHoldTime, m_maxButtonHoldTime);

        //Randomly generates variables for the machine
        CreateNozzle();
        CreateRPM();
        CreateModelNumber();

        //confirm that this machine has been generated
        m_isGenerated = true;
    }
Ejemplo n.º 6
0
        public async Task GetMachinesOne()
        {
            var unitOfWork  = Substitute.For <IUnitOfWork>();
            var rep         = Substitute.For <IMachineRepository>();
            var repC        = Substitute.For <IConfigurationRepository>();
            var userContext = new CNCLibUserContext();

            var ctrl = new MachineManager(unitOfWork, rep, repC, userContext, Mapper);

            var machineEntity = new[]
            {
                new Machine
                {
                    MachineId           = 1,
                    Name                = "Maxi",
                    BufferSize          = 115200,
                    UserId              = userContext.UserId,
                    MachineCommands     = new List <MachineCommand>(),
                    MachineInitCommands = new MachineInitCommand[0]
                }
            };

            rep.GetByUser(userContext.UserId).Returns(machineEntity);

            var machines = (await ctrl.GetAll()).ToArray();

            machines.Length.Should().Be(1);
            machines[0].MachineId.Should().Be(1);
            machines[0].Name.Should().Be("Maxi");
            machines[0].BufferSize.Should().Be(115200);
            machines[0].MachineCommands.Should().NotBeNull();
            machines[0].MachineInitCommands.Should().NotBeNull();
            machines[0].MachineCommands.Count().Should().Be(0);
            machines[0].MachineInitCommands.Count().Should().Be(0);
        }
Ejemplo n.º 7
0
        public async Task DeleteMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(1).Returns(machineEntity1);

            var machine = await ctrl.Get(1);

            machine.Name = "SuperMaxi";

            await ctrl.Delete(machine);

            rep.Received().DeleteRange(Arg.Is <IEnumerable <Machine> >(x => x.First().Name == "SuperMaxi"));
            rep.Received().DeleteRange(Arg.Is <IEnumerable <Machine> >(x => x.First().MachineId == 11));
        }
    /// <summary>
    /// Initially generates the variables the woodchipper might have
    /// </summary>
    /// <param name="manager">The machine manager</param>
    public override void GenerateVariables(MachineManager manager)
    {
        if (m_isGenerated)         //if machine is already generated, don't redo it
        {
            return;
        }

        //Create the variables
        CreateAxle();
        CreateRattlingPipe();
        CreateRotationRate();
        CreateBlades();
        CreatePressure();

        //Create the interactables
        m_buttonA.Create(this, WoodchipperInteractableTypeV2.BUTTON_A, m_incorrectTimeSubtraction);
        m_buttonB.Create(this, WoodchipperInteractableTypeV2.BUTTON_B, m_incorrectTimeSubtraction);
        m_buttonC.Create(this, WoodchipperInteractableTypeV2.BUTTON_C, m_incorrectTimeSubtraction);
        m_buttonD.Create(this, WoodchipperInteractableTypeV2.BUTTON_D, m_incorrectTimeSubtraction);
        m_buttonE.Create(this, WoodchipperInteractableTypeV2.BUTTON_E, m_incorrectTimeSubtraction);

        m_redLever.Create(this, WoodchipperInteractableTypeV2.RED_LEVER, m_incorrectTimeSubtraction);
        m_blueLever.Create(this, WoodchipperInteractableTypeV2.BLUE_LEVER, m_incorrectTimeSubtraction);

        //sets manager
        m_machineManager = manager;

        //set is generated
        m_isGenerated = true;
    }
Ejemplo n.º 9
0
        public async Task QueryOneMachinesNotFound()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 1,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };
            var machineEntity2 = new Machine
            {
                MachineId           = 2,
                Name                = "Mini",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(1).Returns(machineEntity1);
            rep.Get(2).Returns(machineEntity2);

            var machine = await ctrl.Get(3);

            machine.Should().BeNull();
        }
Ejemplo n.º 10
0
        public async Task UpdateMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(11).Returns(machineEntity1);
            rep.GetTracking(Arg.Any <IEnumerable <int> >()).Returns(new[] { machineEntity1 });

            var machine = await ctrl.Get(11);

            machine.Name = "SuperMaxi";

            await ctrl.Update(machine);

            //await rep.Received().Update(11, Arg.Is<Machine>(x => x.Name == "SuperMaxi"));
        }
Ejemplo n.º 11
0
        public static void OnTryChangeBlockUser(ModLoader.OnTryChangeBlockData d)
        {
            if (d.CallbackState == ModLoader.OnTryChangeBlockData.ECallbackState.Cancelled)
            {
                return;
            }

            if (d.TypeNew == Item.ItemIndex && d.TypeOld == BuiltinBlocks.Air)
            {
                if (World.TryGetTypeAt(d.Position.Add(0, -1, 0), out var itemBelow))
                {
                    if (CanMineBlock(itemBelow))
                    {
                        MachineManager.RegisterMachineState(d.RequestedByPlayer,
                                                            new MachineState(d.Position, d.RequestedByPlayer,
                                                                             nameof(Miner)));

                        return;
                    }
                }

                PandaChat.Send(d.RequestedByPlayer, "The mining machine must be placed on stone or ore.",
                               ChatColor.orange);

                d.CallbackState = ModLoader.OnTryChangeBlockData.ECallbackState.Cancelled;
            }
        }
    /// <summary>
    /// Generates the variables the woodchipper may have
    /// Also creates the buttons
    /// </summary>
    override public void GenerateVariables(MachineManager manager)
    {
        if (m_isGenerated)         //if the machine's already had variables generated, don't do it again
        {
            return;
        }

        //set manager
        m_machineManager = manager;

        //Sets up the buttons for the machine
        m_smallMagentaButton.Create(this, WoodchipperInteractableType.SMALL_MAGENTA, m_incorrectTime);
        m_smallYellowButton.Create(this, WoodchipperInteractableType.SMALL_YELLOW, m_incorrectTime);
        m_smallBlackButton.Create(this, WoodchipperInteractableType.SMALL_BLACK, m_incorrectTime);
        m_smallCyanButton.Create(this, WoodchipperInteractableType.SMALL_CYAN, m_incorrectTime);
        m_bigRedButton.Create(this, WoodchipperInteractableType.BIG_RED, m_incorrectTime);

        //Randomly generates variables for the machine
        CreateBlades();
        CreateInputWords();
        CreateWarrantyLabel();
        CreateConveyor();
        CreateLight();

        //confirm that this machine has been generated
        m_isGenerated = true;
    }
Ejemplo n.º 13
0
    Machine CreateMachine(int ins, int outs)
    {
        Machine m = new Machine();

        m.SetSize(new Point(1, System.Math.Max(ins, outs)));
        m._inputs = new MachineConnector[ins];

        for (int i = 0; i < m._inputs.Length; i++)
        {
            m._inputs[i]              = new MachineConnector();
            m._inputs[i]._localDir    = Direction.Left;
            m._inputs[i]._local.X     = 0;
            m._inputs[i]._local.Y     = i;
            m._inputs[i]._input       = true;
            m._inputs[i]._thisMachine = m;
        }

        m._outputs = new MachineConnector[outs];
        for (int i = 0; i < m._outputs.Length; i++)
        {
            m._outputs[i]              = new MachineConnector();
            m._outputs[i]._localDir    = Direction.Right;
            m._outputs[i]._local.X     = 0;
            m._outputs[i]._local.Y     = i;
            m._outputs[i]._input       = false;
            m._outputs[i]._thisMachine = m;
        }
        MachineManager.CreateInstance();
        MachineManager.RegisterMachine(m);
        return(m);
    }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            var nodeParamsDeserialize = new ParametersSerializer <NodeParameters>();
            var nodeParams            = nodeParamsDeserialize.Deserialize("nodeParams.xml");
            var machineManager        = new MachineManager(nodeParams.Ip, nodeParams.Ports.ToArray());

            if (nodeParams.PeerAddress != null)
            {
                machineManager.Register(nodeParams.PeerAddress);
            }
            var cont = true;

            while (cont)
            {
                PrintMenu();
                var c = Console.ReadKey().KeyChar;
                Console.WriteLine("\n\n");

                switch (c)
                {
                case '1':
                    var r = PerformCalculations(machineManager);
                    Console.WriteLine("Value: {0}", r.FitnessValue[0]);
                    break;

                case '0':
                    cont = false;
                    break;
                }
            }
        }
Ejemplo n.º 15
0
        public MachineState(Vector3Int pos, Players.Player owner, string machineType)
        {
            Position    = pos;
            MachineType = machineType;
            Owner       = owner;

            MachineSettings = MachineManager.GetCallbacks(machineType);
        }
Ejemplo n.º 16
0
        public void GetMachineById()
        {
            var machineManager = new MachineManager(mockedServiceProvider);
            var result         = machineManager.GetMachineById(1);

            Assert.AreEqual(1, result.Id, "ID nicht korrekt");
            Assert.AreEqual("Test machine one", result.Name, "Name not correct");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WinRmMachineManager"/> class.
        /// </summary>
        /// <param name="address">Address of machine.</param>
        /// <param name="userName">User name to connect with.</param>
        /// <param name="password">Password for provided user name.</param>
        /// <param name="autoManageTrustedHosts">A value indicating whether or not to automatically manage trusted hosts.</param>
        public WinRmMachineManager(string address, string userName, string password, bool autoManageTrustedHosts)
        {
            new { address }.AsArg().Must().NotBeNullNorWhiteSpace();

            this.Address = address;

            this.machineManager = new MachineManager(this.Address, userName, password.ToSecureString(), autoManageTrustedHosts);
        }
Ejemplo n.º 18
0
        public static void RegisterMachines()
        {
            MachineManager.MachineRemoved += MachineManager_MachineRemoved;

            MachineManager.RegisterMachineType(new MachineManager.MachineSettings(nameof(TeleportPad), Item.ItemIndex,
                                                                                  Repair, Refuel, Reload, DoWork, 10, 4,
                                                                                  5, 10));
        }
Ejemplo n.º 19
0
        public void Test1()
        {
            // Arrange
            var sut = new MachineManager(_fixture.Create <IMachineFactory>(), 10);

            // Act
            sut.GetMachine("M1").MachineName.Should().Be("M1");
        }
Ejemplo n.º 20
0
        private static ParticleState PerformCalculations(MachineManager machineManager)
        {
            var psoParamsDeserialize = new ParametersSerializer <PsoParameters>();
            var psoParams            = psoParamsDeserialize.Deserialize("psoParams.xml");

            machineManager.StartPsoAlgorithm(psoParams);
            return(machineManager.GetResult());
        }
Ejemplo n.º 21
0
        public void GetSingleMachine()
        {
            var machineManager = new MachineManager(mockedServiceProvider);
            var testValue      = 1;
            var result         = machineManager.GetMachineById(testValue);

            Assert.AreEqual(1, result.Id, "ID not correct");
            Assert.AreEqual("Test machine one", result.Name, "Name not correct");
        }
Ejemplo n.º 22
0
        public void GetMachineForDataValue()
        {
            var machineManager = new MachineManager(mockedServiceProvider);
            var result         = machineManager.GetMachineForDataValue(100);

            Assert.AreEqual(1, result.Count(), "Machines for value 100 not correct");
            result = machineManager.GetMachineForDataValue(101);
            Assert.AreEqual(1, result.Count(), "Machines for value 101 not correct");
        }
Ejemplo n.º 23
0
        public void GetAllMachines()
        {
            var machineManager = new MachineManager(mockedServiceProvider);
            var result         = machineManager.GetAllMachines();

            Assert.IsNotNull(result, "Result was NULL"); // Test function
            var count = result.Count();

            Assert.AreEqual(2, count, "COUNT failed"); // Test function
        }
Ejemplo n.º 24
0
        public void GetMachinesWithDevices()
        {
            var machineManager = new MachineManager(mockedServiceProvider);
            var result         = machineManager.GetAllMachines().Select(m => m.HasDevices);

            Assert.IsNotNull(result, "Result was NULL");
            var count = result.Count();

            Assert.AreEqual(1, count, "COUNT failed");
        }
Ejemplo n.º 25
0
        public static void Examples()
        {
            var machineManager = new MachineManager(
                "10.0.0.1",
                "Administrator",
                "password".ToSecureString(),
                autoManageTrustedHosts: true);

            var powershellFileObjects = machineManager.RunScript("{ param($path) ls $path }", new[] { @"D:\Temp" });
        }
Ejemplo n.º 26
0
    protected override bool OnCursorClickInternal(Point tile)
    {
        Machine machine = MachineManager.GetInstance().GetMachineAtPoint(tile);

        if (machine != null)
        {
            SetSubstate(new InputStateMachineSelected(machine));
            return(true);
        }

        return(false);
    }
Ejemplo n.º 27
0
        public void CreateMachine_VerifyMachineExistsInListOfMachines_ReturnTrue()
        {
            Machine machine = new Machine()
            {
                MachineId   = "IDX147",
                MachineName = "Machine147"
            };
            MachineManager machineMgr = new MachineManager();

            machineMgr.CreateMachine(machine);
            Assert.IsNotNull(machineMgr.Machines.FirstOrDefault(x => x.MachineName == "Machine147" && x.MachineId == "IDX147"));
        }
Ejemplo n.º 28
0
        public async Task GetDefaultMachineNotSet()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            repC.Get(1, "Environment", "DefaultMachineId").Returns((Configuration)null);

            (await ctrl.GetDefaultMachine()).Should().Be(-1);
        }
Ejemplo n.º 29
0
    protected override bool OnCursorClickInternal(Point tile)
    {
        Machine machine = MachineManager.GetInstance().GetMachineAtPoint(tile);

        if (machine == _selectedMachine)
        {
            TerminateState();
            return(true);
        }

        return(false);
    }
Ejemplo n.º 30
0
 private void InitObjects()
 {
     Users = new UserManager(context);
     Rulos = new RuloManager(context);
     DefinationProcesses = new DefinationProcessManager(context);
     Machines            = new MachineManager(context);
     TestResults         = new TestResultManager(context);
     Floors           = new FloorManager(context);
     OriginCategories = new OriginCategoryManager(context);
     TestCategories   = new TestCategoryManager(context);
     Samples          = new SampleManager(context);
 }
 /// <summary>
 /// When it is needed, the singleton is called
 /// </summary>
 private void Awake()
 {
     instance = this;
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Upon its creation, the MonoObserver will subscribe itself to the 
 /// Subject contained in manager.
 /// </summary>
 protected void Start()
 {
     manager = MachineManager.Instance;
     manager.subscribe(this);
 }
 void Start()
 {
     theManager = MachineManager.Instance;
     triggered = false;
 }