コード例 #1
0
ファイル: WireEnd.cs プロジェクト: yaakgold/GMTK-2020
    public void PlugInWire()
    {
        RaycastHit h;

        if (Physics.Raycast(transform.position, -Vector3.up, out h))
        {
            if (h.transform.CompareTag("Wire Port"))
            {
                wp     = h.transform.GetComponent <WirePort>();
                pos    = h.transform.position;
                pos.y += .1f;
                transform.position = pos;
                isOnWirePort       = true;

                wp.isOpen = false;

                PowerSupply wpps = wp.GetComponent <PowerSupply>();

                if (wpps != null)
                {
                    wpps.hasBeenPluggedIn = true;
                }
            }
        }
    }
コード例 #2
0
        //validate the pc configuration
        private string ValidatePCConfiguration(Motherboard motherboard, CPU cpu, PowerSupply powerSupply, IEnumerable <MemorySelectViewModel> memories)
        {
            if (memories.Sum(item => item.Count) == 0)
            {
                return("You have to select at least one memory type.");
            }
            if (cpu.CPUSocketId != motherboard.CPUSocketId)
            {
                return("The CPU must has the same socket as the motherboard.");
            }
            if (memories.Sum(item => item.Count) > motherboard.MemorySlots)
            {
                return("Motherboard contains memory slots less than the number of memories you have selected");
            }
            //compute total power consumption
            var totalPowerCons = cpu.PowerConsumption + motherboard.PowerConsumption +
                                 memories.Sum(item => item.PowerConsumption * item.Count);

            //the max output power of the power supply should exceed the total consumprion power by 10%
            if (powerSupply.MaxPowerOutput < (totalPowerCons + (.1 * totalPowerCons)))
            {
                var message = "The power output of the power supply you have selected is not enough for this PC";
                //get lowest power supply enough for this configuation
                var suggestedPowerSupply = _powerSupplyService.All.OrderBy(item => item.MaxPowerOutput).FirstOrDefault(item => item.MaxPowerOutput >= (totalPowerCons + (.1 * totalPowerCons)));
                if (suggestedPowerSupply != null)
                {
                    message += Environment.NewLine + "\nSuggested power supply is \"" + suggestedPowerSupply.Name + "\"";
                }
                return(message);
            }
            return(string.Empty);
        }
コード例 #3
0
ファイル: WireEnd.cs プロジェクト: yaakgold/GMTK-2020
    private void Start()
    {
        cam = Camera.main;
        cc  = GetComponentInParent <ComputerComponent>();

        if (isSelected)
        {
            RaycastHit h;
            if (Physics.Raycast(transform.position, -Vector3.up, out h))
            {
                if (h.transform.CompareTag("Wire Port"))
                {
                    wp     = h.transform.GetComponent <WirePort>();
                    pos    = h.transform.position;
                    pos.y += .1f;
                    transform.position = pos;
                    isOnWirePort       = true;

                    wp.isOpen = false;

                    PowerSupply wpps = wp.GetComponent <PowerSupply>();

                    if (wpps != null)
                    {
                        wpps.hasBeenPluggedIn = true;
                    }
                }
            }
            isSelected = false;
        }
    }
コード例 #4
0
        public async Task <IActionResult> Create(PowerSupply powerSupplyModel)
        {
            try
            {
                if (powerSupplyModel.ImageFile != null)
                {
                    powerSupplyModel.ImageTitle = powerSupplyModel.ImageFile.FileName;
                    powerSupplyModel.ImageData  = ImageManager.GetByteArrayFromImage(powerSupplyModel.ImageFile);
                }

                using (var httpClient = new HttpClient())
                {
                    var content = new StringContent(JsonConvert.SerializeObject(powerSupplyModel), Encoding.UTF8, "application/json");

                    using (HttpResponseMessage response = await httpClient.PostAsync(string.Format("{0}/{1}", this.apiBaseUrl, this.apiController), content))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        //receivedReservation = JsonConvert.DeserializeObject<Reservation>(apiResponse);
                    }
                }

                return(this.RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(this.View());
            }
        }
