protected ReaderWriterLockSlim cal_slim = null;           // синхронизатор вычислнения данных

        /// <summary>
        /// Реализует технологию СГТ
        /// </summary>
        public void Calculate(Object sender, CommutatorEventArgs e)
        {
            if (cal_slim.TryEnterWriteLock(50))
            {
                try
                {
                    TechnologyTime = DateTime.Now;
                    InitializeTechData(e.Slice);

                    CalculateSimple(e.Slice, TechnologyTime);
                    CalculateComplex(e.Slice, TechnologyTime);

                    CalculateDrilling(e.Slice, TechnologyTime);

                    TechnologicalStage  = p206.Stage;
                    TechnologicalRegime = p206.Regime;

                    TechnologicalHook = p206.Hook;

                    if (onComplete != null)
                    {
                        onComplete(this, EventArgs.Empty);
                    }
                }
                finally
                {
                    cal_slim.ExitWriteLock();
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Завершен цикл опроса устройств
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Serial_OnStaticComplete(Object sender, CommutatorEventArgs e)
 {
     bool blocked = false;
     try
     {
         if (mutex.WaitOne(1000, false))
         {
             blocked = true;
             foreach (DataGridViewRow row in dataGridView10.Rows)
             {
                 if (row.Index < dataGridView10.Rows.Count - 1)
                 {
                     Parameter parameter = row.Tag as Parameter;
                     if (parameter != null)
                     {
                         row.Cells[2].Value = parameter.FormattedCurrentValue;
                     }
                 }
             }
         }
     }
     finally
     {
         if (blocked) mutex.ReleaseMutex();
     }
 }
Ejemplo n.º 3
0
        protected ReaderWriterLockSlim cal_slim = null; // синхронизатор вычислнения данных

        #endregion Fields

        #region Methods

        /// <summary>
        /// Реализует технологию СГТ
        /// </summary>
        public void Calculate(Object sender, CommutatorEventArgs e)
        {
            if (cal_slim.TryEnterWriteLock(50))
            {
                try
                {
                    TechnologyTime = DateTime.Now;
                    InitializeTechData(e.Slice);

                    CalculateSimple(e.Slice, TechnologyTime);
                    CalculateComplex(e.Slice, TechnologyTime);

                    CalculateDrilling(e.Slice, TechnologyTime);

                    TechnologicalStage = p206.Stage;
                    TechnologicalRegime = p206.Regime;

                    TechnologicalHook = p206.Hook;

                    if (onComplete != null)
                    {
                        onComplete(this, EventArgs.Empty);
                    }
                }
                finally
                {
                    cal_slim.ExitWriteLock();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Завершен цикл опроса устройств
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Serial_OnStaticComplete(Object sender, CommutatorEventArgs e)
        {
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(1000, false))
                {
                    blocked = true;
                    foreach (DataGridViewRow row in dataGridView10.Rows)
                    {
                        if (row.Index < dataGridView10.Rows.Count - 1)
                        {
                            Parameter parameter = row.Tag as Parameter;
                            if (parameter != null)
                            {
                                row.Cells[2].Value = parameter.FormattedCurrentValue;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
        }