private void LoadPlugin(SourceGrid.Cells.Views.Cell categoryView, string plugId) { int curRow = channelsGrid.RowsCount; channelsGrid.RowsCount++; CommunationPlugs plugs = Env.Current.CommunicationPlugins; channelsGrid[curRow, 0] = new SourceGrid.Cells.Cell(plugs[plugId].Name); channelsGrid[curRow, 0].ColumnSpan = channelsGrid.ColumnsCount; channelsGrid[curRow, 0].View = categoryView; channelsGrid[curRow, 0].AddController(new SourceGrid.Cells.Controllers.Unselectable()); foreach (IChannel ch in plugs[plugId].Channels) { channelsGrid.RowsCount++; curRow++; channelsGrid[curRow, 0] = new SourceGrid.Cells.Cell(ch.Name); channelsGrid[curRow, 1] = new SourceGrid.Cells.Cell(ch.Value == null ? "{null}" : ch.Value); channelsGrid[curRow, 2] = new SourceGrid.Cells.Cell(ch.StatusFlags); channelsGrid[curRow, 3] = new SourceGrid.Cells.Cell(ch.ModifyTime); channelsGrid[curRow, 4] = new SourceGrid.Cells.Cell(ch.IsReadOnly ? "R" : "RW"); channelsGrid[curRow, 5] = new SourceGrid.Cells.Cell(ch.Type); channelsGrid.Rows[curRow].Tag = ch; //ch.Tag = curRow; channels.Add(new chnlListMember(ch, curRow)); ch.ValueChanged += new EventHandler(OnChannelValueChanged); } }
private void OnCloseButton(object sender, EventArgs e) { CommunationPlugs plugs = Env.Current.CommunicationPlugins; foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { foreach (IChannel ch in plugs[plugId].Channels) { ch.ValueChanged -= new EventHandler(OnChannelValueChanged); } } if (selectMode == true) { DialogResult = DialogResult.Cancel; } else { DialogResult = DialogResult.OK; } if (updateThread != null) { updateThread.Abort(); } Close(); }
public void Connection() { CommunationPlugs plugs = Env.Current.CommunicationPlugins; Assert.IsFalse(plugs.IsConnected); Assert.IsTrue(plugs.Connect()); Assert.IsTrue(plugs.IsConnected); plugs.Disconnect(); Assert.IsFalse(plugs.IsConnected); }
protected override void OnExit(ExitEventArgs e) { CommunationPlugs plugs = Env.Current.CommunicationPlugins; FreeSCADA.Archiver.ArchiverMain.Current.Stop(); plugs.Disconnect(); Env.Current.CommunicationPlugins["mdbssrv"].SaveSettings(); Env.Current.Project.Save("project_copy.fs2"); Env.Deinitialize(); base.OnExit(e); }
private void selectButton_Click(object sender, EventArgs e) { CommunationPlugs plugs = Env.Current.CommunicationPlugins; foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { foreach (IChannel ch in plugs[plugId].Channels) { ch.ValueChanged -= new EventHandler(OnChannelValueChanged); } } DialogResult = DialogResult.OK; Close(); }
private void VariablesView_FormClosing(object sender, FormClosingEventArgs e) { CommunationPlugs plugs = Env.Current.CommunicationPlugins; foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { foreach (IChannel ch in plugs[plugId].Channels) { ch.ValueChanged -= new EventHandler(OnChannelValueChanged); } } foreach (SourceGrid.Grid.GridRow row in channelsGrid.Rows) { if (row.Tag != null) { IChannel ch = (IChannel)row.Tag; ch.Tag = null; //Clear our tags } } updateThread.Abort(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var splash = new SplashScreen("splash.jpg"); splash.Show(true); MainWindow window = new MainWindow(); // Create the ViewModel to which // the main window binds. AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); Env.Initialize(window, new Commands(), FreeSCADA.Interfaces.EnvironmentMode.Runtime); string appPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); Directory.SetCurrentDirectory(appPath); Env.Current.Project.Load("project.fs2"); FreeSCADA.Archiver.ArchiverMain.Current.Start(); CommunationPlugs plugs = Env.Current.CommunicationPlugins; if (plugs.Connect() == false) { Env.Deinitialize(); return; } MainWindowViewModel.LoginModel.Login("Гість", "0"); _viewModel = new MainWindowViewModel(); // When the ViewModel asks to be closed, // close the window. EventHandler handler = null; handler = delegate { _viewModel.RequestClose -= handler; window.Close(); }; // Force a reload of the changed section. // This makes the new values available for reading. /* * GsmLoggerSettings settings = (GsmLoggerSettings)System.Configuration.ConfigurationManager.GetSection("gsmsettings"); * try * { * _gsmLogger = new GsmLogger(Env.Current.EventsSummary, settings); * } * catch (Exception ex) * { * //Env.Current.Logger (string.Format("Unable to start Gsm Logger. {0}", ex.Message)); * } */ window.DataContext = _viewModel; window.AddHandler(Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(MousePressed)); _timer = new System.Timers.Timer(600000); _timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed); window.Show(); }
static int Main(string[] args) { Options options = new Options(); Plossum.CommandLine.CommandLineParser parser = new Plossum.CommandLine.CommandLineParser(options); parser.Parse(); Console.WriteLine(parser.UsageInfo.GetHeaderAsString(78)); if (options.Help) { Console.WriteLine(parser.UsageInfo.GetOptionsAsString(20, 56)); return(0); } else if (parser.HasErrors) { Console.WriteLine(parser.UsageInfo.GetErrorsAsString(78)); Console.WriteLine("type --help for list of available options."); return(-1); } Console.Write("Initializing communication plugins... "); Env.Initialize(null, new Commands(), FreeSCADA.Interfaces.EnvironmentMode.Runtime); Env.Current.Project.Load(options.ProjectFile); CommunationPlugs plugs = Env.Current.CommunicationPlugins; if (plugs.Connect() == false) { Env.Deinitialize(); return(-1); } Console.WriteLine("Done."); Uri baseAddress = new Uri(string.Format("http://{0}:{1}/", System.Windows.Forms.SystemInformation.ComputerName, options.Port)); ServiceHost host = new ServiceHost(typeof(Service), baseAddress); try { host.AddServiceEndpoint(typeof(IChannelInformationRetriever), new WSDualHttpBinding(WSDualHttpSecurityMode.None), "ChannelInformationRetriever"); host.AddServiceEndpoint(typeof(IDataRetriever), new WSDualHttpBinding(WSDualHttpSecurityMode.None), "DataRetriever"); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; host.Description.Behaviors.Add(smb); ServiceThrottlingBehavior throttlingBehavior = new ServiceThrottlingBehavior(); throttlingBehavior.MaxConcurrentCalls = Int32.MaxValue; throttlingBehavior.MaxConcurrentInstances = Int32.MaxValue; throttlingBehavior.MaxConcurrentSessions = Int32.MaxValue; host.Description.Behaviors.Add(throttlingBehavior); host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None; host.Open(); Console.WriteLine("Server address {0}", baseAddress.AbsoluteUri); Console.WriteLine("Press <ENTER> to terminate"); Console.ReadLine(); Console.WriteLine("Terminating. Please wait..."); host.Close(); } catch (CommunicationException cex) { Console.WriteLine("Error occured: {0}", cex.Message); host.Abort(); } plugs.Disconnect(); Env.Deinitialize(); return(0); }