Example #1
0
        /// <summary>
        /// Common initialization code.
        /// </summary>
        protected virtual void Initialize(Dictionary <string, string> configuration, ZeroMqSocketType socketType, bool isInbound, IQueueLogger loggerObject = null)
        {
            try
            {
                #region Logger Initialization
                logger = loggerObject;
                #endregion

                #region Parameters Collection
                zmqConfiguration = CommonItems.CollectZmqConfiguration(ref configuration, isInbound, ref logger);
                #endregion

                #region Creating Socket
                InitializeZeroMqSocket(socketType, isInbound);
                #endregion
            }
            catch (Exception ex) when(!(ex is QueueException))
            {
                throw MessageQueueCommonItems.PrepareAndLogQueueException(
                          errorCode: QueueErrorCode.FailedToInitializeMessageQueue,
                          message: ErrorMessages.FailedToInitializeMessageQueue,
                          innerException: ex,
                          queueContext: CommonItems.ZeroMqName,
                          address: zmqConfiguration.Address,
                          logger: logger);
            }
        }
 /// <summary>
 /// Set default values for concentrated load.
 /// </summary>
 private void LoadConcentratedDefaultValues()
 {
     // Next 3 lines initialize concentrated load position values.
     TboxLoadConcentratedPosition.Text   = string.Empty;
     doubleLoadConcentratedPosition      = 0d;
     boolEnteredLoadConcentratedPosition = false;
     // Next 3 lines initialize concentrated load force values.
     TboxLoadConcentratedForce.Text   = string.Empty;
     doubleLoadConcentratedForce      = 0d;
     boolEnteredLoadConcentratedForce = false;
     // Next 3 lines initialize concentrated load moment values.
     TboxLoadConcentratedMoment.Text    = string.Empty;
     doubleLoadConcentratedMoment       = 0d;
     boolEnteredLoadConcentratedMoment  = false;
     TblkLoadConcentratedDisplay.Text   = CommonItems.ShowEnteredSupportsAndLoads();
     TblkLoadConcentratedLostFocus.Text = string.Empty;
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedAdd, false);
     if (CommonItems.listLoadConcentratedValues.Count > 0)
     {
         CommonItems.boolEnteredLoadConcentrated = true;
     }
     else
     {
         CommonItems.boolEnteredLoadConcentrated = false;
     }
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedClear, CommonItems.boolEnteredLoadConcentrated);
 }