コード例 #5
0
        private IOperation BuildShellOperation()
        {
            var aboutInfo       = new AboutNotificationInfo(text);
            var aboutController = new AboutNotificationController(context.AppConfig, uiFactory);
            var audio           = new Audio(context.Settings.Audio, ModuleLogger(nameof(Audio)));
            var keyboard        = new Keyboard(ModuleLogger(nameof(Keyboard)));
            var logInfo         = new LogNotificationInfo(text);
            var logController   = new LogNotificationController(logger, uiFactory);
            var powerSupply     = new PowerSupply(ModuleLogger(nameof(PowerSupply)));
            var wirelessAdapter = new WirelessAdapter(ModuleLogger(nameof(WirelessAdapter)));
            var operation       = new ShellOperation(
                actionCenter,
                audio,
                aboutInfo,
                aboutController,
                context,
                keyboard,
                logger,
                logInfo,
                logController,
                powerSupply,
                systemInfo,
                taskbar,
                taskview,
                text,
                uiFactory,
                wirelessAdapter);

            context.Activators.Add(new ActionCenterKeyboardActivator(ModuleLogger(nameof(ActionCenterKeyboardActivator)), nativeMethods));
            context.Activators.Add(new ActionCenterTouchActivator(ModuleLogger(nameof(ActionCenterTouchActivator)), nativeMethods));
            context.Activators.Add(new TaskviewKeyboardActivator(ModuleLogger(nameof(TaskviewKeyboardActivator)), nativeMethods));
            context.Activators.Add(new TerminationActivator(ModuleLogger(nameof(TerminationActivator)), nativeMethods));

            return(operation);
        }
コード例 #6
0
        public void EquipmentTest_Basic()
        {
            Equipment e = new Equipment("0");

            e.Execute(new Command("PowerOn"));

            Port b = new Port("0");

            b.Execute(
                new Command(
                    "Send",
                    new Dictionary <string, string>()
            {
                {
                    "Bytes",
                    "00 01 02"
                }
            }
                    )
                );

            PowerSupply ps = new PowerSupply("0");

            ps.Execute(new Command("PowerOn"));

            ps.PPort = new Port("0");
            ps.Execute(new Command("PowerOn"));
            ps.Execute(new Command("PowerOff"));

            HardwareSrv hardware = HardwareSrv.GetInstance();

            hardware.Add(e);
        }
コード例 #7
0
ファイル: Controller.cs プロジェクト: BlagoKolev/SoftUni
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            CheckIfComputerExist(computerId);

            if (this.components.Any(x => x.Id == id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            IComponent component = null;

            switch (componentType)
            {
            case "CentralProcessingUnit": component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation); break;

            case "Motherboard": component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation); break;

            case "PowerSupply": component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation); break;

            case "RandomAccessMemory": component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation); break;

            case "SolidStateDrive": component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation); break;

            case "VideoCard": component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation); break;

            default: throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }
            IComputer computer = this.computers.FirstOrDefault(x => x.Id == computerId);

            computer.AddComponent(component);
            this.components.Add(component);

            return(string.Format(SuccessMessages.AddedComponent, component.GetType().Name, component.Id, computerId));
        }
コード例 #8
0
        public ActionResult Addpowersupply(PowerSupply powersupply)
        {
            Session["powersupply"]     = powersupply;
            Session["powersupplyname"] = powersupply.Name;

            return(RedirectToAction("List", "Home"));
        }
コード例 #9
0
 //---------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Объединение данных
 /// </summary>
 /// <param name="engineering_infrastructure">Инженерная инфраструктура</param>
 //---------------------------------------------------------------------------------------------------------
 public void Union(CEngineeringInfrastructure engineering_infrastructure)
 {
     WaterSupply.Union(engineering_infrastructure.WaterSupply);
     PowerSupply.Union(engineering_infrastructure.PowerSupply);
     GasSupply.Union(engineering_infrastructure.GasSupply);
     HeatSupply.Union(engineering_infrastructure.HeatSupply);
 }
