Exemplo n.º 1
0
 public static void Load(string path)
 {
     if (_instance == null)
     {
         using (var s = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
         {
             _instance      = (BasicConfiguration) new XmlSerializer(typeof(BasicConfiguration)).Deserialize(s);
             _instance.Path = path;
         }
     }
 }
Exemplo n.º 2
0
 public static void Load (string path)
 {
     if (_instance == null)
     {
         using (var s = File.Open (path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
         {
             _instance = (BasicConfiguration)new XmlSerializer (typeof (BasicConfiguration)).Deserialize (s);
             _instance.Path = path;
         }
     }
 }
Exemplo n.º 3
0
 public void FillExample()
 {
     Comport = "COM1";
     NumberOfContactClosureBanks = 1;
     AvailableRelayBanks         = new List <RelayBank>
     {
         new RelayBank
         {
             AvailableRelays = 8,
             Number          = 0
         }
     };
     _instance = this;
 }
Exemplo n.º 4
0
 public void FillExample()
 {
     Comport = "COM1";
     NumberOfContactClosureBanks = 1;
     AvailableRelayBanks = new List<RelayBank>
                               {
                                   new RelayBank
                                       {
                                           AvailableRelays = 8,
                                           Number = 0
                                       }
                               };
     _instance = this;
 }
Exemplo n.º 5
0
        public void Initialize()
        {
            var configfile = ConfigurationManager.AppSettings["ConfigurationFilePath"];

            if (File.Exists(configfile))
            {
                BasicConfiguration.Load(configfile);
            }
            else
            {
                new BasicConfiguration
                {
                    Path = configfile
                }.FillExample();

                BasicConfiguration.Save();
                throw new Exception("EmptyConfigurationException, Please fill the configuration with the right information and start again.");
            }

            NCDComponent = new NCDComponent {
                BaudRate = 38400, PortName = BasicConfiguration.Configuration.Comport
            };
            NCDComponent.OpenPort();
            if (!NCDComponent.IsOpen)
            {
                throw new Exception("Can't open port");
            }

            //-------Output states
            var outputState = NCDComponent.ProXR.RelayBanks.GetRelaysStatusInAllBanks();

            for (byte bank = 0; bank < BasicConfiguration.Configuration.AvailableRelayBanks.Count; bank++)
            {
                ReportOutputStates(bank, ParseValue(outputState[bank]));
            }

            Run = new Thread(Runner);
            Run.Start(this);
            Input = new Thread(InputRunner);
            Input.Start(this);
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     BasicConfiguration.Save();
     Run.Abort();
     Input.Abort();
 }