Example #3
0
        /// <summary>
        /// Code that runs after page is loaded that will not execute properly until page is rendered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _ = sender;     // Discard unused parameter.
            _ = e;          // Discard unused parameter.
            List <ToggleSwitch> listToggleSwitchesThisPage = new List <ToggleSwitch>()
            {
                TogSupportDisplacement,
                TogSupportRotation
            };

            LibMPC.SizePageToggleSwitches(listToggleSwitchesThisPage);
            List <Button> listButton = new List <Button>()
            {
                ButSupportAdd,
                ButSupportReturn,
                ButSupportClear
            };

            LibMPC.SizePageButtons(listButton);
            // Only one TextBox this pages so set MinWidth to above button widths.
            TboxSupportPosition.MinWidth = ButSupportClear.MinWidth;
            // Resize following defined support buttons separately since description is much longer.
            listButton = new List <Button>()
            {
                ButSupportDefined1,
                ButSupportDefined2
            };
            LibMPC.SizePageButtons(listButton);
            SetDefaultValuesSupport();
            CommonItems.ButtonForegroundColorSet(ButSupportReturn, true);
            CommonItems.ButtonForegroundColorSet(ButSupportClear, CommonItems.boolEnteredSupport);
        }
        /// <summary>
        /// Check if uniform load input values are valid and toggle foreground color of ButLoadUniformAdd accordingly.
        /// </summary>
        /// <returns></returns>
        private void CheckLoadUniformInputValues()
        {
            // Need to check if all input values valid each time method is called since they can be changed independently by User any time.
            TblkLoadUniformResult.Text = string.Empty;
            // Set boolLoadUniformValid to true as default. Value of following bools are set elsewhere so do not need to duplicate error checks here.
            bool boolLoadUniformValid = true;

            if (!boolEnteredLoadUniformPositionLeft)
            {
                boolLoadUniformValid = false;
            }
            if (!boolEnteredLoadUniformPositionRight)
            {
                boolLoadUniformValid = false;
            }
            if (!boolEnteredLoadUniformForceLeft)
            {
                boolLoadUniformValid = false;
            }
            if (!boolEnteredLoadUniformForceRight)
            {
                boolLoadUniformValid = false;
            }
            CommonItems.ButtonForegroundColorSet(ButLoadUniformAdd, boolLoadUniformValid);
        }
 /// <summary>
 /// Set default values for uniform load.
 /// </summary>
 private void LoadUniformDefaultValues()
 {
     // Next 3 lines initialize left uniform load position values.
     TboxLoadUniformPositionLeft.Text   = string.Empty;
     doubleLoadUniformPositionLeft      = 0d;
     boolEnteredLoadUniformPositionLeft = false;
     // Next 3 lines initialize right uniform load position values.
     TboxLoadUniformPositionRight.Text   = string.Empty;
     doubleLoadUniformPositionRight      = 0d;
     boolEnteredLoadUniformPositionRight = false;
     // Next 3 lines initialize left uniform load force values.
     TboxLoadUniformForceLeft.Text   = string.Empty;
     doubleLoadUniformForceLeft      = 0d;
     boolEnteredLoadUniformForceLeft = false;
     // Next 3 lines initialize right uniform load force values.
     TboxLoadUniformForceRight.Text   = string.Empty;
     doubleLoadUniformForceRight      = 0d;
     boolEnteredLoadUniformForceRight = false;
     if (CommonItems.listLoadUniformValues.Count > 0)
     {
         CommonItems.boolEnteredLoadUniform = true;
     }
     else
     {
         CommonItems.boolEnteredLoadUniform = false;
     }
     TblkLoadUniformDisplay.Text   = CommonItems.ShowEnteredSupportsAndLoads();
     TblkLoadUniformLostFocus.Text = string.Empty;
     CommonItems.ButtonForegroundColorSet(ButLoadUniformAdd, false);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformClear, CommonItems.boolEnteredLoadUniform);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformSimulatedLoads, CommonItems.boolEnteredLoadUniform);
 }
 /// <summary>
 /// Clear beam properties.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButBeamPropertiesClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButBeamPropertiesClear_Click() event fired.");
     CommonItems.stringNameMaterial = TboxBeamPropertiesNameMaterial.Text = string.Empty;
     mainPage.applicationDataContainer.Values[CommonItems.ds_StringNameMaterial] = TboxBeamPropertiesNameMaterial.Text;
     TboxBeamPropertiesYoungsModulus.Text = string.Empty;
     CommonItems.boolEnteredYoungsModulus = false;
     CommonItems.doubleYoungsModulus      = 0d;
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleYoungsModulus] = CommonItems.doubleYoungsModulus;
     TboxBeamPropertiesPoissonsRatio.Text = string.Empty;
     CommonItems.boolEnteredPoissonsRatio = false;
     CommonItems.doublePoissonsRatio      = 0d;
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoublePoissonsRatio] = CommonItems.doublePoissonsRatio;
     CommonItems.stringNameCrossSection = TboxBeamPropertiesNameCrossSection.Text = string.Empty;
     mainPage.applicationDataContainer.Values[CommonItems.ds_StringNameCrossSection] = TboxBeamPropertiesNameCrossSection.Text;
     TboxBeamPropertiesInertia.Text = string.Empty;
     CommonItems.boolEnteredInertia = false;
     CommonItems.doubleInertia      = 0d;
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleInertia] = CommonItems.doubleInertia;
     TboxBeamPropertiesLength.Text     = string.Empty;
     CommonItems.boolEnteredBeamLength = false;
     CommonItems.doubleBeamLength      = 0d;
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleBeamLength] = CommonItems.doubleBeamLength;
     // Also clear supports and loads.
     CommonItems.ClearSupports();
     CommonItems.ClearLoadsConcentrated();
     CommonItems.ClearLoadsUniform();
     CheckBeamPropertyInputValues();
     LibMPC.OutputMsgSuccess(TblkBeamPropertiesLostFocus, "Cleared all items in this page.  Also cleared any existing supports and loads.");
 }