コード例 #10
0
 public ActionResult ChangePowerSupply(PowerSupply p, HttpPostedFileBase NewImage, bool IsDeletePreviousImageFromServer = false, int page = 1, int pageSize = 20)
 {
     ViewBag.page     = page;
     ViewBag.pageSize = pageSize;
     if (ModelState.IsValid)
     {
         if (NewImage != null)
         {
             if (NewImage.ContentLength <= 200000)
             {
                 AddOrAddRemoveImageForCatalog(NewImage, IsDeletePreviousImageFromServer, p);
             }
             else
             {
                 ModelState.AddModelError("NewImage", "Изображение должно быть меньше 200 Кб");
                 return(View(pcComponentsUnit.PowerSupplies.GetElement(p.ID)));
             }
         }
         p.FullName = string.Format($"{p.Category} {p.Power}W {p.Model} ({p.ID})");
         pcComponentsUnit.PowerSupplies.Update(p);
         pcComponentsUnit.Save();
         return(RedirectToActionPermanent("ComponentsCatalog", "Catalog", new { category = p.Category, page, pageSize }));
     }
     return(View(pcComponentsUnit.PowerSupplies.GetElement(p.ID)));
 }
コード例 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Manufacturer,Power,Width,Height,Thickness,Price")] PowerSupply powerSupply)
        {
            if (id != powerSupply.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(powerSupply);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PowerSupplyExists(powerSupply.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(powerSupply));
        }
コード例 #12
0
        public ActionResult Save()
        {
            Build       build       = new Build();
            Case        Case        = (Case)Session["cases"];
            CPU         cpu         = (CPU)Session["Cpu"];
            VideoCard   videoCard   = (VideoCard)Session["videocard"];
            Motherboard motherBoard = (Motherboard)Session["motherboard"];
            PowerSupply powerSupply = (PowerSupply)Session["powersupply"];
            Memory      memory      = (Memory)Session["memory"];
            Storage     storage     = (Storage)Session["storage"];


            build.CaseId        = Case.Id;
            build.MemoryId      = memory.Id;
            build.VideoCardId   = videoCard.Id;
            build.MotherboardId = motherBoard.Id;
            build.PowerSupplyId = powerSupply.Id;
            build.CPUId         = cpu.Id;
            build.StorageId     = storage.Id;

            _context.Builds.Add(build);
            _context.SaveChanges();

            return(RedirectToAction("AllBuilds"));
        }
コード例 #13
0
        public async Task <IActionResult> Edit(Guid id, PowerSupply powerSupplyModel)
        {
            try
            {
                if (powerSupplyModel == null)
                {
                    return(this.NotFound());
                }

                if (powerSupplyModel.ImageFile != null)
                {
                    powerSupplyModel.ImageTitle = powerSupplyModel.ImageFile.FileName;
                    powerSupplyModel.ImageData  = ImageManager.GetByteArrayFromImage(powerSupplyModel.ImageFile);
                }

                powerSupplyModel.PowerSupplyId = id;

                string accessToken = await this.HttpContext.GetTokenAsync("access_token");

                await ApiRequests.PutAsync(accessToken, string.Format("{0}/{1}", this.apiBaseUrl, this.apiController), powerSupplyModel);

                return(this.RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(this.View());
            }
        }
コード例 #14
0
ファイル: Controller.cs プロジェクト: ivaKozarova/CSharpOOP
        private IComponent CreateComponent(string componentType, int id, string manufacturer,
                                           string model, decimal price, double overallPerformance,
                                           int generation)
        {
            IComponent component = null;

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            return(component);
        }
コード例 #15
0
        public void PowerSuppliesController_ShouldReturnViewResultWithPowerSupplyBindingModel()
        {
            var dbPowerSupply = new PowerSupply()
            {
                Connector            = "36 pin",
                Effectiveness        = 99,
                Manufacturer         = "ConnectorsInc",
                ModelName            = "con",
                NumberOfCoolingVents = 2,
                Pfc   = "pcf",
                Power = 1000,
                Price = 1500
            };

            dbContext.PowerSupplies.Add(dbPowerSupply);
            dbContext.SaveChanges();

            var id = dbContext.PowerSupplies.First().Id;

            var result = this.controller.Edit(id);

            Assert.IsInstanceOfType(result, typeof(ViewResult));

            var resultViewModel = (result as ViewResult).Model;

            Assert.IsInstanceOfType(resultViewModel, typeof(PowerSupplyBindingModel));
        }
コード例 #16
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            var computer = this.computers.FirstOrDefault(x => x.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException(ExceptionMessages.NotExistingComputerId);
            }

            IComponent component = null;

            if (this.components.Any(x => x.Id == id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }

            return(string.Format(SuccessMessages.AddedComponent, componentType, component.Id, computer.Id));
        }
コード例 #17
0
        public void ConstructorShouldOpenPort()
        {
            var serialPort = new MockSerialPort();

            var powerSupply = new PowerSupply(serialPort);

            Assert.That(serialPort.IsOpen);
        }
コード例 #18
0
ファイル: PowerSupplyEditor.cs プロジェクト: L3SHA/OOP-Labs
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      powerSupply = new PowerSupply(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbEfficiency.Text), int.Parse(tbPower.Text));
            IStorage storage     = ListItemStorage.GetInstance();

            storage.AddItem(powerSupply);
            this.Close();
        }
