private void newHardware_Button_Click(object sender, EventArgs e) { int id = Reader.GetAllHardware().Count + 1; int type; switch (newHardware_PlatformBox.Text) { case "Computer": type = 1; break; case "XBox One": type = 2; break; case "PlayStation 4": type = 3; break; default: type = -1; break; } if (type == -1) { return; } HardwareData newHardware = new HardwareData { ID = id, HardwareType = type, Name = $"{newHardware_PlatformBox.Text}{id}", Booked = false }; Writer.AddHardware(newHardware); MessageBox.Show("Hardware added succesfully!", "Hardware adding", MessageBoxButtons.OK); }
void AssignSubtypeData(int index) { Type hardwareSubtype = InventoryController.Inventory.EquippedActiveSubtypes[index]; HardwareData subtypeScriptableObject = ScriptableObject.CreateInstance(hardwareSubtype.ToString()) as HardwareData; activeHardware[index].AssignSubtypeData(subtypeScriptableObject); }
public void HardwareCreatorCostructor() { HardwareData creator = HardwareDataManager.LoadData("{\"PushButton\": {\"type\":\"list\", \"buttons\":[{\"id\": 1},{\"id\": 2}]},\"RotaryEncoder\": [{\"id\": 0,\"hasButton\": true}]}"); Assert.AreEqual(creator.PushButtons.Count, 2); Assert.AreEqual(creator.RotaryEncoders.Count, 1); }
public override bool Init(HardwareData hardeareData) { bInitOk = false; #region TCP/IP if (!(null == _aca500M_Camera)) { _aca500M_Camera.Dispose(); } try { aca500M_Camera = new BP.Camera(cameraData.SerialNumber); GetParameter(); if (!_aca500M_Camera.IsOpen) { _aca500M_Camera.Open(); } if (!_aca500M_Camera.StreamGrabber.IsGrabbing) { _aca500M_Camera.StreamGrabber.Start(cameraData.maxPictureNumber, GrabStrategy.OneByOne, GrabLoop.ProvidedByUser); bAsync = false; } bInitOk = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } #endregion return(bInitOk); }
/// <summary> /// Load the hardware data and maps existing functions with the hardware /// </summary> public static void InitHardware() { HardwareData hardware = HardwareDataManager.LoadData(); HardwareAction actions = new HardwareAction(hardware); InputDispatcher.RegisterHardware(actions.HardwareCreator()); }
override public bool Init(HardwareData hardwareData) { try { bInitOk = false; GoogolMotionCardData data = (GoogolMotionCardData)hardwareData; usCardNo = (short)data.Index; short sRtn = 0; sRtn = gts.mc.GT_Open((short)usCardNo, 0, 0); if (!HandleErrorMessage(sRtn)) { return(false); } //sRtn = gts.mc.GT_Stop(0xFF, 0); sRtn = gts.mc.GT_Reset((short)usCardNo); sRtn = gts.mc.GT_LoadConfig((short)usCardNo, data.Path); sRtn = gts.mc.GT_ClrSts((short)usCardNo, 1, 8);//清除轴报警和限位 bInitOk = true; System.Threading.Thread threadScan = new System.Threading.Thread(ScanThreadFunction); threadScan.IsBackground = true; threadScan.Start(); return(true); } catch //(Exception) { return(false); } }
public override bool Init(HardwareData hardeareData) { bInitOk = true; System.Threading.Thread threadRefreshSta = new System.Threading.Thread(ThreadRefreshStaHandler); threadRefreshSta.IsBackground = true; threadRefreshSta.Start(); return(base.Init(hardeareData)); }
public ActionResult Add() { var viewModel = new HardwareData(); viewModel.HardwareTypes = db.HardwareTypes.Where(h => h.Status == true); viewModel.Vendors = db.Vendors.Where(v => v.Status == true); viewModel.Makers = db.Makers.Where(m => m.Status == true); viewModel.Owners = db.Owners.ToList(); return(View(viewModel)); }
public override bool Init(HardwareData hardwareData) { bInitOk = false; try { _modbusMaster = new Master(plcData.IP, 502); return(true); } catch { return(false); } }
public ActionResult Edit(HardwareData h) { var hardware = db.Hardwares .Include(i => i.Inventory) .SingleOrDefault(i => i.Id == h.Id); if (hardware == null) { return(new HttpNotFoundResult()); } var userId = User.Identity.GetUserId(); var employee = db.Employees .Include(e => e.Owner) .SingleOrDefault(i => i.User.Id == userId); if (employee == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (User.IsInRole(ApplicationUser.USER)) { if (hardware.Inventory.Status != InventoryStatus.Pending || hardware.Inventory.OwnerId != employee.Owner.Id) { return(new HttpUnauthorizedResult()); } h.Status = InventoryStatus.Pending; h.OwnerId = employee.Owner.Id; } if (!ModelState.IsValid) { PopulateHardware(hardware, h); h.HardwareTypes = db.HardwareTypes.Where(i => i.Status); h.Vendors = db.Vendors.Where(i => i.Status); h.Makers = db.Makers.Where(i => i.Status); h.Owners = db.Owners.ToList(); return(View(h)); } UpdateHistory(hardware, h); MapHardware(hardware, h); db.SaveChanges(); TempData["AlertMessage"] = "Your Hardware is Saved."; return(RedirectToAction("Show", new { Id = hardware.Id })); }
public override bool Init(HardwareData hardeareData) { bInitOk = false; #region TCP/IP if (codeReaderData.protocol == Protocol.TcpIP) { if (_tcpClient != null) { _tcpClient.Close(); _tcpClient = null; } _tcpClient = new Client(); _tcpClient.IpAddress = codeReaderData.IP; _tcpClient.Port = codeReaderData.Port; _tcpClient.StartCode = codeReaderData.strStartCode; _tcpClient.EndCode = codeReaderData.strEndCode; _tcpClient.OnDataReceived += new EventDataReceived(tcpClient_OnDataReceived); _tcpClient.StartConnect(); bInitOk = true; } #endregion #region RS232 if (codeReaderData.protocol == Protocol.RS232) { if (_port.IsOpen) { bInitOk = true; return(true); } try { _port.PortName = codeReaderData.SerialPort; _port.BaudRate = codeReaderData.Buad; _port.DataBits = codeReaderData.DataBits; _port.StopBits = codeReaderData.StopBits; _port.Parity = codeReaderData.Parity; _port.Open(); bInitOk = true; } catch (Exception) { bInitOk = false; } } #endregion return(bInitOk); }
public void UpdateHistory(Hardware hardware, HardwareData data) { if (data.Status != hardware.Inventory.Status || data.OwnerId != hardware.Inventory.OwnerId) { var history = new History() { AssignedOn = DateTime.Now, AssignedToId = data.OwnerId, InventoryId = hardware.Inventory.Id, StatusAssigned = data.Status, AssignedById = User.Identity.GetUserId() }; db.Histories.Add(history); } }
public ActionResult Edit(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var hardware = db.Hardwares .Include(i => i.Inventory) .SingleOrDefault(i => i.Id == Id); if (hardware == null) { return(new HttpNotFoundResult()); } var userId = User.Identity.GetUserId(); var employee = db.Employees .Include(e => e.Owner) .SingleOrDefault(i => i.User.Id == userId); if (employee == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (User.IsInRole(ApplicationUser.USER)) { if (hardware.Inventory.Status != InventoryStatus.Pending || hardware.Inventory.OwnerId != employee.Owner.Id) { return(new HttpUnauthorizedResult()); } } var viewModel = new HardwareData(); PopulateHardware(hardware, viewModel); viewModel.HardwareTypes = db.HardwareTypes.Where(h => h.Status == true); viewModel.Vendors = db.Vendors.Where(v => v.Status == true); viewModel.Makers = db.Makers.Where(m => m.Status == true); viewModel.Owners = db.Owners.ToList(); viewModel.ReferrerUrl = Request.UrlReferrer?.AbsoluteUri; return(View(viewModel)); }
public void PopulateHardware(Hardware hardware, HardwareData hardwareToDisplay) { hardwareToDisplay.Name = hardware.Inventory.Name; hardwareToDisplay.Description = hardware.Inventory.Description; hardwareToDisplay.ModelName = hardware.Inventory.ModelName; hardwareToDisplay.ModelNo = hardware.Inventory.ModelNo; hardwareToDisplay.ModelYear = hardware.Inventory.ModelYear; hardwareToDisplay.PurchasePrice = hardware.Inventory.PurchasePrice; hardwareToDisplay.PurchaseDate = hardware.Inventory.PurchaseDate; hardwareToDisplay.SerialNo = hardware.Inventory.SerialNo; hardwareToDisplay.MakerId = hardware.Inventory.MakerId; hardwareToDisplay.VendorId = hardware.Inventory.VendorId; hardwareToDisplay.OwnerId = hardware.Inventory.OwnerId; hardwareToDisplay.Status = hardware.Inventory.Status; hardwareToDisplay.HardwareTypeId = hardware.HardwareTypeId; hardwareToDisplay.WarrentyExpiration = hardware.WarrentyExpiration; }
public override bool Init(HardwareData hardeareData) { bInitOk = false; try { if (omronFinsAPI.ConnectToOmronPLC(plcData.RemoteIP, 9600, plcData.LocalIP)) { bInitOk = true; } } catch { } System.Threading.Thread threadRefresh = new System.Threading.Thread(ThreadRefresh); //threadRefresh.IsBackground = true; threadRefresh.Start(); return(bInitOk); }
public void MapHardware(Hardware hardwareToUpdate, HardwareData data) { hardwareToUpdate.Inventory.Name = data.Name; hardwareToUpdate.Inventory.Description = data.Description; hardwareToUpdate.Inventory.ModelName = data.ModelName; hardwareToUpdate.Inventory.ModelNo = data.ModelNo; hardwareToUpdate.Inventory.ModelYear = data.ModelYear; hardwareToUpdate.Inventory.PurchasePrice = data.PurchasePrice; hardwareToUpdate.Inventory.PurchaseDate = data.PurchaseDate; hardwareToUpdate.Inventory.SerialNo = data.SerialNo; hardwareToUpdate.Inventory.MakerId = data.MakerId; hardwareToUpdate.Inventory.VendorId = data.VendorId; hardwareToUpdate.Inventory.OwnerId = data.OwnerId; hardwareToUpdate.Inventory.Status = data.Status == 0 ? InventoryStatus.Pending : data.Status; hardwareToUpdate.Inventory.ModifiedOn = DateTime.Now; hardwareToUpdate.HardwareTypeId = data.HardwareTypeId; hardwareToUpdate.WarrentyExpiration = data.WarrentyExpiration; }
public override bool Init(HardwareData hardeareData) { bInitOk = false; try { if (yamahaRCX340API.ConnectToYamahaRobot(_robotData.IP, (short)_robotData.Port, (short)_robotData.ReadTimeout)) { bInitOk = true; } } catch //(Exception) { } System.Threading.Thread threadRefresh = new System.Threading.Thread(ThreadScan); threadRefresh.IsBackground = true; threadRefresh.Start(); return(bInitOk); }
public override bool Init(HardwareData hardeareData) { bInitOk = false; try { if (omronFinsAPI.ConnectToOmronPLC(plcData.IP, 9600, null)) { bInitOk = true; } else { } } catch //(Exception) { } System.Threading.Thread threadRefresh = new System.Threading.Thread(ThreadRefresh); threadRefresh.IsBackground = true; threadRefresh.Start(); return(bInitOk); }
override public bool Init(HardwareData hardwareData) { LeadShineMotionCardData tempInfo = (LeadShineMotionCardData)hardwareData; if (iCardTotal > 0) { if (iCardTotal >= tempInfo.Index) { bInitOk = true; } else { bInitOk = false; } } else { iCardTotal = LTDMC.dmc_board_init(); if (iCardTotal <= 0)//控制卡初始化 { bInitOk = false; return(false); } if (iCardTotal >= tempInfo.Index) { bInitOk = true; } else { bInitOk = false; } } iCardIndex = (ushort)tempInfo.Index; System.Threading.Thread threadScan = new System.Threading.Thread(ScanThreadFunction); threadScan.IsBackground = true; threadScan.Start(); return(true); }
public HardwareData Tick() { HardwareData data = new HardwareData(); foreach (var hardwareItem in Computer.Hardware) { switch (hardwareItem.HardwareType) { case HardwareType.CPU: { hardwareItem.Update(); data.Cpu.Name = hardwareItem.Name; foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } foreach (var sensor in hardwareItem.Sensors) { if (sensor.SensorType == SensorType.Temperature) { float value; if (sensor.Value != null) { value = sensor.Value.Value; } else { value = 0; } if (sensor.Name.Contains("Package")) { data.Cpu.PackageTemperature = value; } else { int coreCount = sensor.Name.Split('#')[1].ToInt(); if (data.Cpu.Cores.ContainsKey(coreCount)) { data.Cpu.Cores[coreCount].Temperature = value; } else { data.Cpu.Cores.Add(coreCount, new CpuCore()); data.Cpu.Cores[coreCount].Temperature = value; } } } if (sensor.SensorType == SensorType.Load) { float value; if (sensor.Value != null) { value = sensor.Value.Value; } else { value = 0; } if (sensor.Name.Contains("Total")) { data.Cpu.TotalLoad = value; } else { int coreCount = sensor.Name.Split('#')[1].ToInt(); if (data.Cpu.Cores.ContainsKey(coreCount)) { data.Cpu.Cores[coreCount].Load = value; } else { data.Cpu.Cores.Add(coreCount, new CpuCore()); data.Cpu.Cores[coreCount].Load = value; } } } if (sensor.SensorType == SensorType.Clock) { float value; if (sensor.Value != null) { value = sensor.Value.Value; } else { value = 0; } if (sensor.Name.Contains("Speed")) { data.Cpu.BusSpeed = (int)value; } else { int coreCount = sensor.Name.Split('#')[1].ToInt(); if (data.Cpu.Cores.ContainsKey(coreCount)) { data.Cpu.Cores[coreCount].Clock = value; } else { data.Cpu.Cores.Add(coreCount, new CpuCore()); data.Cpu.Cores[coreCount].Clock = value; } } } } break; } case HardwareType.RAM: { hardwareItem.Update(); foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } foreach (var sensor in hardwareItem.Sensors) { if (sensor.SensorType == SensorType.Data) { data.Ram.Usage = sensor.Value.HasValue ? (float)Math.Round(sensor.Value.Value, 1) : 0; } else if (sensor.SensorType == SensorType.Load) { if (sensor.Value != null) { data.Ram.UsagePercent = sensor.Value.Value; } else { data.Ram.UsagePercent = sensor.Value.HasValue ? (float)Math.Round(sensor.Value.Value, 1) : 0; } } } break; } case HardwareType.HDD: { hardwareItem.Update(); Storage storage = new Storage(); storage.Name = hardwareItem.Name; foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } foreach (var sensor in hardwareItem.Sensors) { if (sensor.SensorType == SensorType.Load) { storage.UsagePercent = sensor.Value ?? 0; } else if (sensor.SensorType == SensorType.Data) { storage.Usage = sensor.Value.HasValue ? (float)Math.Round(sensor.Value.Value, 1) : 0; } else if (sensor.SensorType == SensorType.Temperature) { if (sensor.Value != null) { storage.Temperature = (int)sensor.Value.Value; } } } data.Storages.Add(storage); break; } case HardwareType.GpuNvidia: { hardwareItem.Update(); Gpu gpu = new Gpu(); gpu.Name = hardwareItem.Name; foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } foreach (var sensor in hardwareItem.Sensors) { if (sensor.SensorType == SensorType.Load) { if (sensor.Name.Contains("Core")) { gpu.Load = sensor.Value.HasValue ? (float)Math.Round(sensor.Value.Value, 1) : 0; } } else if (sensor.SensorType == SensorType.Data) { if (sensor.Name.Contains("Free")) { gpu.GpuMemoryFree = sensor.Value.HasValue ? (int)sensor.Value.Value : 0; } else if (sensor.Name.Contains("Used")) { gpu.GpuMemoryUsed = sensor.Value.HasValue ? (int)sensor.Value.Value : 0; } else if (sensor.Name.Contains("Total")) { gpu.GpuMemoryTotal = sensor.Value.HasValue ? (int)sensor.Value.Value : 0; } } else if (sensor.SensorType == SensorType.Temperature) { if (sensor.Name.Contains("Core")) { gpu.Temperature = sensor.Value.HasValue ? (float)Math.Round(sensor.Value.Value, 1) : 0; } } else if (sensor.SensorType == SensorType.Clock) { if (sensor.Name.Contains("Core")) { gpu.Clock = sensor.Value.HasValue ? (int)sensor.Value.Value : 0; } } } data.Gpus.Add(gpu); break; } } } return(data); }
public void SetHardwareData(HardwareData hardwareData) { HardwareData = hardwareData; }
public void AssignSubtypeData(HardwareData hardwareData) { subtypeData = hardwareData as BlinkHardwareData; }
public override bool Init(HardwareData hardeareData) { return(base.Init(hardeareData)); }
public void AssignSubtypeData(HardwareData hardwareData) { subtypeData = hardwareData as NullifyHardwareData; }
/// <summary> /// Set the hardware representation from an existing object /// </summary> /// <param name="instance"></param> public static void RegisterHardware(HardwareData instance) { InputDataMapping = instance; }
public void AssignSubtypeData(HardwareData hardwareData) { subtypeData = hardwareData as FractureHardwareData; }
private void ThreadScan() { while (true) { Thread.Sleep(100); if (null == docAlarm || HardwareManage.docHardware == null) { continue; } foreach (AlarmData item in docAlarm.listAlarmItems) { try { if (!HardwareManage.docHardware.dicHardwareData.ContainsKey(item.AlarmSrc)) { continue; } HardwareData hardwareData = HardwareManage.docHardware.dicHardwareData[item.AlarmSrc]; #region Omron PLC NJ series if (hardwareData.Type == HardwareType.PLC && hardwareData.Series == HardwareSeries.Omron_PLC_NJ) { PlcOmronTypeNJData plcData = (PlcOmronTypeNJData)hardwareData; if (!plcData.dicScanItems.ContainsKey(item.AlarmName)) { continue; } if (plcData.dicScanItems[item.AlarmName].strValue.Equals("1")) { if (!DicCurrAlarmMsg.ContainsKey(item.AlarmKey)) { InsertAlarm(item.AlarmKey); } } else if (DicCurrAlarmMsg.ContainsKey(item.AlarmKey)) { RemoveAlarm(item.AlarmKey); } } #endregion #region Omron PLC NX1P series if (hardwareData.Type == HardwareType.PLC && hardwareData.Series == HardwareSeries.Omron_PLC_NX1P) { PlcOmronTypeNX1PData plcData = (PlcOmronTypeNX1PData)hardwareData; if (!plcData.dicScanItems.ContainsKey(item.AlarmName)) { continue; } if (plcData.dicScanItems[item.AlarmName].strValue.Equals("1")) { if (!DicCurrAlarmMsg.ContainsKey(item.AlarmKey)) { InsertAlarm(item.AlarmKey); } } else if (DicCurrAlarmMsg.ContainsKey(item.AlarmKey)) { RemoveAlarm(item.AlarmKey); } } #endregion #region Panasonic PLC #endregion } catch (Exception) { } } if (null == MainModule.formMain) { continue; } if (MainModule.formMain.bExit) { break; } } }
public void AssignSubtypeData(HardwareData hardwareData) { subtypeData = hardwareData as ParryHardwareData; }