Example #7
0
        /// <summary>
        /// Common initialization code.
        /// </summary>
        protected virtual void Initialize(Dictionary <string, string> configuration, bool isInbound, IQueueLogger loggerObject = null)
        {
            try
            {
                #region Logger Initialization
                logger = loggerObject;
                #endregion

                #region Parameters Collection
                sbConfiguration = CommonItems.CollectSbConfiguration(ref configuration, isInbound, ref logger);
                #endregion

                #region Initializing Queue
                queueClient = QueueClient.CreateFromConnectionString(sbConfiguration.Address);

                if (!string.IsNullOrWhiteSpace(sbConfiguration.NamespaceAddress))
                {
                    namespaceManager = NamespaceManager.CreateFromConnectionString(sbConfiguration.NamespaceAddress);
                }

                // Updating address field to remove confidential data.
                sbConfiguration.Address          = sbConfiguration.Address?.Split(';')?.FirstOrDefault(x => x.StartsWith(CommonItems.SbConnectionStringAddressPartName, StringComparison.InvariantCultureIgnoreCase));
                sbConfiguration.NamespaceAddress = sbConfiguration.NamespaceAddress?.Split(';')?.FirstOrDefault(x => x.StartsWith(CommonItems.SbConnectionStringAddressPartName, StringComparison.InvariantCultureIgnoreCase));

                if (!IsQueueExistsHelper())
                {
                    throw MessageQueueCommonItems.PrepareAndLogQueueException(
                              errorCode: QueueErrorCode.QueueDoesNotExist,
                              message: ErrorMessages.QueueDoesNotExist,
                              innerException: null,
                              queueContext: CommonItems.ServiceBusName,
                              queueName: sbConfiguration.QueueName,
                              address: sbConfiguration.Address,
                              logger: logger);
                }

                // Updating flag.
                isInitialized = true;
                #endregion
            }
            catch (Exception ex) when(!(ex is QueueException))
            {
                throw MessageQueueCommonItems.PrepareAndLogQueueException(
                          errorCode: QueueErrorCode.FailedToInitializeMessageQueue,
                          message: ErrorMessages.FailedToInitializeMessageQueue,
                          innerException: ex,
                          queueContext: CommonItems.ServiceBusName,
                          queueName: sbConfiguration.QueueName,
                          address: sbConfiguration.Address,
                          logger: logger);
            }
        }
 /// <summary>
 /// Add load if User has entered position, force, and moment values for load. Otherwise show error message.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadConcentratedAdd_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"ButLoadConcentratedAdd_Click() event fired.");
     TblkLoadConcentratedLostFocus.Text = string.Empty;
     if (boolEnteredLoadConcentratedPosition && boolEnteredLoadConcentratedForce && boolEnteredLoadConcentratedMoment)
     {
         AddLoadConcentratedToList();
         TblkLoadConcentratedDisplay.Text = CommonItems.ShowEnteredSupportsAndLoads();
         LibMPC.OutputMsgSuccess(TblkLoadConcentratedResult, $"Concentrated load added.");
         LoadConcentratedDefaultValues();
     }
     else
     {
         // Build error message to show User if position, force, or moment values not entered.
         string stringErrorMsg    = "Concentrated load not added since one or more following values not entered or not valid:\n";
         bool   boolErrorPosition = false;
         bool   boolErrorForce    = false;
         if (!boolEnteredLoadConcentratedPosition)
         {
             boolErrorPosition = true;
             stringErrorMsg   += $"{CommonItems.stringConstPosition}";
         }
         if (!boolEnteredLoadConcentratedForce)
         {
             boolErrorForce = true;
             if (boolErrorPosition)
             {
                 stringErrorMsg += $", {CommonItems.stringConstForce}";
             }
             else
             {
                 stringErrorMsg += $"{CommonItems.stringConstForce}";
             }
         }
         if (!boolEnteredLoadConcentratedMoment)
         {
             if (boolErrorPosition || boolErrorForce)
             {
                 stringErrorMsg += $", {CommonItems.stringConstMoment}";
             }
             else
             {
                 stringErrorMsg += $"{CommonItems.stringConstMoment}";
             }
         }
         LibMPC.OutputMsgError(TblkLoadConcentratedResult, stringErrorMsg);
     }
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedClear, CommonItems.boolEnteredLoadConcentrated);
 }
 /// <summary>
 /// Calculate beam results if all required entry items entered and valid.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadUniformSimulatedLoads_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadUniformSimulatedLoads_Click(): Event fired.");
     TblkLoadUniformLostFocus.Text = string.Empty;
     if (CommonItems.boolEnteredLoadUniform)
     {
         CommonItems.stringOutputResults = CommonItems.ShowUniformLoadsSimulated();
         mainPage.ShowPageDisplaySimulatedLoads();
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformResult, "No results to display since no uniform loads entered.");
     }
 }
