示例#1
0
文件: Commutator.cs 项目: slawer/skc
        /// <summary>
        /// инициализирует новый экземпляр класса
        /// </summary>
        /// <param name="_tech">Технологическая примочка</param>
        /// <param name="_parameters">Список параметров системы</param>
        /// <param name="_buffer">Буфер в который сохраняются данные</param>
        public Commutator(Tech _tech, Parameter[] _parameters, RSliceBuffer _buffer)
        {
            if (_tech != null && _parameters != null && _buffer != null)
            {
                tech = _tech;
                buffer = _buffer;

                parameters = _parameters;

                tech.onCalculate += new EventHandler(tech_onCalculate);
                tech.onJop += new EventHandler(tech_onJop);
                DevManClient.onReceive += new ReceivedEventHandler(DevManClient_onReceive);
            }
            else
                ErrorHandler.WriteToLog(this, new ErrorArgs("Коммутатор не смог выполнить инициализацию", ErrorType.Fatal));
        }
示例#2
0
文件: Commutator.cs 项目: slawer/sgt
        protected SaverTechnologyData tech_saver; // реализует сохранение технологических данных

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        public Commutator()
        {
            buffer = new RSliceBuffer();
            parameters = new Parameter[256];

            t_slim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
            p_slim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            wcf_slim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            for (int i = 0; i < parameters.Length; i++)
            {
                parameters[i] = new Parameter();
            }

            InitializeWcf();
        }
示例#3
0
文件: Commutator.cs 项目: slawer/sgt
        /// <summary>
        /// Загрузить локальный буфер
        /// </summary>
        public void DeSerialize()
        {
            try
            {
                string fileName = string.Format("{0}\\{1}", Environment.CurrentDirectory, "file.s");
                if (File.Exists(fileName))
                {
                    FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                    BinaryFormatter bf = new BinaryFormatter();

                    buffer = (RSliceBuffer)bf.Deserialize(fs);
                    fs.Close();
                }
            }
            catch { }
            finally
            {
                if (buffer == null)
                {
                    buffer = new RSliceBuffer();
                }
            }
        }
示例#4
0
文件: Application.cs 项目: slawer/skc
        protected Tech tech = null; // технологическая примочка

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        protected Application()
        {
            try
            {
                ErrorHandler.InitializeErrorHandler();
                ErrorHandler.OnExit += new EventHandler(ErrorHandler_OnExit);

                buffer = new RSliceBuffer(72000);
                manager = new DataBaseManager();

                projects = new List<Project>();
                commands = new List<BlockViewCommand>();

                parameters = new Parameter[256];
                for (int index = 0; index < parameters.Length; index++)
                {
                    parameters[index] = new Parameter(index);
                    parameters[index].Identifier = Identifiers.GetGuid(index);
                }

                tech = new Tech();
                commutator = new Commutator(tech, parameters, buffer);

                panels = new List<ParametersViewPanel>();
            //                devManUri = new Uri("net.tcp://localhost:57000");
                devManUri = new Uri("net.tcp://127.0.0.1:57000");

                CheckRegistry();

                LoadUri();

                DevManClient.Uri = devManUri;

                DevManClient.Context.Mode = UserMode.Passive;
                DevManClient.Context.Role = Role.Common;

                client = new devTcpManager();

                Ping ping = new Ping();
                PingOptions options = new PingOptions();

                try
                {
                    PingReply reply = ping.Send(devManUri.Host);
                    if (reply.Status == IPStatus.Success)
                    {
                        /*DevManClient.Uri = devManUri;

                        DevManClient.Context.Mode = UserMode.Passive;
                        DevManClient.Context.Role = Role.Common;*/

                        DevManClient.Connect();

                        // client = new devTcpManager();

                        string ip = System.Net.Dns.Resolve(devManUri.Host).AddressList[0].ToString();
                        //string ip = System.Net.Dns.GetHostEntry(devManUri.Host).AddressList[0].ToString();

                        client.Client.Host = ip;
                        client.Client.Port = 56000;

                        client.Client.Connect();
                    }
                    else
                    {
                        /*try
                        {
                            client = null;
                        }
                        catch { }*/
                    }
                }
                catch { }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Fatal));
            }
        }