public AutoConnectionServer(IMyIntergridCommunicationSystem igc, AutoConnector connector, IProcessSpawner spawner) { this.connector = connector; this.igc = igc; this.mainProcess = spawner.Spawn(p => this.Update(), $"ac-server '{this.Name}'", onDone => this.connector.Stop()); this.logger?.Invoke($"Connector {this.Name} ready"); }
public SckBarcodeScanner(string name, string ipAddress, int port = 2112, ISynchronizeInvoke syncInvoke = null, ILogger logger = null, double interval = 500, bool autoReconnect = true) { Name = name; IpAddress = ipAddress; Port = port; _logger = logger; if (autoReconnect) { _autoConnector = new AutoConnector(this, 10000); } BuildTimers(syncInvoke, interval); _heartbeatRequest = BuildHeartbeatRequest(); }
public void AddNewConnector(string connectorName, MyGridProgram program) { foreach (AutoConnectionServer con in this.autoConnectors) { if (con.Name == connectorName) { this.log($"connector {connectorName} already exists"); return; } } try { var connector = new AutoConnector(this.stationName, connectorName, program, this.logger, this.transformer); this.autoConnectors.Add(new AutoConnectionServer(this.igc, connector, this.manager)); } catch (InvalidOperationException e) { this.log($"could not create connector '{connectorName}': {e.Message}"); } }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). trayIcon.Dispose(); trayIcon = null; connector?.Stop(); connector = null; } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
private void ConfigItem_Click(object sender, EventArgs e) { if (configFormOpen) { return; } configFormOpen = true; var configForm = new LauncherConfigForm(config); if (configForm.ShowDialog() == DialogResult.OK) { config = configForm.Config; config.SaveToFile(); connector?.Stop(); connector = null; CreateAutoConnector(); } configFormOpen = false; }
public AutoConnectionDispatcher(MyGridProgram program, CommandLine command, MyIni ini, Action <string> logger, IProcessManager manager) { this.logger = logger; this.manager = manager; // Station level initialization this.stationName = ini.GetThrow(INI_GENERAL_SECTION, INI_NAME_KEY).ToString(); this.referenceName = ini.GetThrow(INI_GENERAL_SECTION, INI_REFERENCE_KEY).ToString(); IMyTerminalBlock reference = program.GridTerminalSystem.GetBlockWithName(this.referenceName); if (reference == null) { throw new ArgumentException($"Could not find reference block '{this.referenceName}'"); } this.igc = program.IGC; this.transformer = new CoordinatesTransformer(reference, manager); this.log("initializing"); // Connectors initialization var sections = new List <string>(); ini.GetSections(sections); foreach (string sectionName in sections.Where(s => s.StartsWith(AutoConnector.IniConnectorPrefix))) { var connector = new AutoConnector(this.stationName, sectionName, program, this.logger, this.transformer, ini); this.autoConnectors.Add(new AutoConnectionServer(ini, this.igc, connector, manager, this.logger)); } this.log($"has {this.autoConnectors.Count} auto connectors"); this.registerCommands(command, program); IMyBroadcastListener listener = this.igc.RegisterBroadcastListener("StationConnectionRequests"); this.manager.Spawn(p => { if (listener.HasPendingMessage) { MyIGCMessage msg = listener.AcceptMessage(); command.StartCmd($"{msg.As<string>()} {msg.Source}", CommandTrigger.Antenna); } }, "ac-dispatcher"); this.manager.AddOnSave(save); }
private bool CreateAutoConnector() { if (config != null) { var player = new MpcHcWebAdapter( config.PlayerPath, config.PlayerArgs, config.MpcHcWebPort, config.MpcHcWebTimeout); connector = new AutoConnector(player, config); if (!connector.Start()) { string msg = "Could not connect to Emby. Please check your settings."; log.Error(msg); trayIcon.Text = msg; Task.Run(() => MessageBox.Show(msg)); return(false); } else { trayIcon.Text = "Emby External Player launcher has connected."; } } else { string msg = "Emby External Player Launcher is not configured."; trayIcon.Text = msg; log.Warn(msg); Task.Run(() => MessageBox.Show("The launcher does not seem to be configured. " + "Right click the tray icon to open the configuration interface.", "Not Configured", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)); return(false); } return(true); }
public StatusSwithRepository(AutoConnector connector) { AutoConnector = connector; }
public AutoConnectionServer(MyIni ini, IMyIntergridCommunicationSystem igc, AutoConnector connector, IProcessSpawner spawner, Action <string> logger) : this(igc, connector, spawner) { this.logger = logger; this.deserialize(ini); }