Example #10
0
        /// <summary>
        /// Set default values for support.
        /// </summary>
        private void SetDefaultValuesSupport()
        {
            // Next 3 lines initialize support position values.
            TboxSupportPosition.Text   = string.Empty;
            doubleSupportPosition      = 0d;
            boolEnteredSupportPosition = false;
            // Next 2 lines initialize support displacement values.
            TogSupportDisplacement.IsOn = false;
            boolSupportDisplacement     = false;
            // Next 2 lines initialize support rotation values.
            TogSupportRotation.IsOn = true;
            boolSupportRotation     = true;

            TblkSupportDisplay.Text   = CommonItems.ShowEnteredSupportsAndLoads();
            TblkSupportLostFocus.Text = string.Empty;
            CommonItems.ButtonForegroundColorSet(ButSupportAdd, false);
        }
        /// <summary>
        /// Do following when TboxBeamPropertiesLength focus changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TboxBeamPropertiesLength_LostFocus(object sender, RoutedEventArgs e)
        {
            _ = sender;     // Discard unused parameter.
            _ = e;          // Discard unused parameter.
            //Debug.WriteLine($"TboxBeamPropertiesLength_LostFocus(): Event fired.");
            // Save input to local beam length value, then check if valid, if valid then compare to global variable to check if value has changed.
            double doubleBeamLength = LibNum.TextBoxGetDouble(TboxBeamPropertiesLength, EnumTextBoxUpdate.Yes);   // Get the input from the TextBox and convert to matching numeric.

            if (doubleBeamLength >= doubleBeamLengthMinimum && doubleBeamLength <= doubleBeamLengthMaximum)
            {
                string stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid.";     // Default success string.
                CommonItems.boolEnteredBeamLength = true;
                if (!doubleBeamLength.Equals(CommonItems.doubleBeamLength))
                {
                    // Beam length changed.
                    CommonItems.doubleBeamLength = doubleBeamLength;
                    if (CommonItems.ClearLoadsConcentrated() || CommonItems.ClearLoadsUniform())
                    {
                        // Loads cannot be entered unless supports entered, so also clear supports.
                        CommonItems.ClearSupports();
                        stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid but has changed so cleared existing supports and loads.";
                    }
                    else if (CommonItems.ClearSupports())
                    {
                        stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid but has changed so cleared existing supports.";
                    }
                }
                LibMPC.OutputMsgSuccess(TblkBeamPropertiesLostFocus, stringSuccessMessage);
            }
            else
            {
                CommonItems.boolEnteredBeamLength = false;
                CommonItems.doubleBeamLength      = 0d;
                LibMPC.OutputMsgError(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstBeamLength} not valid.  Value must be in range of {doubleBeamLengthMinimum.ToString(LibNum.fpNumericFormatNone)} to {doubleBeamLengthMaximum.ToString(LibNum.fpNumericFormatNone)}.");
            }
            mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleBeamLength] = CommonItems.doubleBeamLength;
            if (CommonItems.doubleBeamLength.Equals(0d))
            {
                TboxBeamPropertiesLength.Text = string.Empty;
            }
            else
            {
                TboxBeamPropertiesLength.Text = CommonItems.doubleBeamLength.ToString(LibNum.fpNumericFormatNone);
            }
            CheckBeamPropertyInputValues();
        }
 /// <summary>
 /// Clear uniform load list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadUniformClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadUniformClear_Click() event fired.");
     if (CommonItems.ClearLoadsUniform())
     {
         LibMPC.OutputMsgSuccess(TblkLoadUniformResult, "Uniform loads cleared.");
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformResult, "Uniform loads not cleared since no loads entered.");
     }
     LoadUniformDefaultValues();     // Always reset default load uniform values.
     CommonItems.ButtonForegroundColorSet(ButLoadUniformAdd, false);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformClear, false);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformSimulatedLoads, false);
 }
 /// <summary>
 /// Clear concentrated load list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadConcentratedClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadConcentratedClear_Click() event fired.");
     if (CommonItems.ClearLoadsConcentrated())
     {
         TblkLoadConcentratedDisplay.Text = string.Empty;
         LibMPC.OutputMsgSuccess(TblkLoadConcentratedResult, "Concentrated loads cleared.");
     }
     else
     {
         TblkLoadConcentratedLostFocus.Text = string.Empty;
         LibMPC.OutputMsgError(TblkLoadConcentratedResult, "Concentrated loads not cleared since no loads entered.");
     }
     LoadConcentratedDefaultValues();     // Always reset default load concentrated values.
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedAdd, false);
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedClear, false);
 }