コード例 #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            PowerSupply powerSupply = db.PowerSupplies.Find(id);

            db.PowerSupplies.Remove(powerSupply);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #20
0
        public OperationDetails CreatePowerSupply(PowerSupply powerSupply)
        {
            Database.PowerSupplies.Create(powerSupply);
            SetPowerSupplyCPUInterfaces(powerSupply, (List <PowerSupplyPowerSupplyCPUInterface>)powerSupply.PowerSupplyPowerSupplyCPUInterfaces);
            Database.Save();

            return(new OperationDetails(true, "Ok", ""));
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: prsquared/SOLIDAssignment1
 public Computer()
 {
     devices[0] = new Motherboard();
     devices[1] = new Cpu();
     devices[2] = new Ram();
     devices[3] = new HardDrive();
     devices[4] = new PowerSupply();
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: inspera/Chrominimum
        internal SEBContext(AppSettings settings)
        {
            appSettings   = settings;
            logger        = new Logger();
            hashAlgorithm = new HashAlgorithm();

            InitializeLogging();
            InitializeText();

            _dispatcher = Dispatcher.CurrentDispatcher;

            uiFactory  = new UserInterfaceFactory(text);
            messageBox = new MessageBoxFactory(text);

            taskbar = uiFactory.CreateTaskbar(logger);
            taskbar.QuitButtonClicked += Shell_QuitButtonClicked;
            taskbar.Show();

            workingAreaHandler = new WorkingAreaHandler(new ModuleLogger(logger, nameof(WorkingAreaHandler)));
            workingAreaHandler.InitializeWorkingArea(taskbar.GetAbsoluteHeight());

            taskview = uiFactory.CreateTaskview();

            var audioSettings = new AudioSettings();
            var audio         = new Audio(audioSettings, new ModuleLogger(logger, nameof(Audio)));

            audio.Initialize();
            taskbar.AddSystemControl(uiFactory.CreateAudioControl(audio, Location.Taskbar));

            var keyboard = new Keyboard(new ModuleLogger(logger, nameof(Keyboard)));

            keyboard.Initialize();
            taskbar.AddSystemControl(uiFactory.CreateKeyboardLayoutControl(keyboard, Location.Taskbar));

            var powerSupply = new PowerSupply(new ModuleLogger(logger, nameof(PowerSupply)));

            powerSupply.Initialize();
            taskbar.AddSystemControl(uiFactory.CreatePowerSupplyControl(powerSupply, Location.Taskbar));

            var wirelessAdapter = new WirelessAdapter(new ModuleLogger(logger, nameof(WirelessAdapter)));

            wirelessAdapter.Initialize();
            taskbar.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.Taskbar));

            browser = new BrowserApplication(appSettings, messageBox, true, new ModuleLogger(logger, nameof(BrowserApplication)), text);
            taskbar.AddApplicationControl(uiFactory.CreateApplicationControl(browser, Location.Taskbar), true);
            browser.TerminationRequested += () =>
            {
                Browser_TerminationRequested();
            };

            taskview.Add(browser);
            InitializeCef();
            foreach (string startUrl in appSettings.StartUrls)
            {
                browser.CreateNewInstance(startUrl);
            }
        }
