public bool Start() { if (IsWorking()) { return(false); } Messenger.AddMessage(MessageToMainForm.ClearConnectedDevicesList); if (_mode == Mode.Stop) { HardwareManager.Connect(); var devices = HardwareManager.GetConnectedDevices(); foreach (var device in devices) { Messenger.AddMessage(MessageToMainForm.ChangeConnectedDevice, device); } } else { Profile.AccessDescriptor.InitializeAccessDescriptors(); } // Запускаем роутер после дампа, чтобы не получилось, что индикаторы и лампы не зажигаются, хотя фактически режимы включены _mode = Mode.Work; _routerCoreThread = new Thread(ThreadLoop) { IsBackground = true }; _routerCoreThread.Start(); Messenger.AddMessage(MessageToMainForm.RouterStarted); if (_mode == Mode.Stop) { Profile.AccessDescriptor.InitializeAccessDescriptors(); Dump(); } return(true); }
/// <summary> /// Startup method for Ceres UCI chess engine and supplemental features. /// </summary> /// <param name="args"></param> static void Main(string[] args) { #if DEBUG Console.WriteLine(); ConsoleUtils.WriteLineColored(ConsoleColor.Red, "*** WARNING: Ceres binaries built in Debug mode and will run much more slowly than Release"); #endif OutputBanner(); CheckRecursiveOverflow(); HardwareManager.VerifyHardwareSoftwareCompatability(); // Load (or cause to be created) a settings file. if (!CeresUserSettingsManager.DefaultConfigFileExists) { Console.WriteLine(); ConsoleUtils.WriteLineColored(ConsoleColor.Red, $"*** NOTE: Configuration file {CeresUserSettingsManager.DefaultCeresConfigFileName} not found in working directory."); Console.WriteLine(); Console.WriteLine($"Prompting to for required values to initialize:"); CeresUserSettingsManager.DoSetupInitialize(); } // Configure logging level const bool LOG = false; CeresEnvironment.MONITORING_EVENTS = LOG; LogLevel logLevel = LOG ? LogLevel.Information : LogLevel.Critical; LoggerTypes loggerTypes = LoggerTypes.WinDebugLogger | LoggerTypes.ConsoleLogger; CeresEnvironment.Initialize(loggerTypes, logLevel); CeresEnvironment.MONITORING_METRICS = CeresUserSettingsManager.Settings.LaunchMonitor; // if (CeresUserSettingsManager.Settings.DirLC0Networks != null) // NNWeightsFilesLC0.RegisterDirectory(CeresUserSettingsManager.Settings.DirLC0Networks); MCTSEngineInitialization.BaseInitialize(); Console.WriteLine(); #if DEBUG CheckDebugAllowed(); #endif if (args.Length > 0 && args[0].ToUpper() == "CUSTOM") { TournamentTest.Test(); return; // SuiteTest.RunSuiteTest(); return; } StringBuilder allArgs = new StringBuilder(); for (int i = 0; i < args.Length; i++) { allArgs.Append(args[i] + " "); } string allArgsString = allArgs.ToString(); DispatchCommands.ProcessCommand(allArgsString); // Win32.WriteCrashdumpFile(@"d:\temp\dump.dmp"); }
public void Dump() { var assignments = Profile.ControlProcessor.GetAllAssignedHardwares(); Debug.Print("Dump command"); HardwareManager.Dump(assignments); }
public static void RemovedFromManager() { if (GetInstance() is IManagedHardware) { HardwareManager.RemoveHardWare(Name, GetInstance() as IManagedHardware); } }
public void Save(int selectedRowIndex, string hardware) { var rowCounter = -1; var assignments = _assignedControlProcessor.GetAssignments(); // На случай, если меняется только инверсия, можно принимать и пустой hardware if (selectedRowIndex == -1 || (string.IsNullOrEmpty(hardware) && assignments.Length == 0)) { return; } foreach (var row in _dataTable.Rows) { rowCounter++; if (rowCounter != selectedRowIndex) { continue; } foreach (IAssignment a in assignments) { if (a.GetConnector().Id == int.Parse((string)((DataRow)row).ItemArray[0])) { a.SetAssignedHardware(string.IsNullOrEmpty(hardware) ? a.GetAssignedHardware() : hardware); if (_assignedControlProcessor.HasInvertMode()) { a.SetInverseState((bool)((DataRow)row).ItemArray[3]); } _assignedControlProcessor.SetAssignment(a); break; } } } HardwareManager.ResendLastControlEvent(hardware); }
public async Task ShowHardware([Summary("The user you want to show the Hardware of")] IGuildUser user) { try { var hwProfile = HardwareManager.ReadHardware(Context.Guild, user.Id); if (hwProfile == null) { await ReplyAsync($"{Helper.GetName(user)} does not have his hardware set! " + $"Create a new hardware profile by using the `{Information.Prefix}sethw <HardwareProfileName>` command!"); return; } var builder = new EmbedBuilder { Color = new Color(50, 125, 125), Author = new EmbedAuthorBuilder { Name = $"{Helper.GetName(user)}'s Hardware 🖥️", IconUrl = user.GetAvatarUrl() } }; builder.AddField(hwProfile.Item1, hwProfile.Item2); await ReplyAsync("", embed : builder.Build()); } catch (Exception ex) { await ReplyAsync($"Sorry, I can't get hardware information for {Helper.GetName(user)}!"); ConsoleHelper.Log($"Error getting hardware for {user} ({ex.Message})", LogSeverity.Error); } }
private void Work() { if (!_isDumpedOnce) { Dump(); _isDumpedOnce = true; } var events = HardwareManager.GetIncomingEvents(); // Обрабатываем все события foreach (var controlEvent in events) { Profile.ControlProcessor.SendEvent(controlEvent); //if(controlEvent.Hardware.ModuleType!=HardwareModuleType.Axis) Messenger.AddMessage(MessageToMainForm.NewHardwareEvent, controlEvent); } var outgoing = new List <ControlEventBase>(); var outputWasOn = new List <string>(); var newOutgoingEvents = Profile.ControlProcessor.GetNewEvents(); foreach (var newOutgoingEvent in newOutgoingEvents) { // В том случае, когда на один индикатор назначены 2 деcкриптора. Переключение "коммутатором" // более ранний по ID дескриптор установил текст при переключении коммутатора, а более поздний выключил питание. В итоге индикатор пуст if (newOutgoingEvent.Hardware.ModuleType == HardwareModuleType.LedMatrixIndicator || newOutgoingEvent.Hardware.ModuleType == HardwareModuleType.Indicator || newOutgoingEvent.Hardware.ModuleType == HardwareModuleType.BinaryOutput) { var isPowerOff = false; var indicatorEvent = newOutgoingEvent as IndicatorEvent; if (indicatorEvent != null && string.IsNullOrWhiteSpace(indicatorEvent.IndicatorText)) { isPowerOff = true; } var lampEvent = newOutgoingEvent as LampEvent; if (lampEvent != null && !lampEvent.IsOn) { isPowerOff = true; } var hwGuid = newOutgoingEvent.Hardware.GetHardwareGuid(); if (isPowerOff && outputWasOn.Contains(hwGuid)) { continue; } if (!isPowerOff && !outputWasOn.Contains(hwGuid)) { outputWasOn.Add(hwGuid); } } outgoing.Add(newOutgoingEvent); } outputWasOn.Clear(); HardwareManager.PostOutgoingEvents(outgoing); Profile.ControlProcessor.Tick(); }
public virtual void OnBeforeAllTests() { // Cleanup directory and re-created Cleanup(); // Attach to hardware using (m_Hardware) m_Hardware = HardwareManager.Open(); }
private void StartSearch() { var hardware = GetSelectedHardwareGuid(); if (!string.IsNullOrEmpty(hardware)) { HardwareManager.SetComponentToSearch(hardware); } }
public static void AddedToManager() { if (GetInstance() is IManagedHardware)//要保证<T>实现IManagedHardware { HardwareManager.AddHardWare(Name, GetInstance() as IManagedHardware); } else { throw new Exception(Name + "未实现IManagedHardware接口"); } }
/// <summary> /// Initializes the object. /// </summary> private void Start() { _canvas = GetComponent <Canvas>(); UpdateCanvasSize(); _camera = FindObjectOfType <CameraController>().GetComponent <Camera>(); if (GameManager.Instance.State == GameManager.GameState.Level) { _hwManager = FindObjectOfType <HardwareManager>(); GenerateVitalWeaponInfos(); } }
public static ComputerInfo GetComputerInfo() { ComputerInfo info = new ComputerInfo(); info.System = Environment.OSVersion.ToString(); info.SystemVersion = Environment.Version.ToString(); info.Name = Environment.MachineName; //info.Mac = Environment.UserName; info.Ip = HardwareManager.GetDefaultIp(); info.Mac = HardwareManager.GetMac(); return(info); }
/// <summary> /// /// </summary> /// <param name="hardWareManager"></param> /// <param name="treeView"></param> private void FillStationTreeView(HardwareManager hardWareManager, TreeView treeView) { foreach (Station station in hardWareManager.Stations) { TreeNode stationTreeNode = AddStationToTreeView(treeView, station); foreach (Device device in station.Devices) { AddDeviceToStationTreeNode(stationTreeNode, device); } } treeView.Sort(); }
/// <summary> /// 默认的发送者对象 /// </summary> /// <returns>一个静态的发送者对象</returns> private static SenderInfo GetDefaultSender() { if (sender == null) { sender = new SenderInfo(); sender.MachineCode = HardwareManager.GetMachineCode(); AssemblyName an = Assembly.GetExecutingAssembly().GetName(); sender.ProgramName = an.Name; sender.Version = an.Version.ToString(); sender.Ip = HardwareManager.GetDefaultIp(); } return(sender); }
public void Save() { var selectedRowIndex = _selectedRowAndColumn.GetSelectedRowIndex(); if (selectedRowIndex == -1 || AssignmentGrid.Columns.Count == 0) { return; } var hardware = GetSelectedHardwareGuid(); _assignEditorHelper.Save(selectedRowIndex, hardware); ShowData(); HardwareManager.StopComponentSearch(); }
private void TcpServerConfig_Load(object sender, EventArgs e) { ServerConfig config = ServerConfig.GetConfig(); if (config != null) { this.cbDefaultStart.Checked = config.DefaultOpen; this.txtIp.Text = config.Ip; this.txtPort.Text = config.Port.ToString(); } else { this.txtIp.Text = HardwareManager.GetDefaultIp(); } }
private void ClientConfigForm_Load(object sender, EventArgs e) { ClientConfig config = ClientConfig.GetConfig(); if (config != null) { this.txtServerIp.Text = config.ServerIp; this.txtIp.Text = config.Ip; this.txtPort.Text = config.Port.ToString(); } else { this.txtIp.Text = HardwareManager.GetDefaultIp(); } }
/// <summary> /// Erstellt eine neue Zugriffsverwaltung. /// </summary> /// <param name="profileNames">Die Namen der zu verwendenden Geräteprofile.</param> public StandardFeedProvider(params string[] profileNames) { // Helper m_devices = (profileNames ?? Enumerable.Empty <string>()) .Select(profileName => new StandardDevice(ProfileManager.FindProfile(profileName))) .ToArray(); // Check configuration if (m_devices.Length != new HashSet <string>(m_devices.Select(profile => profile.Name), ProfileManager.ProfileNameComparer).Count) { throw new ArgumentException("invalid profile list", "profileNames"); } // Start hardware access m_hardware = HardwareManager.Open(); }
private void ThreadLoop() { var currentEventCounter = 0; const int softDumpPortion = 10; var stopwatch = new Stopwatch(); while (true) { if (_mode == Mode.Stop || _mode == Mode.Pause) { return; } stopwatch.Start(); Profile.VariableStorage.SynchronizeVariables(); Work(); if (!ApplicationSettings.ControlsSynchronizationIsOff) { var eventsCache = HardwareManager.SoftDump(); if (eventsCache != null) { var softDumpEvents = eventsCache.Skip(currentEventCounter).Take(softDumpPortion).ToArray(); if (softDumpEvents.Length != 0) { currentEventCounter += softDumpPortion; foreach (var controlEvent in softDumpEvents) { controlEvent.IsSoftDumpEvent = true; Profile.ControlProcessor.SendEvent(controlEvent); } } else { currentEventCounter = 0; } } } stopwatch.Stop(); const int delay = 200; if (stopwatch.ElapsedMilliseconds < delay) { Thread.Sleep(delay - (int)stopwatch.ElapsedMilliseconds); } } }
/// <summary> /// Führt die eigentliche Auswertung durch. /// </summary> private void Worker() { // Be safe try { // Prepare all displays foreach (GroupDisplay display in m_Displays.Values) { display.Prepare(); } // As long as necessary using (HardwareManager.Open()) while (null != m_Worker) { foreach (GroupDisplay display in m_Displays.Values) { // Process display.ProcessNext(); // Done if (null == m_Worker) { break; } // Relax a bit Thread.Sleep(100); // Done if (null == m_Worker) { break; } } } } catch { } // Report Invoke(new Action(AdminSite.OperationDone)); }
/// <summary> /// Führt den eigentliche Zugriff aus. /// </summary> private void Worker() { // Be fully safe try { // With hardware using (HardwareManager.Open()) { // Attach to group PlugIn.LastSource.SelectGroup(); // Attach to device Hardware device = PlugIn.LastSource.GetHardware(); // Create parser m_Parser = TableParser.Create <GenericTable>(OnTable); // Register raw stream Guid consumerId = device.AddConsumer(m_Stream, m_Extended ? StreamTypes.ExtendedTable : StreamTypes.StandardTable, OnData); // Start it device.SetConsumerState(consumerId, true); // Process while (null != m_Worker) { Thread.Sleep(100); } // Stop all device.SetConsumerState(consumerId, null); } } catch { } // Close the file using (BinaryWriter writer = m_TargetFile) m_TargetFile = null; // Did it Invoke(new Action(AdminSite.OperationDone)); }
private bool Stop(bool pause) { if (!IsWorking()) { return(false); } _mode = pause ? Mode.Pause : Mode.Stop; _routerCoreThread.Join(); if (_mode == Mode.Stop) { ShutDownOutputHardware(); HardwareManager.Disconnect(); Messenger.AddMessage(MessageToMainForm.RouterStopped); } else { Messenger.AddMessage(MessageToMainForm.RouterPaused); } return(true); }
public Robot() { sensorsMan = new SensorsManager(); hardwareMan = new HardwareManager(); modules = new SortedList<string, Module>(); head = new HeadHW(1, -1); torso = new TorsoHW(MathUtil.PiOver2, -MathUtil.PiOver2); RightArmIsEmpty = true; LeftArmIsEmpty = true; skeletons = new Skeleton[0]; humanList = new List<Human>(); objectsList = new SortedList<string, WorldObject>(); lastObjectsFounded = new SortedList<string, WorldObject>(); LoadModules(); }
private void RememberSelectedItemOnOpenCombobox(ComboBox cb, DeviceSubType deviceSubType) { _selectedItemOfOpenedCombobox = (string)cb.SelectedItem; var cph = new ControlProcessorHardware { ModuleType = _hardwareSupported, MotherBoardId = (string)_motherboardList.SelectedItem, BlockId = uint.Parse(string.IsNullOrEmpty((string)_blockId.SelectedItem) ? "0" : (string)_blockId.SelectedItem), ModuleId = uint.Parse(string.IsNullOrEmpty((string)_moduleList.SelectedItem) ? "0" : (string)_moduleList.SelectedItem), ControlId = uint.Parse(string.IsNullOrEmpty((string)_controlId.SelectedItem) ? "0" : (string)_controlId.SelectedItem), }; cb.Items.Clear(); var capacity = HardwareManager.GetCapacity(cph, deviceSubType).Names; foreach (var c in capacity) { cb.Items.Add(c); } }
public string EnableDevice(bool enabled = true) { GetSelectedHardwareID(); if (selectedHardwareID == null) { return("Touch screen device not selected"); } try { HardwareManager.DisableDeviceByID(selectedHardwareID, !enabled); } catch (ApplicationException ex) { return(ex.Message); } return(""); }
public static void BaseInitialize() { HardwareManager.VerifyHardwareSoftwareCompatability(); int minNumThreads = Math.Min(96, System.Environment.ProcessorCount * 4); System.Threading.ThreadPool.SetMinThreads(minNumThreads, 32); GCSettings.LatencyMode = GCLatencyMode.Batch; HardwareManager.Initialize(true); if (CeresEnvironment.MONITORING_METRICS && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // TODO: log this. Console.WriteLine($"dotnet-counters monitor --process-id {Process.GetCurrentProcess().Id} Ceres System.Runtime Ceres.MCTS.Environment.MCTSEventSource"); EventSourceCeres.ENABLED = true; EventSourceCeres.LaunchConsoleMonitor("Ceres.MCTS.Environment.MCTSEventSource"); } MCTSEventSource.Initialize(); }
private void checkHardWare() { if (!HardwareManager.OpenAll()) { checkHardWareRet = false; } else { HardwareManager.CheckAll(); if (!HardwareManager.HardWareError()) { checkHardWareRet = true; } else { checkHardWareRet = false; } } checkNetRet = !GPRS.ExistError(); }
/// <summary> /// Erzeugte eine neue Zugriffsinstanz. /// </summary> /// <param name="profile">Zu verwendende DVB.NET Hardware Abstraktion.</param> /// <param name="main">Zugehörige Anwendung.</param> public DeviceAdpator(Profile profile, IViewerSite main) : base(main) { // Remember Profile = profile; // Attach to the device Device = HardwareManager.OpenHardware(Profile); // Create m_TTXConnector = new TTXStreamConsumer(this); // Load alternate interfaces GeneralInfo = (IGeneralInfo)main; ChannelInfo = (IChannelInfo)main; StreamInfo = (IStreamInfo)main; LocalInfo = (ILocalInfo)main; // Initialize core - DirectShow Graph feed directly from a Transport Stream SetAccessor(new AudioVideoAccessor()); }
public async Task ShowHardware() { try { var user = Context.User as IGuildUser; if (user == null) { return; } var hwProfile = HardwareManager.ReadHardware(Context.Guild, user.Id); if (hwProfile == null) { await ReplyAsync("You don't have any hardware info set! " + $"Use `{Information.Prefix}sethw <HardwareProfileName>` to create a new Hardware Profile!"); return; } var builder = new EmbedBuilder { Color = new Color(50, 125, 125), Author = new EmbedAuthorBuilder { Name = $"{Helper.GetName(user)}'s Hardware 🖥️", IconUrl = user.GetAvatarUrl() } }; builder.AddField(hwProfile.Item1, hwProfile.Item2); await ReplyAsync("", embed : builder.Build()); } catch (Exception ex) { await ReplyAsync("Sorry, I can't show your hardware!"); ConsoleHelper.Log($"Error getting hardware for {Context.User} ({ex.Message})", LogSeverity.Error); } }
public void OnTimeTick(int count) { if (count % timeout == 0) { if (!InitializeDeal.Initialized) { StartActivity("初始化"); } else { HardwareManager.CheckAll(); if (GPRS.ExistError()) { return; } if (!CardReader.ExistError() && !Esam.ExistError()) { GotoMain(); } } } }
public Device GetTouchDevice() { GetSelectedHardwareID(); if (selectedHardwareID == null) { return(null); } List <Device> deviceList = HardwareManager.ListDevices( device => device.ID.Contains(selectedHardwareID) ); if (deviceList.Count > 0) { return(deviceList.First <Device>()); } else { return(null); } }