Example #14
0
 /// <summary>
 /// Clear support list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButSupportClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButSupportClear_Click() event fired.");
     if (CommonItems.ClearSupports())
     {
         TblkSupportDisplay.Text = string.Empty;
         LibMPC.OutputMsgSuccess(TblkSupportResult, "Supports were cleared.");
     }
     else
     {
         TblkSupportLostFocus.Text = string.Empty;
         LibMPC.OutputMsgError(TblkSupportResult, "Supports were not cleared since no supports entered.");
     }
     SetDefaultValuesSupport();  // Always reset default support values.
     CommonItems.ButtonForegroundColorSet(ButSupportAdd, false);
     CommonItems.ButtonForegroundColorSet(ButSupportClear, false);
 }
Example #15
0
 /// <summary>
 /// Add a support.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButSupportAdd_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"ButSupportAdd_Click(): Event fired.");
     TblkSupportLostFocus.Text = string.Empty;
     if (boolEnteredSupportPosition)
     {
         boolDefinedSupportEntered    = false;
         boolDefinedSupportEnteredAll = true;
         AddSupport();
     }
     else
     {
         CommonItems.ButtonForegroundColorSet(ButSupportAdd, boolEnteredSupportPosition);
         LibMPC.OutputMsgError(TblkSupportResult, "Support not added since support position not entered or not valid.");
     }
     CommonItems.ButtonForegroundColorSet(ButSupportClear, CommonItems.boolEnteredSupport);
 }
        /// <summary>
        /// Check and show status of required input items on BeamProperties page. Return true if all items valid, false otherwise.
        /// </summary>
        private bool CheckBeamPropertyInputValues()
        {
            bool boolInputValid = false;

            if (CommonItems.boolEnteredYoungsModulus && CommonItems.boolEnteredPoissonsRatio && CommonItems.boolEnteredInertia && CommonItems.boolEnteredBeamLength)
            {
                boolInputValid = true;
                LibMPC.OutputMsgSuccess(TblkBeamPropertiesDisplay, $"Beam length = {CommonItems.doubleBeamLength.ToString(LibNum.fpNumericFormatNone)} {CommonItems.stringConstUnitsLength}\nAll items on page are valid.");
            }
            else
            {
                // Do not overwrite existing textBlockItemStatus if here!
                string stringErrorMsg = "Following item(s) not entered or not valid:\n";
                if (!CommonItems.boolEnteredYoungsModulus)
                {
                    stringErrorMsg += $"{CommonItems.stringConstYoungsModulus}, ";
                }
                if (!CommonItems.boolEnteredPoissonsRatio)
                {
                    stringErrorMsg += $"{CommonItems.stringConstPoissonsRatio}, ";
                }
                if (!CommonItems.boolEnteredInertia)
                {
                    stringErrorMsg += $"{CommonItems.stringConstInertia}, ";
                }
                if (!CommonItems.boolEnteredBeamLength)
                {
                    stringErrorMsg += CommonItems.stringConstBeamLength;
                }
                stringErrorMsg += "\nCorrect above item(s) to calculate beam results.";
                LibMPC.OutputMsgError(TblkBeamPropertiesDisplay, stringErrorMsg);
            }
            if ((CommonItems.stringNameMaterial.Length > 0) || (CommonItems.stringNameCrossSection.Length > 0) || CommonItems.boolEnteredYoungsModulus || CommonItems.boolEnteredPoissonsRatio || CommonItems.boolEnteredInertia || CommonItems.boolEnteredBeamLength)
            {
                CommonItems.ButtonForegroundColorSet(ButBeamPropertiesClear, true);
            }
            else
            {
                CommonItems.ButtonForegroundColorSet(ButBeamPropertiesClear, false);
            }
            return(boolInputValid);
        }
        /// <summary>
        /// Check if concentrated load input values are valid and toggle foreground color of ButLoadConcentratedAdd accordingly.
        /// </summary>
        /// <returns></returns>
        private void CheckLoadConcentratedInputValues()
        {
            // Need to check if all input values valid each time method is called since they can be changed independently by User any time.
            TblkLoadConcentratedResult.Text = string.Empty;
            bool boolLoadConcentratedInputValuesValid = true;

            if (TboxLoadConcentratedPosition.Text.Length == 0)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            if (TboxLoadConcentratedForce.Text.Length == 0)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            if (TboxLoadConcentratedMoment.Text.Length == 0)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            // Check if concentrated load position is on beam.
            if (doubleLoadConcentratedPosition < 0d || doubleLoadConcentratedPosition > CommonItems.doubleBeamLength)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            // Check if concentrated load force value in valid range.
            if (doubleLoadConcentratedForce < -doubleLoadConcentratedValueMax || doubleLoadConcentratedForce > doubleLoadConcentratedValueMax)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            // Check if concentrated load moment value in valid range.
            if (doubleLoadConcentratedMoment < -doubleLoadConcentratedValueMax || doubleLoadConcentratedMoment > doubleLoadConcentratedValueMax)
            {
                boolLoadConcentratedInputValuesValid = false;
            }

            CommonItems.ButtonForegroundColorSet(ButLoadConcentratedAdd, boolLoadConcentratedInputValuesValid);
        }