コード例 #23
0
        public void WritesVoltageValueCorrectToSerialPort()
        {
            var serialPort  = new MockSerialPort();
            var powerSupply = new PowerSupply(serialPort);

            powerSupply.SetVoltage(13.7);

            Assert.That(serialPort.LastWrittenLine, Is.EqualTo("SV137"));
        }
コード例 #24
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            if (!IsComputerExist(computerId))
            {
                throw new ArgumentException("Computer with this id does not exist.");
            }

            if (components.Any(x => x.Id == id))
            {
                throw new ArgumentException("Component with this id already exists.");
            }

            IComponent component = null;

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            else
            {
                throw new ArgumentException("Component type is invalid.");
            }

            var computer = computers.FirstOrDefault(c => c.Id == computerId);

            computer.AddComponent(component);
            components.Add(component);

            return($"Component {component.GetType().Name} with id {component.Id} added successfully in computer with id {computer.Id}.");
        }
コード例 #25
0
        public Circuit()
        {
            elements = new List <Element>();

            power = new PowerSupply();

            Voltage_sum    = 0;
            Current_sum    = 0;
            Resistance_sum = 0;
        }
コード例 #26
0
 public ActionResult Edit([Bind(Include = "IDPowerSupply,Name,Power,Standard,Certificate,Description,Price")] PowerSupply powerSupply)
 {
     if (ModelState.IsValid)
     {
         db.Entry(powerSupply).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(powerSupply));
 }
コード例 #27
0
        // GET: PowerSupplies/Edit/5
        public async Task <IActionResult> Edit(Guid id)
        {
            string accessToken = await this.HttpContext.GetTokenAsync("access_token");

            string response = await ApiRequests.GetAsync(accessToken, string.Format("{0}/{1}/{2}", this.apiBaseUrl, this.apiController, id));

            PowerSupply powerSupply = JsonConvert.DeserializeObject <PowerSupply>(response);

            return(this.View(powerSupply));
        }
コード例 #28
0
 /// <summary>
 /// Gets all PowerSupplies from the database
 /// </summary>
 /// <returns>A PowerSupply[] of all PowerSupplies in the database</returns>
 public static PowerSupply[] GetAll()
 {
     string[]      result = Queries.Query("SELECT * FROM `powersupply`");
     PowerSupply[] arr    = new PowerSupply[result.Length];
     for (int i = 0; i < result.Length; i++)
     {
         arr[i] = GetFromQuery(result[i]);
     }
     return(arr);
 }
コード例 #29
0
        public OperationDetails UpdatePowerSupply(PowerSupply powerSupply)
        {
            Database.PowerSupplies.Update(powerSupply);
            //SetPowerSupplyCPUInterfaces(powerSupply, (List<PowerSupplyPowerSupplyCPUInterface>)powerSupply.PowerSupplyPowerSupplyCPUInterfaces);
            Database.Save();
            powerSupply = GetPowerSupply(powerSupply.Id);
            _computerAssemblyService.OnPowerSupplyChange(powerSupply);
            Database.Save();

            return(new OperationDetails(true, "Ok", ""));
        }
