// This method prints the values of the device (as a integer and the interpreted string) as well as the description of each bit. private static void Update(object sender, DataEvent e) { // The description and the value of the WTX are only printed on the console if the Interface, containing all auto-properties of the values is // not null (respectively empty) and if no calibration is done at that moment. if (_wtxDevice != null /* && (_isCalibrating==false)*/) { Console.Clear(); if (_wtxDevice.ApplicationMode == 0) // If the WTX device is in standard application/mode. { Console.WriteLine("0-Taring | 1-Gross/net | 2-Zeroing | 3- Adjust zero | 4-Adjust nominal |\n5-Activate Data \t| 6-Manual taring \t | 7-Weight storage\n"); } else if (_wtxDevice.ApplicationMode == 1 || _wtxDevice.ApplicationMode == 2) // If the WTX device is in filler application/mode. { if (_showAllInputWords == false && mode == "Modbus") { Console.WriteLine("\n0-Taring | 1-Gross/net | 2-Clear dosing | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Jetbus | a-Show all input words 0 to 37 |\no-Show output words 9-44 | b-Bytes read from the register |\nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n"); } else if (_showAllInputWords == true && mode == "Modbus") { Console.WriteLine("\n0-Taring | 1-Gross/net | 2-Clear dosing | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Modbus | a-Show only input word 0 to 5 |\nb-Bytes read from the register |\nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n"); } if (mode == "Jet" || mode == "Jetbus" || mode == "jet" || mode == "jetbus") { Console.WriteLine("\n0-Taring | 1-Gross/net | 2-Clear dosing | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Modbus | \nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n"); } } if (_wtxDevice.ApplicationMode == 0) // If the device is in the standard mode (standard=0; filler=1 or filler=2) { // The values are printed on the console according to the input - "numInputs": if (_inputMode == 1) { Console.WriteLine("Net value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.NetValue); } else if (_inputMode == 2 || _inputMode == 3 || _inputMode == 4) { Console.WriteLine("Net value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.NetValue); Console.WriteLine("Gross value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.GrossValue); } else if (_inputMode == 5) { Console.WriteLine("Net value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.NetValue); Console.WriteLine("Gross value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.GrossValue); Console.WriteLine("General weight error: " + _wtxDevice.GeneralWeightError.ToString() + "\t As an Integer: " + _wtxDevice.GeneralWeightError); Console.WriteLine("Scale alarm triggered: " + _wtxDevice.LimitStatus.ToString() + "\t As an Integer: " + _wtxDevice.LimitStatus); Console.WriteLine("Scale seal is open: " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t As an Integer: " + _wtxDevice.ScaleSealIsOpen); Console.WriteLine("Manual tare: " + _wtxDevice.ManualTare.ToString() + "\t As an Integer: " + _wtxDevice.ManualTare); Console.WriteLine("Weight type: " + _wtxDevice.WeightType + "\t As an Integer: " + _wtxDevice.WeightType); //_wtxDevice.WeightTypeStringComment() Console.WriteLine("Scale range: " + _wtxDevice.ScaleRange + "\t As an Integer: " + _wtxDevice.ScaleRange); //_wtxDevice.ScaleRangeStringComment() Console.WriteLine("Zero required/True zero: " + _wtxDevice.ZeroRequired.ToString() + "\t As an Integer: " + _wtxDevice.ZeroRequired); Console.WriteLine("Weight within center of zero: " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t As an Integer: " + _wtxDevice.WeightWithinTheCenterOfZero); Console.WriteLine("Weight in zero range: " + _wtxDevice.WeightInZeroRange.ToString() + "\t As an Integer: " + _wtxDevice.WeightInZeroRange); Console.WriteLine("Limit status: " + _wtxDevice.LimitStatus.ToString() + " As an Integer: " + _wtxDevice.LimitStatus); //_wtxDevice.LimitStatusStringComment() Console.WriteLine("Weight moving: " + _wtxDevice.WeightMoving.ToString() + " As an Integer: " + _wtxDevice.WeightMoving); //_wtxDevice.WeightMovingStringComment() } else if (_inputMode == 6 || _inputMode == 38) { Console.WriteLine("Net value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.NetValue); Console.WriteLine("Gross value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.GrossValue); Console.WriteLine("General weight error: " + _wtxDevice.GeneralWeightError.ToString() + "\t As an Integer: " + _wtxDevice.GeneralWeightError); Console.WriteLine("Scale alarm triggered: " + _wtxDevice.LimitStatus.ToString() + "\t As an Integer: " + _wtxDevice.LimitStatus); Console.WriteLine("Scale seal is open: " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t As an Integer: " + _wtxDevice.ScaleSealIsOpen); Console.WriteLine("Manual tare: " + _wtxDevice.ManualTare.ToString() + "\t As an Integer: " + _wtxDevice.ManualTare); Console.WriteLine("Weight type: " + _wtxDevice.WeightType + "\t As an Integer: " + _wtxDevice.WeightType); //_wtxDevice.WeightTypeStringComment() Console.WriteLine("Scale range: " + _wtxDevice.ScaleRange + "\t As an Integer: " + _wtxDevice.ScaleRange); //_wtxDevice.ScaleRangeStringComment() Console.WriteLine("Zero required/True zero: " + _wtxDevice.ZeroRequired.ToString() + "\t As an Integer: " + _wtxDevice.ZeroRequired); Console.WriteLine("Weight within center of zero: " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t As an Integer: " + _wtxDevice.WeightWithinTheCenterOfZero); Console.WriteLine("Weight in zero range: " + _wtxDevice.WeightInZeroRange.ToString() + "\t As an Integer: " + _wtxDevice.WeightInZeroRange); Console.WriteLine("Application mode: " + _wtxDevice.ApplicationMode.ToString() + "\t As an Integer: " + _wtxDevice.ApplicationMode); //_wtxDevice.ApplicationModeStringComment() Console.WriteLine("Decimal places: " + _wtxDevice.Decimals.ToString() + "\t As an Integer: " + _wtxDevice.Decimals); Console.WriteLine("Unit: " + _wtxDevice.UnitStringComment() + "\t As an Integer: " + _wtxDevice.Unit); Console.WriteLine("Handshake: " + _wtxDevice.Handshake.ToString() + "\t As an Integer: " + _wtxDevice.Handshake); Console.WriteLine("Status: " + statusCommentMethod() + "\t As an Integer: " + _wtxDevice.Status); //_wtxDevice.StatusStringComment() Console.WriteLine("Limit status: " + limitCommentMethod() + " As an Integer: " + _wtxDevice.LimitStatus); //_wtxDevice.LimitStatusStringComment() Console.WriteLine("Weight moving: " + _wtxDevice.WeightMoving.ToString() + " As an Integer: " + _wtxDevice.WeightMoving); //_wtxDevice.WeightMovingStringComment() } else { Console.WriteLine("\nWrong input for the number of bytes, which should be read from the register!\nPlease enter 'b' to choose again."); } } else if (_wtxDevice.ApplicationMode == 2 || _wtxDevice.ApplicationMode == 1) { Console.WriteLine("Net value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.NetValue); Console.WriteLine("Gross value: " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t As an Integer: " + _wtxDevice.GrossValue); Console.WriteLine("General weight error: " + _wtxDevice.GeneralWeightError.ToString() + "\t As an Integer: " + _wtxDevice.GeneralWeightError); Console.WriteLine("Scale alarm triggered: " + _wtxDevice.LimitStatus.ToString() + "\t As an Integer: " + _wtxDevice.LimitStatus); Console.WriteLine("Scale seal is open: " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t As an Integer: " + _wtxDevice.ScaleSealIsOpen); Console.WriteLine("Manual tare: " + _wtxDevice.ManualTare.ToString() + "\t As an Integer: " + _wtxDevice.ManualTare); Console.WriteLine("Weight type: " + _wtxDevice.WeightType + "\t As an Integer: " + _wtxDevice.WeightType); //_wtxDevice.WeightTypeStringComment() Console.WriteLine("Scale range: " + _wtxDevice.ScaleRange + "\t As an Integer: " + _wtxDevice.ScaleRange); //_wtxDevice.ScaleRangeStringComment() Console.WriteLine("Zero required/True zero: " + _wtxDevice.ZeroRequired.ToString() + "\t As an Integer: " + _wtxDevice.ZeroRequired); Console.WriteLine("Weight within center of zero: " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t As an Integer: " + _wtxDevice.WeightWithinTheCenterOfZero); Console.WriteLine("Weight in zero range: " + _wtxDevice.WeightInZeroRange.ToString() + "\t As an Integer: " + _wtxDevice.WeightInZeroRange); Console.WriteLine("Application mode: " + _wtxDevice.ApplicationMode.ToString() + "\t As an Integer: " + _wtxDevice.ApplicationMode); //_wtxDevice.ApplicationModeStringComment() Console.WriteLine("Decimal places: " + _wtxDevice.Decimals.ToString() + "\t As an Integer: " + _wtxDevice.Decimals); Console.WriteLine("Unit: " + _wtxDevice.UnitStringComment() + "\t As an Integer: " + _wtxDevice.Unit); Console.WriteLine("Handshake: " + _wtxDevice.Handshake.ToString() + "\t As an Integer: " + _wtxDevice.Handshake); Console.WriteLine("Status: " + statusCommentMethod() + "\t As an Integer: " + _wtxDevice.Status); //_wtxDevice.StatusStringComment() Console.WriteLine("Limit status: " + limitCommentMethod() + " As an Integer: " + _wtxDevice.LimitStatus); //_wtxDevice.LimitStatusStringComment() Console.WriteLine("Weight moving: " + _wtxDevice.WeightMoving.ToString() + " As an Integer: " + _wtxDevice.WeightMoving); //_wtxDevice.WeightMovingStringComment() if (_showAllInputWords == true) { Console.WriteLine("Digital input 1: " + _wtxDevice.Input1.ToString() + "\t As an Integer: " + _wtxDevice.Input1); Console.WriteLine("Digital input 2: " + _wtxDevice.Input2.ToString() + "\t As an Integer: " + _wtxDevice.Input2); Console.WriteLine("Digital input 3: " + _wtxDevice.Input3.ToString() + "\t As an Integer: " + _wtxDevice.Input3); Console.WriteLine("Digital input 4: " + _wtxDevice.Input4.ToString() + "\t As an Integer: " + _wtxDevice.Input4); Console.WriteLine("Digital output 1: " + _wtxDevice.Output1.ToString() + "\t As an Integer: " + _wtxDevice.Output1); Console.WriteLine("Digital output 2: " + _wtxDevice.Output2.ToString() + "\t As an Integer: " + _wtxDevice.Output2); Console.WriteLine("Digital output 3: " + _wtxDevice.Output3.ToString() + "\t As an Integer: " + _wtxDevice.Output3); Console.WriteLine("Digital output 4: " + _wtxDevice.Output4.ToString() + "\t As an Integer: " + _wtxDevice.Output4); Console.WriteLine("Coarse flow: " + _wtxDevice.CoarseFlow.ToString() + "\t As an Integer: " + _wtxDevice.CoarseFlow); Console.WriteLine("Fine flow: " + _wtxDevice.FineFlow.ToString() + "\t As an Integer: " + _wtxDevice.FineFlow); Console.WriteLine("Ready: " + _wtxDevice.Ready.ToString() + "\t As an Integer: " + _wtxDevice.Ready); Console.WriteLine("Re-dosing: " + _wtxDevice.ReDosing.ToString() + "\t As an Integer: " + _wtxDevice.ReDosing); Console.WriteLine("Emptying: " + _wtxDevice.Emptying.ToString() + "\t As an Integer: " + _wtxDevice.Emptying); Console.WriteLine("Flow error: " + _wtxDevice.FlowError.ToString() + "\t As an Integer: " + _wtxDevice.FlowError); Console.WriteLine("Alarm: " + _wtxDevice.Alarm.ToString() + "\t As an Integer: " + _wtxDevice.Alarm); Console.WriteLine("ADC Overload/Unterload: " + _wtxDevice.AdcOverUnderload.ToString() + "\t As an Integer: " + _wtxDevice.AdcOverUnderload); Console.WriteLine("Max.Dosing time: " + _wtxDevice.MaxDosingTime.ToString() + "\t As an Integer: " + _wtxDevice.MaxDosingTime); Console.WriteLine("Legal-for-trade operation: " + _wtxDevice.LegalTradeOp.ToString() + "\t As an Integer: " + _wtxDevice.LegalTradeOp); Console.WriteLine("Tolerance error+: " + _wtxDevice.ToleranceErrorPlus.ToString() + "\t As an Integer: " + _wtxDevice.ToleranceErrorPlus); Console.WriteLine("Tolerance error-: " + _wtxDevice.ToleranceErrorMinus.ToString() + "\t As an Integer: " + _wtxDevice.ToleranceErrorMinus); Console.WriteLine("Status digital input 1: " + _wtxDevice.StatusInput1.ToString() + "\t As an Integer: " + _wtxDevice.StatusInput1); Console.WriteLine("General scale error: " + _wtxDevice.GeneralScaleError.ToString() + "\t As an Integer: " + _wtxDevice.GeneralScaleError); Console.WriteLine("Filling process status: " + _wtxDevice.FillingProcessStatus.ToString() + "\t As an Integer: " + _wtxDevice.FillingProcessStatus); Console.WriteLine("Number of dosing results: " + _wtxDevice.NumberDosingResults.ToString() + "\t As an Integer: " + _wtxDevice.NumberDosingResults); Console.WriteLine("Dosing result: " + _wtxDevice.DosingResult.ToString() + "\t As an Integer: " + _wtxDevice.DosingResult); Console.WriteLine("Mean value of dosing results: " + _wtxDevice.MeanValueDosingResults.ToString() + "\t As an Integer: " + _wtxDevice.MeanValueDosingResults); Console.WriteLine("Standard deviation: " + _wtxDevice.StandardDeviation.ToString() + "\t As an Integer: " + _wtxDevice.StandardDeviation); Console.WriteLine("Total weight: " + _wtxDevice.TotalWeight.ToString() + "\t As an Integer: " + _wtxDevice.TotalWeight); Console.WriteLine("Fine flow cut-off point: " + _wtxDevice.FineFlowCutOffPoint.ToString() + "\t As an Integer: " + _wtxDevice.FineFlowCutOffPoint); Console.WriteLine("Coarse flow cut-off point: " + _wtxDevice.CoarseFlowCutOffPoint.ToString() + "\t As an Integer: " + _wtxDevice.CoarseFlowCutOffPoint); Console.WriteLine("Current dosing time: " + _wtxDevice.CurrentDosingTime.ToString() + "\t As an Integer: " + _wtxDevice.CurrentDosingTime); Console.WriteLine("Current coarse flow time: " + _wtxDevice.CurrentCoarseFlowTime.ToString() + "\t As an Integer: " + _wtxDevice.CurrentCoarseFlowTime); Console.WriteLine("Current fine flow time: " + _wtxDevice.CurrentFineFlowTime.ToString() + "\t As an Integer: " + _wtxDevice.CurrentFineFlowTime); Console.WriteLine("Parameter set (product): " + _wtxDevice.ParameterSetProduct.ToString() + "\t As an Integer: " + _wtxDevice.ParameterSetProduct); Console.WriteLine("Weight memory, Day: " + _wtxDevice.WeightMemDay.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemDay); Console.WriteLine("Weight memory, Month: " + _wtxDevice.WeightMemMonth.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemMonth); Console.WriteLine("Weight memory, Year: " + _wtxDevice.WeightMemYear.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemYear); Console.WriteLine("Weight memory, Seq.Number: " + _wtxDevice.WeightMemSeqNumber.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemSeqNumber); Console.WriteLine("Weight memory, gross: " + _wtxDevice.WeightMemGross.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemGross); Console.WriteLine("Weight memory, net: " + _wtxDevice.WeightMemNet.ToString() + "\t As an Integer: " + _wtxDevice.WeightMemNet); Console.WriteLine("\nPress 'a' again to hide the input words."); } if (_showAllOutputWords == true) { Console.WriteLine("\nOutput words:\n"); Console.WriteLine(" 9) Residual flow time: " + _wtxDevice.ResidualFlowTime + " Press '9' and a value to write"); Console.WriteLine("10) Target filling weight: " + _wtxDevice.TargetFillingWeight + " Press '10' and a value to write"); Console.WriteLine("12) Coarse flow cut-off point: " + _wtxDevice.CoarseFlowCutOffPoint + " Press '12' and a value to write"); Console.WriteLine("14) Fine flow cut-off point: " + _wtxDevice.FineFlowCutOffPoint + " Press '14' and a value to write"); Console.WriteLine("16) Minimum fine flow: " + _wtxDevice.MinimumFineFlow + " Press '16' and a value to write"); Console.WriteLine("18) Optimization of cut-off points:" + _wtxDevice.OptimizationOfCutOffPoints + " Press '18' and a value to write"); Console.WriteLine("19) Maximum dosing time: " + _wtxDevice.MaxDosingTime + " Press '19' and a value to write"); Console.WriteLine("20) Start with fine flow: " + _wtxDevice.StartWithFineFlow + " Press '20' and a value to write"); Console.WriteLine("21) Coarse lockout time: " + _wtxDevice.CoarseLockoutTime + " Press '21' and a value to write"); Console.WriteLine("22) Fine lockout time: " + _wtxDevice.FineLockoutTime + " Press '22' and a value to write"); Console.WriteLine("23) Tare mode: " + _wtxDevice.TareMode + " Press '23' and a value to write"); Console.WriteLine("24) Upper tolerance limit + : " + _wtxDevice.UpperToleranceLimit + " Press '24' and a value to write"); Console.WriteLine("26) Lower tolerance limit -: " + _wtxDevice.LowerToleranceLimit + " Press '26' and a value to write"); Console.WriteLine("28) Minimum start weight: " + _wtxDevice.MinimumStartWeight + " Press '28' and a value to write"); Console.WriteLine("30) Empty weight: " + _wtxDevice.EmptyWeight + " Press '30' and a value to write"); Console.WriteLine("32) Tare delay: " + _wtxDevice.TareDelay + " Press '32' and a value to write"); Console.WriteLine("33) Coarse flow monitoring time: " + _wtxDevice.CoarseFlowMonitoringTime + " Press '33' and a value to write"); Console.WriteLine("34) Coarse flow monitoring: " + _wtxDevice.CoarseFlowMonitoring + " Press '34' and a value to write"); Console.WriteLine("36) Fine flow monitoring: " + _wtxDevice.FineFlowMonitoring + " Press '36' and a value to write"); Console.WriteLine("38) Fine flow monitoring time: " + _wtxDevice.FineFlowMonitoringTime + " Press '38' and a value to write"); Console.WriteLine("40) Delay time after fine flow: " + _wtxDevice.DelayTimeAfterFineFlow + " Press '40' and a value to write"); Console.WriteLine("41) Systematic difference: " + _wtxDevice.SystematicDifference + " Press '41' and a value to write"); Console.WriteLine("42) Downwards dosing: " + _wtxDevice.DownwardsDosing + " Press '42' and a value to write"); Console.WriteLine("43) Valve control: " + _wtxDevice.ValveControl + " Press '43' and a value to write"); Console.WriteLine("44) Emptying mode: " + _wtxDevice.EmptyingMode + " Press '44' and a value to write"); Console.WriteLine("\nPress 'o' again to hide the output words."); } } } }
//Callback for automatically receiving event based data from the device private void Update(object sender, DataEvent e) { txtInfo.Invoke(new Action(() => { int taraValue = _wtxDevice.NetValue - _wtxDevice.GrossValue; txtInfo.Text = "Net:" + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + _wtxDevice.UnitStringComment() + Environment.NewLine + "Gross:" + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + _wtxDevice.UnitStringComment() + Environment.NewLine + "Tara:" + _wtxDevice.NetGrossValueStringComment(taraValue, _wtxDevice.Decimals) + _wtxDevice.UnitStringComment(); txtInfo.TextAlign = HorizontalAlignment.Right; })); txtInfo.Invoke(new Action(() => { if (_wtxDevice.LimitStatus == 1) { txtInfo.Text = "Lower than minimum" + Environment.NewLine; txtInfo.TextAlign = HorizontalAlignment.Right; } if (_wtxDevice.LimitStatus == 2) { txtInfo.Text = "Higher than maximum capacity" + Environment.NewLine; txtInfo.TextAlign = HorizontalAlignment.Right; } if (_wtxDevice.LimitStatus == 3) { txtInfo.Text = "Higher than safe load limit" + Environment.NewLine; txtInfo.TextAlign = HorizontalAlignment.Right; } })); }