Example #18
0
        /// <summary>
        /// Check if support input values are valid and toggle foreground color of ButSupportAdd accordingly.
        /// </summary>
        /// <returns></returns>
        private void CheckSupportInputValues()
        {
            // Need to check if all input values valid each time method is called since they values can be changed by User any time.
            bool boolSupportInputValuesValid = true;

            if (TboxSupportPosition.Text.Length == 0)
            {
                boolSupportInputValuesValid = false;
            }
            // Check if support position is on beam.
            if (doubleSupportPosition < 0d || doubleSupportPosition > CommonItems.doubleBeamLength)
            {
                boolSupportInputValuesValid = false;
            }
            // Check if displacement and rotation bools are both true. Support is not valid if so since not really a support in this case.
            if (boolSupportDisplacement == true && boolSupportRotation == true)
            {
                boolSupportInputValuesValid = false;
            }
            CommonItems.ButtonForegroundColorSet(ButSupportAdd, boolSupportInputValuesValid);
        }
        /// <summary>
        /// Add uniform load if User has entered valid position and force values for load. Otherwise show error message.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButLoadUniformAdd_Click(object sender, RoutedEventArgs e)
        {
            _ = sender;     // Discard unused parameter.
            _ = e;          // Discard unused parameter.
            //Debug.WriteLine($"ButLoaduniformAdd_Click() event fired.");
            TblkLoadUniformLostFocus.Text = string.Empty;
            if (boolEnteredLoadUniformPositionLeft && boolEnteredLoadUniformPositionRight && boolEnteredLoadUniformForceLeft && boolEnteredLoadUniformForceRight)
            {
                CommonItems.AddLoadUniformToList(doubleLoadUniformPositionLeft, doubleLoadUniformPositionRight, doubleLoadUniformForceLeft, doubleLoadUniformForceRight);
                TblkLoadUniformDisplay.Text = CommonItems.ShowEnteredSupportsAndLoads();
                LibMPC.OutputMsgSuccess(TblkLoadUniformResult, $"Uniform load added.");
                LoadUniformDefaultValues();
            }
            else
            {
                //Debug.WriteLine($"ButLoaduniformAdd_Click() One or more input values not valid.");
                // Build error message to show User if position or force values not entered.
                string stringErrorMsg         = "Uniform load not added since one or more following values not entered or not valid:\n";
                bool   boolErrorPositionLeft  = false;
                bool   boolErrorForceLeft     = false;
                bool   boolErrorPositionRight = false;

                if (!boolEnteredLoadUniformPositionLeft)
                {
                    boolErrorPositionLeft = true;
                    stringErrorMsg       += $"{CommonItems.stringConstPositionLeft}";
                }
                if (!boolEnteredLoadUniformForceLeft)
                {
                    boolErrorForceLeft = true;
                    if (boolErrorPositionLeft)
                    {
                        stringErrorMsg += $", {CommonItems.stringConstForceLeft}";
                    }
                    else
                    {
                        stringErrorMsg += $"{CommonItems.stringConstForceLeft}";
                    }
                }
                if (!boolEnteredLoadUniformPositionRight)
                {
                    boolErrorPositionRight = true;
                    if (boolErrorPositionLeft || boolErrorForceLeft)
                    {
                        stringErrorMsg += $", {CommonItems.stringConstPositionRight}";
                    }
                    else
                    {
                        stringErrorMsg += $"{CommonItems.stringConstPositionRight}";
                    }
                }
                if (!boolEnteredLoadUniformForceRight)
                {
                    if (boolErrorPositionLeft || boolErrorForceLeft || boolErrorPositionRight)
                    {
                        stringErrorMsg += $", {CommonItems.stringConstForceRight}";
                    }
                    else
                    {
                        stringErrorMsg += $"{CommonItems.stringConstForceRight}";
                    }
                }
                LibMPC.OutputMsgError(TblkLoadUniformResult, stringErrorMsg);
            }

            CommonItems.ButtonForegroundColorSet(ButLoadUniformClear, CommonItems.boolEnteredLoadUniform);
            CommonItems.ButtonForegroundColorSet(ButLoadUniformSimulatedLoads, CommonItems.boolEnteredLoadUniform);
        }