コード例 #30
0
        public ActionResult Create([Bind(Include = "IDPowerSupply,Name,Power,Standard,Certificate,Description,Price")] PowerSupply powerSupply)
        {
            if (ModelState.IsValid)
            {
                db.PowerSupplies.Add(powerSupply);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(powerSupply));
        }
コード例 #31
0
ファイル: Player.cs プロジェクト: rhyok/hue-r
    //void renderInfoPane(float left, float top, float width, float height
    Motherboard fabricateDebugRig()
    {
        Motherboard returnMobo = new Motherboard();

        returnMobo.name = "Mother of All Boards";

        CPU         debugCPU        = new CPU           ("Hammond DebugHammer 750XL",           Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 30, 0, 1, 6, 32);
        GPU         debugGPU        = new GPU           ("Zhu Industries Mothra 8800",          Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 20, 0, 3, 1);
        HDD         debugHDD        = new HDD           ("DataPlatter Stack 5",                 Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 2, 0, 10, 8);
        RAM         debugRAM        = new RAM           ("RYAM Interceptor 1 MB",               Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 1, 0, 1, 10, 1);
        PowerSupply debugPower      = new PowerSupply   ("ArEmEs 200W Power Supply",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 200);
        CompInput   debugInput      = new CompInput     ("Cobra Katana",                        Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 50, 60, false);
        CompOutput  debugOutput     = new CompOutput    ("AudiVisual AV2350",                   Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 320, 30, 5);
        CompNetwork debugNet        = new CompNetwork   ("Digiline Dial-up Package",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, NetworkType.DIALUP, 40, 4);
        Chassis     debugChassis    = new Chassis       ("CompuTech Tower of Power",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 10);

        GPU         badGPU          = new GPU           ("Bad GPU",                             Company.COMPUTECH, 125.0f, "Pudding Cup Interface", 20, 0, 3, 1);

        returnMobo.CPUInterface         = DEBUG_INTERFACE;
        returnMobo.GPUInterface         = DEBUG_INTERFACE;
        returnMobo.HDDInterface         = DEBUG_INTERFACE;
        returnMobo.RAMInterface         = DEBUG_INTERFACE;
        returnMobo.powerInterface       = DEBUG_INTERFACE;
        returnMobo.compInputInterface   = DEBUG_INTERFACE;
        returnMobo.compOutputInterface  = DEBUG_INTERFACE;
        returnMobo.networkInterface     = DEBUG_INTERFACE;
        returnMobo.formFactor           = DEBUG_INTERFACE;

        returnMobo.plugIn(debugCPU);
        returnMobo.plugIn(debugGPU);
        returnMobo.plugIn(debugHDD);
        returnMobo.plugIn(debugRAM);
        returnMobo.plugIn(debugInput);
        returnMobo.plugIn(debugOutput);
        returnMobo.plugIn(debugNet);
        returnMobo.plugIn(debugPower);
        returnMobo.plugIn(debugChassis);

        return returnMobo;
    }
