Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveClientCom.cs @ 5325

Last change on this file since 5325 was 5314, checked in by ascheibe, 13 years ago

#1233

  • added ItemView and Item for the Slave
  • added a Tray Icon App for data visualization and control of the slave windows service
  • added control methods to SlaveCommunication for controlling the slave core
  • fixed typo in namespace
File size: 2.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.ServiceModel;
23using HeuristicLab.Clients.Hive.Slave;
24using HeuristicLab.Clients.Hive.Slave.ServiceContracts;
25
26namespace HeuristicLab.Clients.Hive.Slave {
27
28  /// <summary>
29  /// Singleton which encapsulates the SlaveCommunicationService
30  /// </summary>
31  public class SlaveClientCom {
32    private static SlaveClientCom instance;
33    private static DuplexChannelFactory<ISlaveCommunication> pipeFactory;
34    /// <summary>
35    /// Getter for the Instance of the SlaveClientCom
36    /// </summary>
37    /// <returns>the Instance of the SlaveClientCom class</returns>
38    public static SlaveClientCom Instance {
39      get {
40        if (instance == null) {
41          instance = new SlaveClientCom();
42        }
43        return instance;
44      }
45    }
46
47    public ISlaveCommunication ClientCom { get; set; }
48
49    private SlaveClientCom() {
50      setupClientCom();
51    }
52
53    private void setupClientCom() {
54      DummyListener dummy = new DummyListener();
55      pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(
56        dummy, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));
57      ISlaveCommunication pipeProxy = pipeFactory.CreateChannel();
58      ClientCom = pipeProxy;
59    }
60
61    public static void Close() {
62      if (pipeFactory.State != CommunicationState.Closed)
63        pipeFactory.Close();
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.