Example #20
0
        /// <summary>
        /// Common initialization code.
        /// </summary>
        protected virtual void Initialize(Dictionary <string, string> configuration, AmqpExchangeType exchangeType, bool isInbound, IQueueLogger loggerObject = null)
        {
            try
            {
                #region Logger Initialization
                logger = loggerObject;
                #endregion

                #region Parameters Collection
                rabbitMqConfiguration = CommonItems.CollectConfiguration(ref configuration, isInbound, ref logger);
                #endregion

                #region Initializing Connection
                var connectionFactory = GetRmqConnectionFactory();
                connection = connectionFactory.CreateConnection();
                #endregion

                #region Initializing Queue
                model = connection.CreateModel();

                if (!IsQueueExistsHelper())
                {
                    throw MessageQueueCommonItems.PrepareAndLogQueueException(
                              errorCode: QueueErrorCode.QueueDoesNotExist,
                              message: ErrorMessages.QueueDoesNotExist,
                              innerException: null,
                              queueContext: CommonItems.RabbitMqName,
                              queueName: rabbitMqConfiguration.QueueName,
                              address: rabbitMqConfiguration.Address,
                              logger: logger);
                }

                if (!IsExchangeExistsHelper())
                {
                    throw MessageQueueCommonItems.PrepareAndLogQueueException(
                              errorCode: QueueErrorCode.ExchangeDoesNotExist,
                              message: ErrorMessages.ExchangeDoesNotExist,
                              innerException: null,
                              queueContext: CommonItems.RabbitMqName,
                              address: rabbitMqConfiguration.Address,
                              context: new Dictionary <string, string>
                    {
                        [CommonContextKeys.ExchangeName] = rabbitMqConfiguration.ExchangeName
                    },
                              logger: logger);
                }

                // Binding queue with exchange if configured.
                if (!string.IsNullOrWhiteSpace(rabbitMqConfiguration.ExchangeName))
                {
                    model.QueueBind(rabbitMqConfiguration.QueueName, rabbitMqConfiguration.ExchangeName, rabbitMqConfiguration.RoutingKey ?? string.Empty);
                }

                if (isInbound)
                {
                    model.BasicQos(0, rabbitMqConfiguration.MaxConcurrentReceiveCallback, false);
                }

                //  Setting model properties.
                modelProperties            = model.CreateBasicProperties();
                modelProperties.Persistent = rabbitMqConfiguration.DurableMessage;
                #endregion

                #region Registering Events
                model.BasicReturn             += OnBasicReturn;
                model.ModelShutdown           += OnModelShutdown;
                connection.ConnectionShutdown += OnConnectionShutdown;
                #endregion

                #region Updating Flag
                isInitialized = true;
                #endregion

                #region Cleaning up Sensitive Info
                rabbitMqConfiguration.Password = null;
                #endregion
            }
            catch (Exception ex) when(!(ex is QueueException))
            {
                throw MessageQueueCommonItems.PrepareAndLogQueueException(
                          errorCode: QueueErrorCode.FailedToInitializeMessageQueue,
                          message: ErrorMessages.FailedToInitializeMessageQueue,
                          innerException: ex,
                          queueContext: CommonItems.RabbitMqName,
                          queueName: rabbitMqConfiguration.QueueName,
                          address: rabbitMqConfiguration.Address,
                          logger: logger);
            }
        }