コード例 #32
0
ファイル: Parts.cs プロジェクト: rhyok/hue-r
    public bool plugIn(Part part)
    {
        bool returnValue = false;

        if (part.GetType() == typeof(CPU))
        {
            if (part.partInterface == CPUInterface)
            {
                this.cpu = (CPU) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(GPU))
        {
            if (part.partInterface == GPUInterface)
            {
                this.gpu = (GPU)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(HDD))
        {
            if (part.partInterface == HDDInterface)
            {
                this.hdd = (HDD)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(RAM))
        {
            if (part.partInterface == RAMInterface)
            {
                this.ram = (RAM)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompInput))
        {
            if (part.partInterface == compInputInterface)
            {
                this.input = (CompInput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompOutput))
        {
            if (part.partInterface == compOutputInterface)
            {
                this.output = (CompOutput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompNetwork))
        {
            if (part.partInterface == networkInterface)
            {
                this.network = (CompNetwork) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(PowerSupply))
        {
            if (part.partInterface == powerInterface)
            {
                this.pSupply = (PowerSupply)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(Chassis))
        {
            if (part.partInterface == formFactor)
            {
                this.chassis = (Chassis)part;
                returnValue = true;
            }
        }

        return returnValue;
    }
コード例 #33
0
ファイル: Parts.cs プロジェクト: rhyok/hue-r
 public Motherboard(string name, float price, float defectiveChance, string CPUI, string GPUI, string HDDI, string RAMI, 
     string powerI, string compInputI, string compOutputI, string networkI, string formFactor,
     CPU cpu, GPU gpu, HDD hdd, RAM ram, CompInput input, CompOutput output, CompNetwork network,
     PowerSupply pSupply, Chassis chassis)
 {
     this.name                   = name;
     this.price                  = price;
     this.defectiveChance        = defectiveChance;
     this.CPUInterface           = CPUI;
     this.GPUInterface           = GPUI;
     this.HDDInterface           = HDDI;
     this.RAMInterface           = RAMI;
     this.powerInterface         = powerI;
     this.compInputInterface     = compInputI;
     this.compOutputInterface    = compOutputI;
     this.networkInterface       = networkI;
     this.formFactor             = formFactor;
     this.cpu                    = cpu;
     this.gpu                    = gpu;
     this.hdd                    = hdd;
     this.ram                    = ram;
     this.input                  = input;
     this.output                 = output;
     this.network                = network;
     this.pSupply                = pSupply;
     this.chassis                = chassis;
 }
コード例 #34
0
ファイル: PartGenerator.cs プロジェクト: rhyok/hue-r
    public object generatePart(Type partType, Company company)
    {
        object returnPart = null;
        if (partType == typeof(CPU))
        {
            /*
            CPU = new CPU(
                generatePartName(partType, company),
                companyToString(company),
                499.0f,
                "Generic Interface",
                100,
                1
                )
             * */

            returnPart = new CPU(generatePartName(partType, company),
                company,
                500.0f * (float)CPU[company] * (float)CPU[company],
                "Debug",
                100 * (int)((float)CPU[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1),
                rand.Next(ranges.PE1980.cpu_ClockRange.getLeft(), ranges.PE1980.cpu_ClockRange.getRight() + 1),
                rand.Next(ranges.PE1980.cpu_BitsRange.getLeft(), ranges.PE1980.cpu_BitsRange.getRight() + 1)
                );

            //returnPart = new CPU(generatePartName(partType, company),
            //    company,
            //    500.0f * (float)CPU[company] * (float)CPU[company],
            //    "Debug",
            //    100 * (int)((float)CPU[company] * 100.0f) / 100,
            //    1.0f,
            //    rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1), 1, 1);

        }
        else if (partType == typeof(GPU))
        {
            returnPart = new GPU(generatePartName(partType, company),
                company,
                 500.0f * (float)GPU[company] * (float)GPU[company],
                "Debug",
                200 * (int)((float)GPU[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.gpu_MegaflopsRange.getLeft(), ranges.PE1980.gpu_MegaflopsRange.getRight() + 1),
                rand.Next(ranges.PE1980.gpu_MemoryRange.getLeft(), ranges.PE1980.gpu_MemoryRange.getRight() + 1)
                );
        }
        else if (partType == typeof(HDD))
        {
            returnPart = new HDD(generatePartName(partType, company),
                company,
                 500.0f * (float)HDD[company] * (float)HDD[company],
                "Debug",
                5 * (int)((float)HDD[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.hdd_SizeRange.getLeft(), ranges.PE1980.hdd_SizeRange.getRight() + 1),
                rand.Next(ranges.PE1980.hdd_SpeedRange.getLeft(), ranges.PE1980.hdd_SpeedRange.getRight() + 1)
                );
        }
        else if (partType == typeof(RAM))
        {
            returnPart = new RAM(generatePartName(partType, company),
                company,
                 500.0f * (float)RAM[company] * (float)RAM[company],
                "Debug",
                5 * (int)((float)RAM[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.ram_SizeRange.getLeft(), ranges.PE1980.ram_SizeRange.getRight() + 1),
                rand.Next(ranges.PE1980.ram_SpeedRange.getLeft(), ranges.PE1980.ram_SpeedRange.getRight() + 1),
                rand.Next(ranges.PE1980.ram_ChannelsRange.getLeft(), ranges.PE1980.ram_ChannelsRange.getRight() + 1)
                );
        }
        else if (partType == typeof(CompInput))
        {
            returnPart = new CompInput(generatePartName(partType, company),
                company,
                 500.0f * (float)INPUT[company] * (float)INPUT[company],
                "Debug",
                5 * (int)((float)INPUT[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.input_DPIRange.getLeft(), ranges.PE1980.input_DPIRange.getRight() + 1),
                rand.Next(ranges.PE1980.input_PollingRange.getLeft(), ranges.PE1980.input_PollingRange.getRight() + 1),
                rand.Next(10) <= 7 ? false : true
                );
        }
        else if (partType == typeof(CompOutput))
        {
            returnPart = new CompOutput(generatePartName(partType, company),
                company,
                 500.0f * (float)OUTPUT[company] * (float)OUTPUT[company],
                "Debug",
                50 * (int)((float)OUTPUT[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.output_ResolutionRange.getLeft(), ranges.PE1980.output_ResolutionRange.getRight() + 1),
                rand.Next(ranges.PE1980.output_RefreshRange.getLeft(), ranges.PE1980.output_RefreshRange.getRight() + 1),
                rand.Next(ranges.PE1980.output_SQRange.getLeft(), ranges.PE1980.output_SQRange.getRight() + 1)
                );
        }
        else if (partType == typeof(CompNetwork))
        {
            returnPart = new CompNetwork(generatePartName(partType, company),
                company,
                 500.0f * (float)NETWORK[company] * (float)NETWORK[company],
                "Debug",
                0,
                1.0f,
                rand.Next(2) == 0 ? ranges.PE1980.network_TypeRange.getLeft() : ranges.PE1980.network_TypeRange.getRight(),
                rand.Next(ranges.PE1980.network_PingRange.getLeft(), ranges.PE1980.network_PingRange.getRight() + 1),
                rand.Next(ranges.PE1980.network_BandwidthRange.getLeft(), ranges.PE1980.network_BandwidthRange.getRight() + 1)
                );
        }
        else if (partType == typeof(PowerSupply))
        {
            returnPart = new PowerSupply(generatePartName(partType, company),
                company,
                 500.0f * (float)PSU[company] * (float)PSU[company],
                "Debug",
                0,
                1.0f,
                rand.Next(ranges.PE1980.pSupply_WattageRange.getLeft(), ranges.PE1980.pSupply_WattageRange.getRight() + 1)
                );
        }
        else if (partType == typeof(Chassis))
        {
            returnPart = new Chassis(generatePartName(partType, company),
                company,
                 500.0f * (float)CHASSIS[company] * (float)CHASSIS[company],
                "Debug",
                0,
                1.0f,
                rand.Next(ranges.PE1980.chassis_CoolRange.getLeft(), ranges.PE1980.chassis_CoolRange.getRight() + 1)
                );
        }
        else if (partType == typeof(Motherboard))
        {
            returnPart = new Motherboard(generatePartName(partType, company),
                500.0f * (float)MOBO[company] * (float)MOBO[company],
                1.0f,
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null
                );
        }
        return returnPart;
    }