Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Validates the text displayed in the spin box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void ValidateEditText()
        {
            if (m_preventValidation)
            {
                return;
            }
            m_preventValidation = true;

            string str = Text;

            if (str == string.Empty && Changed != null)
            {
                // Give our "owner" (or whoever cares) a chance to define what should happen if
                // the user deletes our value (such as resetting our value to some default).
                Changed(this, EventArgs.Empty);
                return;
            }

            double nVal = MeasurementUtils.ExtractMeasurementInMillipoints(str, m_measureType, m_mptValue);

            if (m_fDisplayAbsoluteValues && m_mptValue < 0)
            {
                nVal *= -1;
            }

            if (nVal != m_mptValue)
            {
                if (!m_fDisplayAbsoluteValues || Math.Sign(nVal) == Math.Sign(m_mptValue))
                {
                    SetMsrValue(nVal);
                }
            }
            UpdateEditText();
            m_preventValidation = false;
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public void UpdateData(object sender, EventArgs e)
 {
     try
     {
         ApplicationMode    = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.IMDApplicationMode));
         GeneralWeightError = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusGeneralWeightError)));
         ScaleAlarm         = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleAlarm)));
         int LimitStatus = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusLimitStatus));
         Underload           = (LimitStatus == 1);
         Overload            = (LimitStatus == 2);
         HigherSafeLoadLimit = (LimitStatus == 3);
         TareMode            = EvaluateTareMode(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusManualTare)), Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusWeightType)));
         WeightStable        = !Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusWeightMoving)));
         LegalForTrade       = !Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleSealIsOpen)));
         ScaleRange          = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleRange));
         ZeroRequired        = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusZeroRequired)));
         CenterOfZero        = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusCenterOfZero)));
         InsideZero          = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusInsideZero)));
         Decimals            = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461Decimals));
         Unit = UnitIDToString(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461Unit)));
         Weight.Update(MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461NetValue)), Decimals), MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461GrossValue)), Decimals));
         PrintableWeight.Update(MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461NetValue)), Decimals), MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461GrossValue)), Decimals), Decimals);
     }
     catch (KeyNotFoundException)
     {
         Console.WriteLine("KeyNotFoundException in class ProcessDataJet, update method");
     }
 }
        /// <summary>
        /// Updates and converts the values from buffer
        /// </summary>
        /// <param name="sender">Connection class</param>
        /// <param name="e">EventArgs, Event argument</param>
        public void UpdateDataLimitSwitch(object sender, EventArgs e)
        {
            try
            {
                LimitStatus1 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus2 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus3 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus4 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));

                ApplicationMode _applicationMode = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.IMDApplicationMode));
                if (_applicationMode == ApplicationMode.Standard)
                {
                    _limitSwitch1Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch1Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch1LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch1HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch2Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch2Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch2LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch2HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch3Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch3Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch3LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch3HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch4Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch4Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch4LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch4HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                }
            }
            catch (KeyNotFoundException)
            {
                Console.WriteLine("KeyNotFoundException in class DataStandardModbus, update method");
            }
        }
        public void BatchSizeTest()
        {
            // Check if Streaming makes a difference:
            var streamingModes = new bool[] { true, false };

            // Check if Batch Sizes make a difference:
            var batchSizes = new int[] { 10000, 50000, 80000, 100000 };

            foreach (var streamingMode in streamingModes)
            {
                foreach (var batchSize in batchSizes)
                {
                    // Number Of Entities:
                    var numberOfEntities = 1000000;

                    // Bulk Options:
                    var bulkOptions = new BulkCopyOptions(batchSize, TimeSpan.FromSeconds(30), streamingMode, SqlBulkCopyOptions.Default);

                    // Build the Test Subject:
                    var bulkInsert = new SqlServerBulkInsert <TestEntity>(new TestEntityMapping(), bulkOptions);

                    // Experiment Name:
                    var experimentName = string.Format("BatchExperiment (NumberOfEntities = {0}, BatchSize = {1}, Streaming = {2})", numberOfEntities, batchSize, streamingMode);

                    // Measure and Print the Elapsed Time:
                    MeasurementUtils.MeasureElapsedTime(experimentName, () => WriteDataInTransaction(bulkInsert, GenerateEntities(numberOfEntities)));
                }
            }
        }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public override bool AdjustNominalSignalWithCalibrationWeight(double adjustmentWeight)
 {
     Stop();
     Connection.WriteInteger(ModbusCommands.CWTScaleCalibrationWeight, MeasurementUtils.DoubleToDigit(adjustmentWeight, ProcessData.Decimals));
     Connection.WriteInteger(ModbusCommands.LWTNominalSignal, 0x7FFFFFFF);
     _result = Connection.WriteInteger(ModbusCommands.ControlWordAdjustNominal, 1);
     this.Restart();
     return(_result);
 }
Ejemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the text displayed in the spin box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void UpdateEditText()
        {
            // Prevent validation while updating the text. Since we know what will be
            // set, there is no need to validate it.
            m_preventValidation = true;

            double valueToDisplay = m_fDisplayAbsoluteValues ? Math.Abs(m_mptValue) : m_mptValue;

            Text = MeasurementUtils.FormatMeasurement(valueToDisplay, m_measureType, UseVariablePrecision);
            m_preventValidation = false;
        }
Ejemplo n.º 7
0
        private static async Task <Dictionary> LoadDictionary()
        {
            Console.WriteLine("Loading...");
            var dict    = new Dictionary(Games.Polish);
            var task    = dict.Load("Dictionaries/pl.txt");
            var elapsed = await MeasurementUtils.RunWithStopwatch(task);

            var compressed = 1f - dict.Words / (float)dict.Lines;

            Console.WriteLine($"Loaded in {elapsed.TotalMilliseconds} ms, lines {dict.Lines}, words {dict.Words} (compressed {compressed:P})");
            return(dict);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Updates and converts the values from buffer
 /// </summary>
 /// <param name="sender">Connection class</param>
 /// <param name="e">EventArgs, Event argument</param>
 public void UpdateDataIO(object sender, EventArgs e)
 {
     try
     {
         Input1   = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS1DigitalInput1));
         Input2   = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS2DigitalInput2));
         Input3   = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS3DigitalInput3));
         Input4   = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS4DigitalInput4));
         _output1 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS1DigitalOutput1));
         _output2 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS2DigitalOutput2));
         _output3 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS3DigitalOutput3));
         _output4 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS4DigitalOutput4));
     }
     catch (KeyNotFoundException)
     {
         Console.WriteLine("KeyNotFoundException in class DataStandardJet, update method");
     }
 }
Ejemplo n.º 9
0
        ///<inheritdoc/>
        public override bool AdjustNominalSignalWithCalibrationWeight(double calibrationWeight)
        {
            Connection.WriteInteger(JetBusCommands.CIA461CalibrationWeight, MeasurementUtils.DoubleToDigit(calibrationWeight, ProcessData.Decimals));

            Connection.WriteInteger(JetBusCommands.CIA461ScaleCommand, SCALE_COMMAND_CALIBRATE_NOMINAL);
           
            
            while (Convert.ToInt32(Connection.ReadFromBuffer(JetBusCommands.CIA461ScaleCommandStatus)) != SCALE_COMMAND_STATUS_ONGOING)
            {
                Thread.Sleep(100);
            }
            
            while (Convert.ToInt32(Connection.ReadFromBuffer(JetBusCommands.CIA461ScaleCommandStatus)) == SCALE_COMMAND_STATUS_ONGOING)
            {
                Thread.Sleep(100);
            }

            if (Convert.ToInt32(Connection.ReadFromBuffer(JetBusCommands.CIA461ScaleCommandStatus)) == SCALE_COMMAND_STATUS_OK)
            { 
                return true;
            }

            return false;
        }
Ejemplo n.º 10
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Append information about a measure value
 /// </summary>
 /// <param name="text">text string to append to</param>
 /// <param name="measureLabel">Label identifying what this measurement represents</param>
 /// <param name="msrType">Type representing the measurement units to which the value
 /// should be converted and with which it should be shown.</param>
 /// <param name="value">measurement value (in millipoints) to write</param>
 /// ------------------------------------------------------------------------------------
 private void AppendMeasure(StringBuilder text, string measureLabel, MsrSysType msrType,
                            int value)
 {
     AppendItem(text, measureLabel, MeasurementUtils.FormatMeasurement(value, msrType));
 }
Ejemplo n.º 11
0
 ///<inheritdoc/>
 public override void TareManually(double manualTareValue)
 {
     Connection.WriteInteger(JetBusCommands.CIA461TareValue, MeasurementUtils.DoubleToDigit(manualTareValue, ProcessData.Decimals));
 }
Ejemplo n.º 12
0
        public void Update()
        {
            int requestedFrame = Time.frameCount % SequenceFramesCount;

            MeasurementUtils.SetAnimationToMeasurement(Director, SequenceFramesCount, requestedFrame);
        }