Example #21
0
        /// <summary>
        /// Add support to beam.
        /// </summary>
        private void AddSupport()
        {
            //Debug.WriteLine($"AddSupport(): doubleSupportPosition={doubleSupportPosition}, boolSupportDisplacement={boolSupportDisplacement}, boolSupportRotation={boolSupportRotation}");
            // Check displacement and rotation bools are not both true since not a support if so.
            if (!(boolSupportDisplacement == true && boolSupportRotation == true))
            {
                bool boolDuplicateSupportFound = false;
                foreach (SupportValues supportValues in CommonItems.listSupportValues)
                {
                    if (supportValues.DoubleSupportPosition.Equals(doubleSupportPosition))
                    {
                        boolDuplicateSupportFound = true;
                        break;
                    }
                }
                if (boolDuplicateSupportFound)
                {
                    if (boolDefinedSupportEntered)
                    {
                        boolDefinedSupportEnteredAll = false;
                        LibMPC.OutputMsgError(TblkSupportResult, "One or more supports not added since support already entered at position.");
                    }
                    else
                    {
                        LibMPC.OutputMsgError(TblkSupportResult, "Support not added since support already entered at position.");
                    }
                }
                else
                {
                    SupportValues supportValuesAdd = new SupportValues
                    {
                        DoubleSupportPosition   = doubleSupportPosition,
                        BoolSupportDisplacement = boolSupportDisplacement,
                        BoolSupportRotation     = boolSupportRotation
                    };
                    CommonItems.listSupportValues.Add(supportValuesAdd);     // Add support values to support list.


                    if (boolDefinedSupportEntered)
                    {
                        if (boolDefinedSupportEnteredAll)           // Do not overwrite error message if false.
                        {
                            LibMPC.OutputMsgSuccess(TblkSupportResult, "Support(s) added.");
                        }
                    }
                    else
                    {
                        LibMPC.OutputMsgSuccess(TblkSupportResult, "Support added.");
                    }
                    if (CommonItems.listSupportValues.Count > 0)
                    {
                        // More than one support entered so sort by DoubleSupportPosition.
                        CommonItems.listSupportValues.Sort((x, y) => x.DoubleSupportPosition.CompareTo(y.DoubleSupportPosition));
                    }
                    CommonItems.boolEnteredSupport = true;
                }
            }
            else
            {
                LibMPC.OutputMsgError(TblkSupportResult, "Support not added since displacement and rotation at support were both on.");
            }
            CommonItems.ButtonForegroundColorSet(ButSupportClear, CommonItems.boolEnteredSupport);
            SetDefaultValuesSupport();
        }