From 6ea7407ed05f6f23797e8c4908db74d4ca60e51e Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Tue, 17 Feb 2026 14:41:43 +0100 Subject: [PATCH] FM2014: refactoring, MiniPrf: - checks extended --- .../FM2014/FM2014Core/Consts/FM2014CmdDef.cs | 411 +++++++++-------- .../FM2014/FM2014Core/FM2014.cs | 231 +++++----- Common/LaaPackages | 2 +- MiniPrf/Ui/FrmMainMiniPrf.Designer.cs | 422 ++++++++++-------- MiniPrf/Ui/FrmMainMiniPrf.cs | 171 ++++--- MiniPrf/Ui/Properties/Resources.Designer.cs | 2 +- MiniPrf/Ui/Properties/Resources.de.resx | 2 +- MiniPrf/Ui/Properties/Resources.resx | 2 +- 8 files changed, 669 insertions(+), 574 deletions(-) diff --git a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs index 8a30207a..1eeab003 100644 --- a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs +++ b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs @@ -27,269 +27,297 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co public enum CmdName { /// - /// + /// Connect the FM2014 by asking for the connection string. /// - CMD_CONNECT, + CmdConnect, /// - /// + /// Unlock the erase capability for the serial number and or the application code. + /// This should protect against unwanted access to the protected memory cells. /// - CMD_UNLOCK_SETUP, + CmdUnlockErase, /// - /// + /// Erase the serial number. /// - CMD_ERASE_SETUP, + CmdEraseSerialNumber, /// - /// + /// Read the default measurement table stored in the EEPROM of FM2014 for a standalone regulation + /// measurement. /// - CMD_READ_EEP_MEAS_SETUP, + CmdReadEepMeasSetup, /// - /// + /// Read the default measurement table actually set up in the RAM of FM2014 for a standalone + /// regulation measurement. This value is temporary and needs to be stored to the EEPROM to survive + /// a reboot. /// - CMD_READ_RAM_MEAS_SETUP, + CmdReadRamMeasSetup, /// - /// + /// Store the default measurement table actually set up in the RAM of FM2014 to the EEPROM to keep + /// this standalone regulation measurement setup upon a reboot. /// - CMD_SAVE_RAM_TO_EEP_MEAS_SETUP, + CmdSaveRamToEepMeasSetup, /// - /// + /// Switch from application to boot mode. /// - CMD_BOOT_MODE, + CmdSwitchToBootMode, /// - /// + /// Read out the extended application code information. /// - CMD_PRINT_APP_INFO, + CmdPrintAppInfo, /// - /// + /// Read out the extended boot code information. /// - CMD_PRINT_BOOT_INFO, + CmdPrintBootInfo, /// - /// + /// Read or set the baudrate for the shared serial interface between PC and FM2014s. /// - CMD_BAUDRATE_PC, + CmdBaudratePc, /// - /// + /// Use a virtual address the program the standalone regulation measurement for downwards compatibility + /// to the legacy FM85. /// - CMD_GET_VIRTUAL_ADDRESS, + CmdSetVirtualAddress, /// - /// + /// Use a virtual address the readout the standalone regulation measurement for downwards compatibility + /// to the legacy FM85. /// - CMD_SERIAL, + CmdGetVirtualAddress, /// - /// + /// Read or set the serial number of the FM2014. Writing is only allowed once. If the serial number is + /// accidentally setup wrong the 'CmdUnlockErase' followed by 'CmdEraseSerialNumber' can be used to erase it + /// being able to write the correct serial number again. /// - CMD_GET_STATUS, + CmdSerialNumber, /// - /// + /// Read the FM2014 device status as bitmask containing 'measure', 'error', 'fault1' and 'fault2' info. /// - CMD_SET_VIRTUAL_ADDRESS, + CmdGetStatus, /// - /// + /// Read the lifetime of the FM2014 in hours. /// - CMD_PRINT_STATISTICS, + CmdGetLifetime, /// - /// + /// Reset the measurement of the FM2014 to clean all settings and recalibrate the current output. + /// This has to be done before a new measurement can be initiated. Otherwise, a new setup will be + /// ignored. /// - CMD_RST_MEAS, + CmdResetMeasurement, /// - /// + /// Set the base value of the deadtime for double pulse detection ignorance time in milliseconds /// - CMD_SET_DPLS_LOCK_TMR, + CmdSetDoublePulseDeadtimeBase, /// - /// + /// Set the multiplier value to extend the deadtime for double pulse detection ignorance time set up + /// with the 'CmdSetDoublePulseDeadtimeBase' /// - CMD_SET_DPLS_LOCK_MULT, + CmdSetDoublePulseDeadtimeMultiplier, /// - /// + /// Switch the deadtime for double pulse ignorance off. /// - CMD_SET_DBPL_UNLOCK, + CmdSwitchDoublePulseDeadtimeOff, /// - /// + /// Set the pulses for a time measurement for the REF, if the DUT is going to be started, the first + /// rising edge of the DUT pulse will synchronize the REF and start the REF counter from the beginning /// - CMD_DUT_SET_PLS, + CmdRefSetPulsesRequired, /// - /// + /// Set the pulses for a time measurement for the DUT, if the DUT is going to be started, the first + /// rising edge of the DUT pulse will synchronize the REF and start the REF counter from the beginning /// - CMD_REF_SET_PLS, + CmdSetDutPulsesRequired, /// - /// + /// Read the remaining pulses set up with the 'CmdSetRefPulsesRequired' time measurement command /// - CMD_DUT_GET_PLS_RMN, + CmdRefPulsesRemaining, /// - /// + /// Read the remaining pulses set up with the 'CmdSetDutPulsesRequired' time measurement command /// - CMD_REF_GET_PLS_RMN, + CmdDutGetPulsesRemaining, /// - /// + /// Start the REF pulses counter /// - CMD_REF_STR_PLS_CTR, + CmdStartRefPulseCounter, /// - /// + /// Start the DUT pulse counter /// - CMD_DUT_STR_PLS_CTR, + CmdStartDutPulseCounter, /// - /// + /// Start the REF and DUT pulse counter together to get a synchronized value /// - CMD_REF_GET_PLS_CTR, + CmdStartRefAndDutPulseCounter, /// - /// + /// Read the actual counted REF pulses in time or pulse counter measurement /// - CMD_DUT_GET_PLS_CTR, + CmdGetRefPulsesCounted, /// - /// + /// Read the actual counted DUT pulses in time or pulse counter measurement /// - CMD_REF_GET_PLS_CTR_BU, + CmdGetDutPulsesCounted, /// - /// + /// Take a synchronized snapshot of pulses for REF and DUT and store it as backup pulses /// - CMD_DUT_GET_PLS_CTR_BU, + CmdBackupRefAndDutPulses, /// - /// + /// Read out the REF pulses synchronized between REF and DUT with 'CmdBackupRefAndDutPulses' /// - CMD_REF_DUT_STR_PLS_CTR, + CmdGetRefPulsesCountedBackup, /// - /// + /// Read out the DUT pulses synchronized between REF and DUT with 'CmdBackupRefAndDutPulses' /// - CMD_REF_DUT_BU_PLS_CTR, + CmdGetDutPulsesCountedBackup, /// - /// + /// Set up the REF to DUT scale for pulses per cubic-meters. This is needed for the regulation + /// measurement setup. /// - CMD_REF_SET_SCALE, + CmdRefToDutScale, /// - /// + /// Set up the DUT pulses per cubic-meter scale. This is needed for the regulation + /// measurement setup. /// - CMD_DUT_LPP_SCALE, + CmdSetRefPulsesPerCm, /// - /// + /// Set up the DUT pulses per cubic-meter scale. This is needed for the regulation + /// measurement setup. /// - CMD_REF_LPP_SCALE, + CmdSetDutPulsesPerCm, /// - /// + /// Set the current output attenuation which will stabilize the current output on bigger + /// numbers. /// - CMD_MEAS_SET_ATTN, + CmdSetCurrentOutputAttenuation, /// - /// + /// Read out the counted timer ticks during the time measurement of the REF. This is the + /// time from the first rising edge of the first pulse to the last after the counted pulses. + /// This value has to be multiplied with the timer resolution to get a real time. /// - CMD_DUT_GET_TMR, + CmdGetRefTimerTicks, /// - /// + /// Read out the counted timer ticks during the time measurement of the DUT. This is the + /// time from the first rising edge of the first pulse to the last after the counted pulses. + /// This value has to be multiplied with the timer resolution to get a real time. /// - CMD_REF_GET_TMR, + CmdGetDutTimerTicks, /// - /// + /// Get the undamped tolerance between DUT and REF during the regulation measurement. + /// This is a raw value which needs to be scaled to the resolution of the connected current + /// output scale. /// - CMD_GET_UDTLC, + CmdGetDutToRefToleranceUndamped, /// - /// + /// Get the damped tolerance between DUT and REF during the regulation measurement. + /// This is a raw value which needs to be scaled to the resolution of the connected current + /// output scale. /// - CMD_GET_DTLC, + CmdGetDutToRefToleranceDamped, /// - /// + /// Read out the REF period averaged over the ongoing measurement in timer ticks. + /// This value has to be multiplied with the timer resolution to get a real time. /// - CMD_GET_REF_PERIOD, + CmdGetRefPeriod, /// - /// + /// Read out the DUT period averaged over the ongoing measurement in timer ticks. + /// This value has to be multiplied with the timer resolution to get a real time. /// - CMD_GET_DUT_PERIOD, + CmdGetDutPeriod, /// - /// + /// Read the REF frequency in Hertz. /// - CMD_GET_REF_FREQU, + CmdGetRefFrequency, /// - /// Calculate DUT to REF tolerance based on timer values + /// Calculate DUT to REF tolerance based on timer values in the time measurement operation (calibration). /// - CMD_CAL_DUT_TO_REF_TOL, + CmdCalculatedDutToRefTolerance, /// - /// Calculate frequency from REF period + /// Calculate frequency from REF period. /// - CMD_CAL_FREQU_REF_PERIOD, + CmdCalculatedFrequRefPeriod, /// - /// Calculate frequency from DUT period + /// Calculate frequency from DUT period. /// - CMD_CAL_FREQU_DUT_PERIOD, + CmdCalculatedFrequencyDutPeriod, /// - /// Calculated flow rate from REF frequency + /// Calculated flow rate from REF frequency. /// - CMD_CAL_FLOW_REF_FREQU, + CmdCalculatedFlowRefFrequ, /// - /// Calculated flow rate from REF period + /// Calculated flow rate from REF period. /// - CMD_CAL_FLOW_REF_PERIOD, + CmdCalculatedFlowRefPeriod, /// - /// Calculated flow rate from DUT period + /// Calculated flow rate from DUT period. /// - CMD_CAL_FLOW_DUT_PERIOD, + CmdCalculatedFlowDutPeriod, /// - /// Command to force a current offset correction (takes about 4 s) + /// Command to force a current offset correction (takes about 4 s). /// - CMD_COR_CURRENT, + CmdStartCurrentOffsetCorrection, /// - /// Set current to max value (20 mA) + /// Set current to max value (20 mA). /// - CMD_SET_XTR_MAX, + CmdCurrentOutputMax, /// - /// Set current to min value (-20 mA) + /// Set current to min value (-20 mA). /// - CMD_SET_XTR_MIN, + CmdCurrentOutputMin, /// - /// + /// Read or set up the address of the FM2014. /// - CMD_ADDR_PC, + CmdAddress, /// - /// + /// Command code not assigned. /// - CMD_NA + CmdNotAssigned } /// @@ -300,22 +328,22 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// /// All measurements idle /// - IDLE, + idle, /// /// Pulse counter measurements /// - PULSE_CTR, + pulseCounterMeasurement, /// /// Regulation measurement ongoing /// - REGULATION, + regulationMeasurement, /// /// Calibration measurement ongoing /// - CALIBRATION + timeMeasurement } /// @@ -326,27 +354,27 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// /// Unknown status /// - UNKNOWN, + unknown, /// /// Offline: - not connected /// - OFFLINE, + offline, /// /// Standby: - connected but logged out /// - STANDBY, + standby, /// /// Online: - connected and logged in /// - ONLINE, + online, /// /// /// - ERROR + error } /// @@ -381,11 +409,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// public static readonly DeviceConnectionStatus[] DeviceConnectionStati = { - new DeviceConnectionStatus(ConnectionStatusName.UNKNOWN, "?"), - new DeviceConnectionStatus(ConnectionStatusName.OFFLINE, "OFFLINE"), - new DeviceConnectionStatus(ConnectionStatusName.STANDBY, "STANDBY"), - new DeviceConnectionStatus(ConnectionStatusName.ONLINE, "ONLINE"), - new DeviceConnectionStatus(ConnectionStatusName.ERROR, Resources.StrError) + new DeviceConnectionStatus(ConnectionStatusName.unknown, "?"), + new DeviceConnectionStatus(ConnectionStatusName.offline, "OFFLINE"), + new DeviceConnectionStatus(ConnectionStatusName.standby, "STANDBY"), + new DeviceConnectionStatus(ConnectionStatusName.online, "ONLINE"), + new DeviceConnectionStatus(ConnectionStatusName.error, Resources.StrError) }; /// @@ -396,23 +424,22 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// /// Individual addressed command with answer /// - INDIVIDUAL, + individual, /// /// Individual addressed command without answer /// - INDIVIDUAL_UNRESPONSIVE, + individualUnresponsive, /// /// Broadcast command without answer to address 0 or individual without answer /// - BROADCAST, + broadcast, /// /// Uninitialized addressing command type /// - NOT_INITIALIZED, - + uninitialized } /// @@ -423,37 +450,37 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// /// String taken directly to send or as received /// - STRING, + stringValue, /// /// Double format /// - DOUBLE, + doubleValue, /// /// Hexadecimal integer /// - UINT_HEX, + uintHexValue, /// /// Hexadecimal byte plus additional sign /// - BYTE_HEX_PLUS_SIGN, + byteHexValuePlusSign, /// /// Decimal integer /// - UINT_DEZ, + uintDecimalValue, /// /// Individual formatting required /// - INDIVIDUAL, + individual, /// /// Parameterless means the command will be sent without any parameter /// - PARAMETERLESS + parameterless } /// @@ -521,26 +548,26 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co public const String ADDR_VALIDATION_STR = "@"; /// - /// Partial search string for - /// and for 'Attenuation'. + /// Partial search string for + /// and for 'Attenuation'. /// public const String StandAlonePartSearchAttenuationStr = "Attenuation"; /// - /// Partial search string for - /// and for 'Scale REF to DUT'. + /// Partial search string for + /// and for 'Scale REF to DUT'. /// public const String StandAlonePartSearchScaleStr = "Scale"; /// - /// Partial search string for - /// and for 'Pulses per volume REF'. + /// Partial search string for + /// and for 'Pulses per volume REF'. /// public const String StandAlonePartSearchRefPpvStr = "Pulses per volume REF"; /// - /// Partial search string for - /// and for 'Pulses per volume DUT'. + /// Partial search string for + /// and for 'Pulses per volume DUT'. /// public const String StandAlonePartSearchDutPpvStr = "Pulses per volume DUT"; @@ -561,65 +588,65 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co public static readonly List CmdTbl = new List { // FM2014 control and information - new Cmd(CmdName.CMD_CONNECT, "", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgConnect), - new Cmd(CmdName.CMD_UNLOCK_SETUP, "&U@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgUnlock), - new Cmd(CmdName.CMD_ERASE_SETUP, "&E@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgErase), - new Cmd(CmdName.CMD_READ_EEP_MEAS_SETUP, "%D@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgReadDefMeasSetup), - new Cmd(CmdName.CMD_READ_RAM_MEAS_SETUP, "%A@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgActualDefMeasSetup), - new Cmd(CmdName.CMD_SAVE_RAM_TO_EEP_MEAS_SETUP, "%S@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgStoreDefMeasSetup), - new Cmd(CmdName.CMD_BOOT_MODE, "$B@", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgBootMode), - new Cmd(CmdName.CMD_PRINT_APP_INFO, "?A", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgPrintAppInfo), - new Cmd(CmdName.CMD_PRINT_BOOT_INFO, "?B", CmdType.INDIVIDUAL, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgPrintBootInfo), - new Cmd(CmdName.CMD_BAUDRATE_PC, "=BP", CmdType.INDIVIDUAL, ParaFormat.UINT_DEZ, Resources.StrCmdMsgBaudrateAll), - new Cmd(CmdName.CMD_GET_VIRTUAL_ADDRESS, " ", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgGetVirtualAddress), - new Cmd(CmdName.CMD_SERIAL, "#", CmdType.INDIVIDUAL, ParaFormat.UINT_DEZ, Resources.StrCmdMsgSerial), - new Cmd(CmdName.CMD_GET_STATUS, UNICODE_ACK, CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgGetStatus), - new Cmd(CmdName.CMD_SET_VIRTUAL_ADDRESS, "N", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgSetVirtualAddress), - new Cmd(CmdName.CMD_PRINT_STATISTICS, "!", CmdType.INDIVIDUAL, ParaFormat.STRING, Resources.StrCmdMsgPrintStatistics), + new Cmd(CmdName.CmdConnect, "", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgConnect), + new Cmd(CmdName.CmdUnlockErase, "&U@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgUnlock), + new Cmd(CmdName.CmdEraseSerialNumber, "&E@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgErase), + new Cmd(CmdName.CmdReadEepMeasSetup, "%D@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgReadDefMeasSetup), + new Cmd(CmdName.CmdReadRamMeasSetup, "%A@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgActualDefMeasSetup), + new Cmd(CmdName.CmdSaveRamToEepMeasSetup, "%S@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgStoreDefMeasSetup), + new Cmd(CmdName.CmdSwitchToBootMode, "$B@", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgBootMode), + new Cmd(CmdName.CmdPrintAppInfo, "?A", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgPrintAppInfo), + new Cmd(CmdName.CmdPrintBootInfo, "?B", CmdType.individual, ParaFormat.parameterless, Resources.StrCmdMsgPrintBootInfo), + new Cmd(CmdName.CmdBaudratePc, "=BP", CmdType.individual, ParaFormat.uintDecimalValue, Resources.StrCmdMsgBaudrateAll), + new Cmd(CmdName.CmdGetVirtualAddress, " ", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgGetVirtualAddress), + new Cmd(CmdName.CmdSerialNumber, "#", CmdType.individual, ParaFormat.uintDecimalValue, Resources.StrCmdMsgSerial), + new Cmd(CmdName.CmdGetStatus, UNICODE_ACK, CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgGetStatus), + new Cmd(CmdName.CmdSetVirtualAddress, "N", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgSetVirtualAddress), + new Cmd(CmdName.CmdGetLifetime, "!", CmdType.individual, ParaFormat.stringValue, Resources.StrCmdMsgPrintStatistics), //measurement reset - new Cmd(CmdName.CMD_RST_MEAS, "R", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgRstMeas), + new Cmd(CmdName.CmdResetMeasurement, "R", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgRstMeas), // Double impulse detection settings - new Cmd(CmdName.CMD_SET_DPLS_LOCK_TMR, "S", CmdType.BROADCAST, ParaFormat.UINT_DEZ, Resources.StrCmdMsgDplsLockTmr), - new Cmd(CmdName.CMD_SET_DPLS_LOCK_MULT, "s", CmdType.BROADCAST, ParaFormat.UINT_DEZ, Resources.StrCmdMsgDplsLockMult), - new Cmd(CmdName.CMD_SET_DBPL_UNLOCK, "G", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgSetDbplUnlock), + new Cmd(CmdName.CmdSetDoublePulseDeadtimeBase, "S", CmdType.broadcast, ParaFormat.uintDecimalValue, Resources.StrCmdMsgDplsLockTmr), + new Cmd(CmdName.CmdSetDoublePulseDeadtimeMultiplier, "s", CmdType.broadcast, ParaFormat.uintDecimalValue, Resources.StrCmdMsgDplsLockMult), + new Cmd(CmdName.CmdSwitchDoublePulseDeadtimeOff, "G", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgSetDbplUnlock), // Main measurement pulse settings and readout - new Cmd(CmdName.CMD_DUT_SET_PLS, "H", CmdType.BROADCAST, ParaFormat.UINT_HEX, Resources.StrCmdMsgDutSetPls), - new Cmd(CmdName.CMD_REF_SET_PLS, "M", CmdType.BROADCAST, ParaFormat.UINT_HEX, Resources.StrCmdMsgRefSetPls), - new Cmd(CmdName.CMD_DUT_GET_PLS_RMN, "I", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgDutGetPlsRmn), - new Cmd(CmdName.CMD_REF_GET_PLS_RMN, "J", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgRefGetPlsRmn), + new Cmd(CmdName.CmdSetDutPulsesRequired, "H", CmdType.broadcast, ParaFormat.uintHexValue, Resources.StrCmdMsgDutSetPls), + new Cmd(CmdName.CmdRefSetPulsesRequired, "M", CmdType.broadcast, ParaFormat.uintHexValue, Resources.StrCmdMsgRefSetPls), + new Cmd(CmdName.CmdDutGetPulsesRemaining, "I", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgDutGetPlsRmn), + new Cmd(CmdName.CmdRefPulsesRemaining, "J", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgRefGetPlsRmn), // Pulse counters start, readout and backup - new Cmd(CmdName.CMD_REF_STR_PLS_CTR, "O", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgRefStrPlsCtr), - new Cmd(CmdName.CMD_DUT_STR_PLS_CTR, "Q", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgDutStrPlsCtr), - new Cmd(CmdName.CMD_REF_GET_PLS_CTR, "L", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgRefGetPlsCtr), - new Cmd(CmdName.CMD_DUT_GET_PLS_CTR, "U", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgDutGetPlsCtr), - new Cmd(CmdName.CMD_REF_GET_PLS_CTR_BU, "l", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgRefGetPlsCtrBu), - new Cmd(CmdName.CMD_DUT_GET_PLS_CTR_BU, "u", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgDutGetPlsCtrBu), - new Cmd(CmdName.CMD_REF_DUT_STR_PLS_CTR, "o", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgRefDutStrPlsCtr), - new Cmd(CmdName.CMD_REF_DUT_BU_PLS_CTR, "q", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgRefDutBuPlsCtr), + new Cmd(CmdName.CmdStartRefPulseCounter, "O", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgRefStrPlsCtr), + new Cmd(CmdName.CmdStartDutPulseCounter, "Q", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgDutStrPlsCtr), + new Cmd(CmdName.CmdGetRefPulsesCounted, "L", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgRefGetPlsCtr), + new Cmd(CmdName.CmdGetDutPulsesCounted, "U", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgDutGetPlsCtr), + new Cmd(CmdName.CmdGetRefPulsesCountedBackup, "l", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgRefGetPlsCtrBu), + new Cmd(CmdName.CmdGetDutPulsesCountedBackup, "u", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgDutGetPlsCtrBu), + new Cmd(CmdName.CmdStartRefAndDutPulseCounter, "o", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgRefDutStrPlsCtr), + new Cmd(CmdName.CmdBackupRefAndDutPulses, "q", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgRefDutBuPlsCtr), // General measurement setup - new Cmd(CmdName.CMD_REF_SET_SCALE, "K", CmdType.BROADCAST, ParaFormat.INDIVIDUAL, Resources.StrCmdMsgRefSetScale), - new Cmd(CmdName.CMD_DUT_LPP_SCALE, "V", CmdType.INDIVIDUAL_UNRESPONSIVE, ParaFormat.UINT_DEZ, Resources.StrCmdMsgDutLppScale), - new Cmd(CmdName.CMD_REF_LPP_SCALE, "W", CmdType.INDIVIDUAL_UNRESPONSIVE, ParaFormat.UINT_DEZ, Resources.StrCmdMsgRefLppScale), - new Cmd(CmdName.CMD_MEAS_SET_ATTN, "T", CmdType.BROADCAST, ParaFormat.UINT_DEZ, Resources.StrCmdMsgMeasSetAttn), + new Cmd(CmdName.CmdRefToDutScale, "K", CmdType.broadcast, ParaFormat.individual, Resources.StrCmdMsgRefSetScale), + new Cmd(CmdName.CmdSetDutPulsesPerCm, "V", CmdType.individualUnresponsive, ParaFormat.uintDecimalValue, Resources.StrCmdMsgDutLppScale), + new Cmd(CmdName.CmdSetRefPulsesPerCm, "W", CmdType.individualUnresponsive, ParaFormat.uintDecimalValue, Resources.StrCmdMsgRefLppScale), + new Cmd(CmdName.CmdSetCurrentOutputAttenuation, "T", CmdType.broadcast, ParaFormat.uintDecimalValue, Resources.StrCmdMsgMeasSetAttn), // Measurement result request - new Cmd(CmdName.CMD_DUT_GET_TMR, "X", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgDutGetTmr), - new Cmd(CmdName.CMD_REF_GET_TMR, "Y", CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgRefGetTmr), - new Cmd(CmdName.CMD_CAL_DUT_TO_REF_TOL, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalDutToRefTol), - new Cmd(CmdName.CMD_GET_UDTLC, "Z", CmdType.INDIVIDUAL, ParaFormat.BYTE_HEX_PLUS_SIGN, Resources.StrCmdMsgGetUdtlc), - new Cmd(CmdName.CMD_GET_DTLC, "z", CmdType.INDIVIDUAL, ParaFormat.BYTE_HEX_PLUS_SIGN, Resources.StrCmdMsgGetDtlc), - new Cmd(CmdName.CMD_GET_REF_PERIOD, UNICODE_DLE, CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgGetRefPeriod), - new Cmd(CmdName.CMD_GET_DUT_PERIOD, UNICODE_DC1, CmdType.INDIVIDUAL,ParaFormat.UINT_HEX, Resources.StrCmdMsgGetDutPeriod), - new Cmd(CmdName.CMD_GET_REF_FREQU, UNICODE_DC2, CmdType.INDIVIDUAL, ParaFormat.UINT_HEX, Resources.StrCmdMsgGetRefFrequ), - new Cmd(CmdName.CMD_CAL_FREQU_REF_PERIOD, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalRefFrequFromRefPeriod), - new Cmd(CmdName.CMD_CAL_FREQU_DUT_PERIOD, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalDutFrequFromDutPeriod), - new Cmd(CmdName.CMD_CAL_FLOW_REF_FREQU, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalRefFlowRateFromRefFrequ), - new Cmd(CmdName.CMD_CAL_FLOW_REF_PERIOD, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalRefFlowRateFromRefPeriod), - new Cmd(CmdName.CMD_CAL_FLOW_DUT_PERIOD, "", CmdType.INDIVIDUAL, ParaFormat.DOUBLE, Resources.StrCalDutFlowRateFromDutPeriod), + new Cmd(CmdName.CmdGetDutTimerTicks, "X", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgDutGetTmr), + new Cmd(CmdName.CmdGetRefTimerTicks, "Y", CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgRefGetTmr), + new Cmd(CmdName.CmdCalculatedDutToRefTolerance, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalDutToRefTol), + new Cmd(CmdName.CmdGetDutToRefToleranceUndamped, "Z", CmdType.individual, ParaFormat.byteHexValuePlusSign, Resources.StrCmdMsgGetUdtlc), + new Cmd(CmdName.CmdGetDutToRefToleranceDamped, "z", CmdType.individual, ParaFormat.byteHexValuePlusSign, Resources.StrCmdMsgGetDtlc), + new Cmd(CmdName.CmdGetRefPeriod, UNICODE_DLE, CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgGetRefPeriod), + new Cmd(CmdName.CmdGetDutPeriod, UNICODE_DC1, CmdType.individual,ParaFormat.uintHexValue, Resources.StrCmdMsgGetDutPeriod), + new Cmd(CmdName.CmdGetRefFrequency, UNICODE_DC2, CmdType.individual, ParaFormat.uintHexValue, Resources.StrCmdMsgGetRefFrequ), + new Cmd(CmdName.CmdCalculatedFrequRefPeriod, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalRefFrequFromRefPeriod), + new Cmd(CmdName.CmdCalculatedFrequencyDutPeriod, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalDutFrequFromDutPeriod), + new Cmd(CmdName.CmdCalculatedFlowRefFrequ, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalRefFlowRateFromRefFrequ), + new Cmd(CmdName.CmdCalculatedFlowRefPeriod, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalRefFlowRateFromRefPeriod), + new Cmd(CmdName.CmdCalculatedFlowDutPeriod, "", CmdType.individual, ParaFormat.doubleValue, Resources.StrCalDutFlowRateFromDutPeriod), // Adjustment, place here Ids which may represent digital numbers from A to F - new Cmd(CmdName.CMD_COR_CURRENT, "C", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgCorCurrent), - new Cmd(CmdName.CMD_SET_XTR_MAX, "+", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgSetXtrMax), - new Cmd(CmdName.CMD_SET_XTR_MIN, "-", CmdType.BROADCAST, ParaFormat.PARAMETERLESS, Resources.StrCmdMsgSetXtrMin), - new Cmd(CmdName.CMD_ADDR_PC, "A", CmdType.INDIVIDUAL, ParaFormat.UINT_DEZ, Resources.StrCmdMsgAddrPc) + new Cmd(CmdName.CmdStartCurrentOffsetCorrection, "C", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgCorCurrent), + new Cmd(CmdName.CmdCurrentOutputMax, "+", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgSetXtrMax), + new Cmd(CmdName.CmdCurrentOutputMin, "-", CmdType.broadcast, ParaFormat.parameterless, Resources.StrCmdMsgSetXtrMin), + new Cmd(CmdName.CmdAddress, "A", CmdType.individual, ParaFormat.uintDecimalValue, Resources.StrCmdMsgAddrPc) }; /// diff --git a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/FM2014.cs b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/FM2014.cs index 32ccf90f..6a023bd7 100644 --- a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/FM2014.cs +++ b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/FM2014.cs @@ -562,7 +562,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } while (mantissa < REF_TO_DUT_SCALE_MANTISSA_MIN); // The pre-generated string will be used to send it to the FM2014 directly - RefToDutScaleStr = $"{mantissa}{GetCmdStr(CmdName.CMD_REF_SET_SCALE)}{exponent}"; + RefToDutScaleStr = $"{mantissa}{GetCmdStr(CmdName.CmdRefToDutScale)}{exponent}"; } } @@ -700,7 +700,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core /// public static Boolean ResetHardwareAllDevices() { - if (SharedCyclicMeasSequ == CyclicMeasSequ.IDLE) + if (SharedCyclicMeasSequ == CyclicMeasSequ.idle) return true; var firstActiveFm2014 = GetFirstConnectedAndLoggedInFm2014(); @@ -708,7 +708,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core return false; // Exit tasks - SharedCyclicMeasSequ = CyclicMeasSequ.IDLE; + SharedCyclicMeasSequ = CyclicMeasSequ.idle; // Schedule to other tasks to avoid side effects through the reset command Task.Factory.StartNew(() => @@ -717,8 +717,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core }).ContinueWith(delegate { // Reset measurement - var infoStr = GetCmdInfo(CmdName.CMD_RST_MEAS); - if (!Write(CmdName.CMD_RST_MEAS, firstActiveFm2014)) + var infoStr = GetCmdInfo(CmdName.CmdResetMeasurement); + if (!Write(CmdName.CmdResetMeasurement, firstActiveFm2014)) return; // Wait until FM2014 calibration finished @@ -728,7 +728,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core do { // Change the SI unit to ms instead of seconds - var response = new CmdResponse(CmdName.CMD_RST_MEAS, infoStr, (UInt32)resetDelayCtr_ms, + var response = new CmdResponse(CmdName.CmdResetMeasurement, infoStr, (UInt32)resetDelayCtr_ms, unit: "m" + Units.GetInfo(Units.Name.TIME_s)); PublishResponse(firstActiveFm2014, new ProcessExecEventArgs("", actualProcessMessage: infoStr, @@ -752,7 +752,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core /// public static Boolean StoreAllConfigurations() { - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE || + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle || RegisteredFm2014s == null || RegisteredFm2014s.Count == 0 || RegisteredFm2014s.All(x => !x.IsLoggedOn)) @@ -883,11 +883,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core public static Boolean PulseCounterMeasurement(Boolean refPulseCtrOn, Boolean dutPulseCtrOn) { // If the cyclic task has already been started everything is fine - if (SharedCyclicMeasSequ == CyclicMeasSequ.PULSE_CTR) + if (SharedCyclicMeasSequ == CyclicMeasSequ.pulseCounterMeasurement) return true; // Marked measurement isn't pulse counter measurement, other FM2014s cannot activate this - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle) return false; var firstActiveFm2014 = GetFirstConnectedAndLoggedInFm2014(); @@ -912,7 +912,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core return false; } - var cmdName = CmdName.CMD_NA; + var cmdName = CmdName.CmdNotAssigned; // Prepare REF and/or DUT pulse counter measurement, the first call activates if one or both are started! try @@ -920,15 +920,15 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core switch (firstActiveFm2014.RefPulseCtrOn) { case true when firstActiveFm2014.DutPulseCtrOn: - cmdName = CmdName.CMD_REF_DUT_STR_PLS_CTR; + cmdName = CmdName.CmdStartRefAndDutPulseCounter; MeasurementInfo = Resources.StrMeasMsgPulseCtrRefDut; break; case true: - cmdName = CmdName.CMD_REF_STR_PLS_CTR; + cmdName = CmdName.CmdStartRefPulseCounter; MeasurementInfo = Resources.StrMeasMsgPulseCtrRef; break; default: - cmdName = CmdName.CMD_DUT_STR_PLS_CTR; + cmdName = CmdName.CmdStartDutPulseCounter; MeasurementInfo = Resources.StrMeasMsgPulseCtrDut; break; } @@ -952,7 +952,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core { // Mark pulse counter measurement as active - SharedCyclicMeasSequ = CyclicMeasSequ.PULSE_CTR; + SharedCyclicMeasSequ = CyclicMeasSequ.pulseCounterMeasurement; do { @@ -963,14 +963,14 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Check if any FM2014 has a synchronized request to synchronize all FM2014 pulse counter values if (RegisteredFm2014s.Any(x => x.RefPulseCtrOn && x.DutPulseCtrOn)) { - cmdNameDut = CmdName.CMD_DUT_GET_PLS_CTR_BU; - cmdNameRef = CmdName.CMD_REF_GET_PLS_CTR_BU; + cmdNameDut = CmdName.CmdGetDutPulsesCountedBackup; + cmdNameRef = CmdName.CmdGetRefPulsesCountedBackup; syncPulseCtr = true; } else { - cmdNameDut = CmdName.CMD_DUT_GET_PLS_CTR; - cmdNameRef = CmdName.CMD_REF_GET_PLS_CTR; + cmdNameDut = CmdName.CmdGetDutPulsesCounted; + cmdNameRef = CmdName.CmdGetRefPulsesCounted; syncPulseCtr = false; } @@ -979,17 +979,17 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var infoDut = GetCmdInfo(cmdNameDut); // Make a backup of the pulse counters to synchronize those and read out the backups - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && syncPulseCtr) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && syncPulseCtr) { // Synchronized backup of REF and DUT pulse counter - Write(CmdName.CMD_REF_DUT_BU_PLS_CTR, firstActiveFm2014); + Write(CmdName.CmdBackupRefAndDutPulses, firstActiveFm2014); } foreach (var fm2014 in RegisteredFm2014s.Where(fm2014 => fm2014.IsLoggedOn)) { try { - if (SharedCyclicMeasSequ == CyclicMeasSequ.IDLE) continue; + if (SharedCyclicMeasSequ == CyclicMeasSequ.idle) continue; if (fm2014.RefPulseCtrOn && Write(cmdNameRef, fm2014)) { @@ -1016,7 +1016,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core specificInfoObj: response, statusReturn: StatusReturn.Failed)); } } - } while (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE); + } while (SharedCyclicMeasSequ != CyclicMeasSequ.idle); }, SharedCancellationToken).ContinueWith(delegate { foreach (var fm2014 in RegisteredFm2014s) @@ -1066,11 +1066,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core UInt16 doublePulseDeadtime_ms, Byte currentOutputAttenuation) { // If the cyclic task has already been started everything is fine - if (SharedCyclicMeasSequ == CyclicMeasSequ.REGULATION) + if (SharedCyclicMeasSequ == CyclicMeasSequ.regulationMeasurement) return true; // Marked measurement isn't pulse counter measurement, other FM2014s cannot activate this - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle) return false; // Initially, check if any device is connected and logged in, if not => exit @@ -1103,23 +1103,23 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core return false; } - var cmdName = CmdName.CMD_NA; + var cmdName = CmdName.CmdNotAssigned; MeasurementInfo = Resources.StrMeasMsgRegulation; // Prepare regulation measurement try { - cmdName = CmdName.CMD_SET_DBPL_UNLOCK; + cmdName = CmdName.CmdSwitchDoublePulseDeadtimeOff; if (!Write(cmdName, firstActiveFm2014)) { return false; } - cmdName = CmdName.CMD_MEAS_SET_ATTN; + cmdName = CmdName.CmdSetCurrentOutputAttenuation; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.CurrentOutputAttenuation)) { return false; } - cmdName = CmdName.CMD_REF_SET_SCALE; + cmdName = CmdName.CmdRefToDutScale; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.RefToDutScaleStr)) { return false; @@ -1137,7 +1137,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core Task.Run(() => { // Mark regulation measurement as active - SharedCyclicMeasSequ = CyclicMeasSequ.REGULATION; + SharedCyclicMeasSequ = CyclicMeasSequ.regulationMeasurement; do { @@ -1148,9 +1148,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read out the damped/undamped tolerance and convert the raw value (0, +/-1..255 digits) to the // tolerance in percent depending on the setup to 3 % (3.3) of 5 % (5.5) StatusReturn statusReturn; - cmdName = fm2014.UseDampedTolerance ? CmdName.CMD_GET_DTLC : CmdName.CMD_GET_UDTLC; + cmdName = fm2014.UseDampedTolerance ? CmdName.CmdGetDutToRefToleranceDamped : CmdName.CmdGetDutToRefToleranceUndamped; var info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out _, out _, out var doubleValue)) { @@ -1171,9 +1171,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } // Read the REF period and calculate the frequency [Hz] and flow rate [m³/h] based on this period - cmdName = CmdName.CMD_GET_REF_PERIOD; + cmdName = CmdName.CmdGetRefPeriod; info = GetCmdInfo(cmdName); - if (fm2014.RequestDebugInformation && SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && + if (fm2014.RequestDebugInformation && SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out _, out var period, out _)) @@ -1185,7 +1185,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core ResponseEvent(fm2014, response); // Publish the frequency in [Hz] - cmdName = CmdName.CMD_CAL_FREQU_REF_PERIOD; + cmdName = CmdName.CmdCalculatedFrequRefPeriod; info = GetCmdInfo(cmdName); response = new CmdResponse(cmdName, info, doubleValue: 1.0 / (TMR_RESOLUTION_s * period), @@ -1195,7 +1195,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Convert to m³/h (3600 s/h) based on REF pulse rate fm2014.RefFlowRate_cm_per_h = 3600.0 / ((Double)period * TMR_RESOLUTION_s) / fm2014.RefPulses_per_cm; // Publish the calculated flow rate [m³/h] - cmdName = CmdName.CMD_CAL_FLOW_REF_PERIOD; + cmdName = CmdName.CmdCalculatedFlowRefPeriod; info = GetCmdInfo(cmdName); response = new CmdResponse(cmdName, info, doubleValue: fm2014.RefFlowRate_cm_per_h, unit: Units.GetInfo(Units.Name.FLOW_RATE_cm_per_h)); @@ -1205,10 +1205,10 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read the DUT period and calculate the frequency [Hz] and flow rate [m³/h] based on this period - cmdName = CmdName.CMD_GET_DUT_PERIOD; + cmdName = CmdName.CmdGetDutPeriod; info = GetCmdInfo(cmdName); if (fm2014.RequestDebugInformation && - SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && + SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out _, out var period, out _)) @@ -1220,7 +1220,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core ResponseEvent(fm2014, response); // Publish the frequency in [Hz] - cmdName = CmdName.CMD_CAL_FREQU_DUT_PERIOD; + cmdName = CmdName.CmdCalculatedFrequencyDutPeriod; info = GetCmdInfo(cmdName); response = new CmdResponse(cmdName, info, doubleValue: 1.0 / (TMR_RESOLUTION_s * period), @@ -1230,7 +1230,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Convert to m³/h (3600 s/h) based on DUT pulse rate fm2014.DutFlowRate_cm_per_h = 3600.0 / ((Double)period * TMR_RESOLUTION_s) / fm2014.DutPulses_per_cm; // Publish the calculated flow rate [m³/h] - cmdName = CmdName.CMD_CAL_FLOW_DUT_PERIOD; + cmdName = CmdName.CmdCalculatedFlowDutPeriod; info = GetCmdInfo(cmdName); response = new CmdResponse(cmdName, info, doubleValue: fm2014.DutFlowRate_cm_per_h, unit: Units.GetInfo(Units.Name.FLOW_RATE_cm_per_h)); @@ -1239,9 +1239,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } // Read the REF frequency [Hz] directly and calculate the flow rate [m³/h] based on this frequency - cmdName = CmdName.CMD_GET_REF_FREQU; + cmdName = CmdName.CmdGetRefFrequency; info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out _, out var refFrequency, out _)) { @@ -1258,7 +1258,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Convert to m³/h (3600 s/h) and save the value fm2014.RefFlowRate_cm_per_h = 3600.0 * (Double)refFrequency / fm2014.RefPulses_per_cm; // Publish the calculated flow rate [m³/h] - cmdName = CmdName.CMD_CAL_FLOW_REF_FREQU; + cmdName = CmdName.CmdCalculatedFlowRefFrequ; info = GetCmdInfo(cmdName); response = new CmdResponse(cmdName, info, doubleValue: fm2014.RefFlowRate_cm_per_h, unit: Units.GetInfo(Units.Name.FLOW_RATE_cm_per_h)); @@ -1273,7 +1273,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core specificInfoObj: response, statusReturn: StatusReturn.Failed)); } } - } while (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE); + } while (SharedCyclicMeasSequ != CyclicMeasSequ.idle); }, SharedCancellationToken); @@ -1318,11 +1318,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core UInt16 doublePulseDeadtime_ms = 0) { // If the cyclic task has already been started everything is fine - if (SharedCyclicMeasSequ == CyclicMeasSequ.CALIBRATION) + if (SharedCyclicMeasSequ == CyclicMeasSequ.timeMeasurement) return true; // Marked measurement isn't pulse counter measurement, other FM2014s cannot activate this - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle) return false; // Initially, check if any device is connected and logged in, if not => exit @@ -1353,7 +1353,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } - var cmdName = CmdName.CMD_NA; + var cmdName = CmdName.CmdNotAssigned; MeasurementInfo = Resources.StrMeasMsgCalibration; // Prepare pulse time measurement with all broadcast command - avoid read @@ -1363,7 +1363,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (DOUBLE_PULSE_DEADTIME_MIN_ms == firstActiveFm2014.DoublePulseDeadtime_ms) { // This is a command without parameter - cmdName = CmdName.CMD_SET_DBPL_UNLOCK; + cmdName = CmdName.CmdSwitchDoublePulseDeadtimeOff; if (!Write(cmdName, firstActiveFm2014)) { return false; @@ -1371,12 +1371,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } else { - cmdName = CmdName.CMD_SET_DPLS_LOCK_TMR; + cmdName = CmdName.CmdSetDoublePulseDeadtimeBase; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.DoublePulseBaseDeadTime_ms)) { return false; } - cmdName = CmdName.CMD_SET_DPLS_LOCK_MULT; + cmdName = CmdName.CmdSetDoublePulseDeadtimeMultiplier; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.DoublePulseMultiplier)) { return false; @@ -1385,7 +1385,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (firstActiveFm2014.RefPulsesRequired != 0) { - cmdName = CmdName.CMD_REF_SET_PLS; + cmdName = CmdName.CmdRefSetPulsesRequired; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.RefPulsesRequired)) { return false; @@ -1394,7 +1394,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (firstActiveFm2014.DutPulsesRequired != 0) { - cmdName = CmdName.CMD_DUT_SET_PLS; + cmdName = CmdName.CmdSetDutPulsesRequired; if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.DutPulsesRequired)) { return false; @@ -1413,7 +1413,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core Task.Run(() => { // Mark calibration measurement as active - SharedCyclicMeasSequ = CyclicMeasSequ.CALIBRATION; + SharedCyclicMeasSequ = CyclicMeasSequ.timeMeasurement; // Set up the progress maximal counter value base on required pulses for REF or DUT InitActualProcessProgress( @@ -1431,9 +1431,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core StatusReturn statusReturn; // Read the device status to check for timeout between pulses - cmdName = CmdName.CMD_GET_STATUS; + cmdName = CmdName.CmdGetStatus; var info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out responseStr, out var status, out _)) { @@ -1446,9 +1446,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read the remaining REF pulses if required if (fm2014.RefPulsesRequired != 0) { - cmdName = CmdName.CMD_REF_GET_PLS_RMN; + cmdName = CmdName.CmdRefPulsesRemaining; info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out responseStr, out var pulses, out _)) { @@ -1481,9 +1481,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read the remaining DUT pulses if required if (fm2014.DutPulsesRequired != 0) { - cmdName = CmdName.CMD_DUT_GET_PLS_RMN; + cmdName = CmdName.CmdDutGetPulsesRemaining; info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out responseStr, out var pulses, out _)) { @@ -1520,9 +1520,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read the REF timer ticks for the counted pulses if (fm2014.RefPulsesRequired != 0) { - cmdName = CmdName.CMD_REF_GET_TMR; + cmdName = CmdName.CmdGetRefTimerTicks; info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out responseStr, out var timerTicks, out _)) { @@ -1542,9 +1542,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Read the DUT timer ticks for the counted pulses if (fm2014.DutPulsesRequired != 0) { - cmdName = CmdName.CMD_DUT_GET_TMR; + cmdName = CmdName.CmdGetDutTimerTicks; info = GetCmdInfo(cmdName); - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle && Write(cmdName, fm2014)) { if (Read(cmdName, fm2014, out responseStr, out var timerTicks, out _)) { @@ -1564,7 +1564,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Calculate the DUT to REF tolerance if both timer had been active if (fm2014.RefPulsesRequired != 0 && fm2014.DutPulsesRequired != 0) { - cmdName = CmdName.CMD_CAL_DUT_TO_REF_TOL; + cmdName = CmdName.CmdCalculatedDutToRefTolerance; info = GetCmdInfo(cmdName); // Is converting to a real time in seconds if (fm2014.RefTimeMeasured_s > 0.0) @@ -1606,9 +1606,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core { ResetHardwareAllDevices(); // Exit this task - SharedCyclicMeasSequ = CyclicMeasSequ.IDLE; + SharedCyclicMeasSequ = CyclicMeasSequ.idle; } - } while (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE); + } while (SharedCyclicMeasSequ != CyclicMeasSequ.idle); }, SharedCancellationToken); @@ -1634,14 +1634,14 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var statusReturn = StatusReturn.Unknown; var numberStyle = NumberStyles.None; var paraFormat = GetParaFormat(cmdName); - if (paraFormat == ParaFormat.UINT_HEX || paraFormat == ParaFormat.BYTE_HEX_PLUS_SIGN) + if (paraFormat == ParaFormat.uintHexValue || paraFormat == ParaFormat.byteHexValuePlusSign) { numberStyle = NumberStyles.HexNumber; } switch (paraFormat) { - case ParaFormat.BYTE_HEX_PLUS_SIGN: + case ParaFormat.byteHexValuePlusSign: // The response contains a sign! var signMultiplier = responseStr.Contains("+") ? 1.0 : -1.0; var cleanedStr = responseStr.Replace("+", "").Replace("-", ""); @@ -1651,8 +1651,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } break; - case ParaFormat.UINT_HEX: - case ParaFormat.UINT_DEZ: + case ParaFormat.uintHexValue: + case ParaFormat.uintDecimalValue: if (uint.TryParse(responseStr, numberStyle, new CultureInfo("en"), out intValueParsed)) { intValue = intValueParsed; @@ -1690,13 +1690,13 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core ActualProcessProgress++; // Check for individual command without response - if (CmdType.INDIVIDUAL_UNRESPONSIVE == SharedCmdTypeReminderLastCmd && - CmdType.INDIVIDUAL_UNRESPONSIVE == GetCmdType(cmdName)) + if (CmdType.individualUnresponsive == SharedCmdTypeReminderLastCmd && + CmdType.individualUnresponsive == GetCmdType(cmdName)) { statusReturn = StatusReturn.Skipped; } - else if (CmdType.INDIVIDUAL == SharedCmdTypeReminderLastCmd && - CmdType.INDIVIDUAL == GetCmdType(cmdName)) + else if (CmdType.individual == SharedCmdTypeReminderLastCmd && + CmdType.individual == GetCmdType(cmdName)) { // Read or timeout with a TimeoutException var answerStr = SharedSerialPort?.ReadTo(END_OF_STR); @@ -1745,9 +1745,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (SharedSerialPort == null) { - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; fm2014.IsLoggedOn = false; - SharedCyclicMeasSequ = CyclicMeasSequ.IDLE; + SharedCyclicMeasSequ = CyclicMeasSequ.idle; return false; } if (!DisableWriteReadActualProcessIncreasing) @@ -1755,9 +1755,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core // Initiate communication using the individual or broadcast address var retVal = true; - if (CmdType.BROADCAST == GetCmdType(cmdName)) + if (CmdType.broadcast == GetCmdType(cmdName)) { - if (SharedCmdTypeReminderLastCmd != CmdType.BROADCAST) + if (SharedCmdTypeReminderLastCmd != CmdType.broadcast) { retVal = InitiateBroadcastComm(fm2014); } @@ -1765,8 +1765,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core else { if (ReminderLastIndividualCommFm2014Address != fm2014.Address || - SharedCmdTypeReminderLastCmd != CmdType.INDIVIDUAL || - SharedCmdTypeReminderLastCmd != CmdType.INDIVIDUAL) + SharedCmdTypeReminderLastCmd != CmdType.individual || + SharedCmdTypeReminderLastCmd != CmdType.individual) { retVal = InitiateIndividualComm(fm2014); if (retVal) @@ -1781,13 +1781,13 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var cmdCodeStr = GetCmdStr(cmdName); var info = GetCmdInfo(cmdName) + $": {cmdCodeStr}"; - var isHexFormat = GetParaFormat(cmdName) == ParaFormat.UINT_HEX; + var isHexFormat = GetParaFormat(cmdName) == ParaFormat.uintHexValue; CmdResponse response; // Without data the command alone needs to be sent if (dataObj == null) { SharedSerialPort.Write($"{cmdCodeStr}{END_OF_STR}"); - var additionalInfo = GetCmdType(cmdName) == CmdType.BROADCAST + var additionalInfo = GetCmdType(cmdName) == CmdType.broadcast ? Resources.StrCommDirectionSetup : Resources.StrCommDirectionRequest; response = new CmdResponse(cmdName, $"{additionalInfo}: {info}"); @@ -1849,38 +1849,38 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core SharedSerialPort.Open(); if (!SharedSerialPort.IsOpen) { - response = new CmdResponse(CmdName.CMD_ADDR_PC, + response = new CmdResponse(CmdName.CmdAddress, $"{Resources.StrCmdRespErrorBroadcast}"); PublishResponse(fm2014, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; return false; } } // If broadcast communication is already active - if (SharedCmdTypeReminderLastCmd == CmdType.BROADCAST) + if (SharedCmdTypeReminderLastCmd == CmdType.broadcast) { return true; } // Establish connection to all FM2014s with broadcast address // The direct write has to be used as this is being called from the 'Write' routine!!!! SharedSerialPort.Write(BROADCAST_ADDRESS + END_OF_STR); - var cmdName = CmdName.CMD_CONNECT; + var cmdName = CmdName.CmdConnect; var info = GetCmdInfo(cmdName) + ": " + BROADCAST_ADDRESS; response = new CmdResponse(cmdName, info); PublishResponse(fm2014, new ProcessExecEventArgs("", specificInfoObj: response)); - SharedCmdTypeReminderLastCmd = CmdType.BROADCAST; + SharedCmdTypeReminderLastCmd = CmdType.broadcast; return true; } catch (Exception e) { - response = new CmdResponse(CmdName.CMD_ADDR_PC, + response = new CmdResponse(CmdName.CmdAddress, $"{Resources.StrCmdRespErrorBroadcast} - {e.Message}"); PublishResponse(fm2014, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; return false; } } @@ -1909,11 +1909,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core SharedSerialPort.Open(); if (!SharedSerialPort.IsOpen) { - response = new CmdResponse(CmdName.CMD_ADDR_PC, $"{Resources.StrCmdRespErrorIndividual}"); + response = new CmdResponse(CmdName.CmdAddress, $"{Resources.StrCmdRespErrorIndividual}"); PublishResponse(fm2014, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; fm2014.IsLoggedOn = false; return false; } @@ -1926,7 +1926,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (!string.IsNullOrEmpty(fm2014.ConnectResponse)) { - var cmdName = CmdName.CMD_CONNECT; + var cmdName = CmdName.CmdConnect; var info = GetCmdInfo(cmdName) + ": " + fm2014.AddressStr; response = new CmdResponse(cmdName, info); PublishResponse(fm2014, new ProcessExecEventArgs("", specificInfoObj: response)); @@ -1939,19 +1939,19 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core } catch (Exception e) { - response = new CmdResponse(CmdName.CMD_CONNECT, $"{Resources.StrCmdRespErrorIndividual}" + + response = new CmdResponse(CmdName.CmdConnect, $"{Resources.StrCmdRespErrorIndividual}" + $": {fm2014.AddressStr}" + $" - {e.Message}"); PublishResponse(fm2014, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; fm2014.IsLoggedOn = false; return false; } - response = new CmdResponse(CmdName.CMD_CONNECT, $"{Resources.StrCmdRespErrorIndividual}"); + response = new CmdResponse(CmdName.CmdConnect, $"{Resources.StrCmdRespErrorIndividual}"); PublishResponse(fm2014, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; return false; } @@ -1974,6 +1974,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core RegisteredFm2014s?.Clear(); RegisteredFm2014s = null; SharedSerialPort?.Dispose(); + SharedSerialPort = null; } #endregion ---------------------------------------- static methods -------------------------------------------- @@ -1989,10 +1990,10 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core private Boolean SaveStandAloneMeasurement() { // If the cyclic task has already been started everything is fine - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE || !IsLoggedOn) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle || !IsLoggedOn) return false; - var cmdName = CmdName.CMD_REF_LPP_SCALE; + var cmdName = CmdName.CmdSetRefPulsesPerCm; try { // Set to zero if it doesn't fit to the limit which can be stored as indicator for invalid value @@ -2003,27 +2004,27 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core if (retVal) { - cmdName = CmdName.CMD_DUT_LPP_SCALE; + cmdName = CmdName.CmdSetDutPulsesPerCm; retVal = Write(cmdName, this, DutPulses_per_cm); } if (retVal) { - cmdName = CmdName.CMD_REF_SET_SCALE; + cmdName = CmdName.CmdRefToDutScale; // During setup of the 'Ref_pulse_per_cm' the '_refToDutScaleStr' will be generated retVal = Write(cmdName, this, RefToDutScaleStr); } if (retVal) { - cmdName = CmdName.CMD_MEAS_SET_ATTN; + cmdName = CmdName.CmdSetCurrentOutputAttenuation; retVal = Write(cmdName, this, CurrentOutputAttenuation); } if (retVal) { // Save all settings from RAM to nonvolatile EEPROM - cmdName = CmdName.CMD_SAVE_RAM_TO_EEP_MEAS_SETUP; + cmdName = CmdName.CmdSaveRamToEepMeasSetup; return Write(cmdName, this); } } @@ -2052,12 +2053,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core private Boolean ReadStandAloneMeasurement(CmdName cmdName) { // If the cyclic task has already been started everything is fine - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE || !IsLoggedOn) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle || !IsLoggedOn) return false; // Allow explicit standalone measurement commands - if (cmdName != CmdName.CMD_READ_EEP_MEAS_SETUP && - cmdName != CmdName.CMD_READ_RAM_MEAS_SETUP) + if (cmdName != CmdName.CmdReadEepMeasSetup && + cmdName != CmdName.CmdReadRamMeasSetup) { return false; } @@ -2067,7 +2068,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var responseStrs = new List(); if (Write(cmdName, this)) { - if (cmdName == CmdName.CMD_READ_EEP_MEAS_SETUP) + if (cmdName == CmdName.CmdReadEepMeasSetup) { // From here 5 lines need to be read to get the information var loopCtr = 4; @@ -2097,7 +2098,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core attenuation >= CURRENT_OUTPUT_ATTENUATION_MIN && attenuation <= CURRENT_OUTPUT_ATTENUATION_MAX) { - cmdName = CmdName.CMD_MEAS_SET_ATTN; + cmdName = CmdName.CmdSetCurrentOutputAttenuation; var info = GetCmdInfo(cmdName); CurrentOutputAttenuation = attenuation; var response = new CmdResponse(cmdName, info, CurrentOutputAttenuation); @@ -2110,7 +2111,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var strCleaned = strFields[1].Replace(" ", ""); if (double.TryParse(strCleaned, NumberStyles.Float, new CultureInfo("en"), out var value)) { - cmdName = CmdName.CMD_REF_SET_SCALE; + cmdName = CmdName.CmdRefToDutScale; var info = GetCmdInfo(cmdName); RefToDutScale_norm = value; var response = new CmdResponse(cmdName, info, doubleValue: RefToDutScale_norm); @@ -2123,13 +2124,13 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core var strCleaned = Regex.Replace(str, "[^0-9]", string.Empty); if (ushort.TryParse(strCleaned, out var value)) { - cmdName = CmdName.CMD_DUT_LPP_SCALE; + cmdName = CmdName.CmdSetDutPulsesPerCm; var info = GetCmdInfo(cmdName); DutPulses_per_cm = value; var response = new CmdResponse(cmdName, info, DutPulses_per_cm); ResponseEvent(this, response); // Added 2026-Jan-01 to overcome limitation of max 9999 Impulses per volume - cmdName = CmdName.CMD_REF_LPP_SCALE; + cmdName = CmdName.CmdSetRefPulsesPerCm; info = GetCmdInfo(cmdName); // Calculate REF pulses per cubic meter RefPulses_per_cm = (UInt32)Math.Round(DutPulses_per_cm * RefToDutScale_norm, 1); @@ -2162,7 +2163,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core { // If the cyclic task has already been started the login isn't allowed anymore // until this has been finished - if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE) + if (SharedCyclicMeasSequ != CyclicMeasSequ.idle) return false; return InitiateIndividualComm(this); @@ -2229,7 +2230,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core SharedSerialPort.ReadTimeout = 1000; SharedSerialPort.WriteTimeout = 1000; } - var cmdName = CmdName.CMD_SERIAL; + var cmdName = CmdName.CmdSerialNumber; try { if (!SharedSerialPort.IsOpen) @@ -2237,12 +2238,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core SharedSerialPort.Open(); if (!SharedSerialPort.IsOpen) { - var response = new CmdResponse(CmdName.CMD_ADDR_PC, + var response = new CmdResponse(CmdName.CmdAddress, $"{Resources.StrCmdRespErrorBroadcast}"); PublishResponse(this, new ProcessExecEventArgs(Resources.StrError, specificInfoObj: response, statusReturn: StatusReturn.Failed)); - SharedCmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED; + SharedCmdTypeReminderLastCmd = CmdType.uninitialized; return false; } } @@ -2264,7 +2265,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core SerialNumber = SerialNumber.Replace(cmdCode, ""); } - cmdName = CmdName.CMD_PRINT_STATISTICS; + cmdName = CmdName.CmdGetLifetime; // Read out the lifetime of this FM2014 if (!Write(cmdName, this)) { @@ -2278,7 +2279,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core Lifetime_h = intValue; } - IsLoggedOn = ReadStandAloneMeasurement(CmdName.CMD_READ_EEP_MEAS_SETUP); + IsLoggedOn = ReadStandAloneMeasurement(CmdName.CmdReadEepMeasSetup); } catch (Exception e) { diff --git a/Common/LaaPackages b/Common/LaaPackages index 1cd877ff..653498d4 160000 --- a/Common/LaaPackages +++ b/Common/LaaPackages @@ -1 +1 @@ -Subproject commit 1cd877ff8628cdcb94a7ad2751d61dc77e1211da +Subproject commit 653498d43dcca1234a8fba95959ca02bb2c3f480 diff --git a/MiniPrf/Ui/FrmMainMiniPrf.Designer.cs b/MiniPrf/Ui/FrmMainMiniPrf.Designer.cs index 67d3bedc..5e63fbc5 100644 --- a/MiniPrf/Ui/FrmMainMiniPrf.Designer.cs +++ b/MiniPrf/Ui/FrmMainMiniPrf.Designer.cs @@ -46,6 +46,22 @@ this.tbxFM2014FullId = new System.Windows.Forms.TextBox(); this.tbxFM2014ApplicationFwVersion = new System.Windows.Forms.TextBox(); this.gbxRegulationSetup = new System.Windows.Forms.GroupBox(); + this.gbxBoxDebug = new System.Windows.Forms.GroupBox(); + this.label7 = new System.Windows.Forms.Label(); + this.tbxRefFlowRateFromRefFrequencyCmPerH = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.tbxRefFrequencyDirectHz = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.tbxDutPeriodMs = new System.Windows.Forms.TextBox(); + this.tbxRefFlowRateFromRefPeriodCmPerH = new System.Windows.Forms.TextBox(); + this.tbxDutFrequencyFromDutPeriodHz = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.tbxDutFlowRateFromDutPeriodCmPerH = new System.Windows.Forms.TextBox(); + this.tbxRefFrequencyFromRefPeriodHz = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.tbxRefPeriodMs = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); this.btnSaveSetupToFm2014 = new System.Windows.Forms.Button(); this.cbxToleranceDisplayAttenuation = new System.Windows.Forms.ComboBox(); this.lblRefPulsePerVolume = new System.Windows.Forms.Label(); @@ -81,30 +97,14 @@ this.lblActualFlowRateCmPerHour = new System.Windows.Forms.Label(); this.tbxActualFlowRateCmPerHour = new System.Windows.Forms.TextBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.label1 = new System.Windows.Forms.Label(); - this.tbxRefFrequencyFromRefPeriodHz = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.tbxRefFlowRateFromRefPeriodCmPerH = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.tbxRefPeriodMs = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.tbxDutPeriodMs = new System.Windows.Forms.TextBox(); - this.tbxDutFrequencyFromDutPeriodHz = new System.Windows.Forms.TextBox(); - this.tbxDutFlowRateFromDutPeriodCmPerH = new System.Windows.Forms.TextBox(); - this.grpBoxDebug = new System.Windows.Forms.GroupBox(); - this.label7 = new System.Windows.Forms.Label(); - this.tbxRefFlowRateFromRefFrequencyCmPerH = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.tbxRefFrequencyDirectHz = new System.Windows.Forms.TextBox(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.gbxFM2014Setup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picFM2014)).BeginInit(); this.gbxRegulationSetup.SuspendLayout(); + this.gbxBoxDebug.SuspendLayout(); this.gbxManualRefCalibration.SuspendLayout(); this.gbxDutToRefRegulation.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.grpBoxDebug.SuspendLayout(); this.SuspendLayout(); // // gbxFM2014Setup @@ -147,10 +147,11 @@ "5"}); this.cbxToleranceDisplayRange.Location = new System.Drawing.Point(220, 150); this.cbxToleranceDisplayRange.Name = "cbxToleranceDisplayRange"; + this.cbxToleranceDisplayRange.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.cbxToleranceDisplayRange.Size = new System.Drawing.Size(60, 21); this.cbxToleranceDisplayRange.TabIndex = 3; this.cbxToleranceDisplayRange.Text = "3"; - this.cbxToleranceDisplayRange.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged); + this.cbxToleranceDisplayRange.SelectedValueChanged += new System.EventHandler(this.cbxProgramSettings_Changed); // // picFM2014 // @@ -169,8 +170,10 @@ this.tbxFM2014SerialNumber.Location = new System.Drawing.Point(220, 75); this.tbxFM2014SerialNumber.Name = "tbxFM2014SerialNumber"; this.tbxFM2014SerialNumber.ReadOnly = true; + this.tbxFM2014SerialNumber.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxFM2014SerialNumber.Size = new System.Drawing.Size(60, 20); this.tbxFM2014SerialNumber.TabIndex = 29; + this.tbxFM2014SerialNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lblFM2014Tolerance // @@ -204,10 +207,11 @@ "22"}); this.cbxFM2014Address.Location = new System.Drawing.Point(220, 125); this.cbxFM2014Address.Name = "cbxFM2014Address"; + this.cbxFM2014Address.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.cbxFM2014Address.Size = new System.Drawing.Size(60, 21); this.cbxFM2014Address.TabIndex = 2; this.cbxFM2014Address.Text = "1"; - this.cbxFM2014Address.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged); + this.cbxFM2014Address.SelectedValueChanged += new System.EventHandler(this.cbxProgramSettings_Changed); // // lblFM2014Address // @@ -229,9 +233,9 @@ // // btnFM2014Connect // - this.btnFM2014Connect.Location = new System.Drawing.Point(170, 179); + this.btnFM2014Connect.Location = new System.Drawing.Point(163, 179); this.btnFM2014Connect.Name = "btnFM2014Connect"; - this.btnFM2014Connect.Size = new System.Drawing.Size(110, 25); + this.btnFM2014Connect.Size = new System.Drawing.Size(120, 25); this.btnFM2014Connect.TabIndex = 0; this.btnFM2014Connect.Text = "Connect"; this.btnFM2014Connect.UseVisualStyleBackColor = true; @@ -242,10 +246,11 @@ this.cbxProgramComPort.FormattingEnabled = true; this.cbxProgramComPort.Location = new System.Drawing.Point(220, 100); this.cbxProgramComPort.Name = "cbxProgramComPort"; + this.cbxProgramComPort.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.cbxProgramComPort.Size = new System.Drawing.Size(60, 21); this.cbxProgramComPort.TabIndex = 1; this.cbxProgramComPort.Text = "NA"; - this.cbxProgramComPort.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged); + this.cbxProgramComPort.SelectedValueChanged += new System.EventHandler(this.cbxProgramSettings_Changed); // // lblFM2014SerialPort // @@ -281,11 +286,14 @@ this.tbxFM2014ApplicationFwVersion.Location = new System.Drawing.Point(220, 50); this.tbxFM2014ApplicationFwVersion.Name = "tbxFM2014ApplicationFwVersion"; this.tbxFM2014ApplicationFwVersion.ReadOnly = true; + this.tbxFM2014ApplicationFwVersion.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxFM2014ApplicationFwVersion.Size = new System.Drawing.Size(60, 20); this.tbxFM2014ApplicationFwVersion.TabIndex = 31; + this.tbxFM2014ApplicationFwVersion.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // gbxRegulationSetup // + this.gbxRegulationSetup.Controls.Add(this.gbxBoxDebug); this.gbxRegulationSetup.Controls.Add(this.btnSaveSetupToFm2014); this.gbxRegulationSetup.Controls.Add(this.cbxToleranceDisplayAttenuation); this.gbxRegulationSetup.Controls.Add(this.lblRefPulsePerVolume); @@ -302,11 +310,179 @@ this.gbxRegulationSetup.TabStop = false; this.gbxRegulationSetup.Text = "Regulation Setup"; // + // grpBoxDebug + // + this.gbxBoxDebug.Controls.Add(this.label7); + this.gbxBoxDebug.Controls.Add(this.tbxRefFlowRateFromRefFrequencyCmPerH); + this.gbxBoxDebug.Controls.Add(this.label6); + this.gbxBoxDebug.Controls.Add(this.tbxRefFrequencyDirectHz); + this.gbxBoxDebug.Controls.Add(this.label1); + this.gbxBoxDebug.Controls.Add(this.tbxDutPeriodMs); + this.gbxBoxDebug.Controls.Add(this.tbxRefFlowRateFromRefPeriodCmPerH); + this.gbxBoxDebug.Controls.Add(this.tbxDutFrequencyFromDutPeriodHz); + this.gbxBoxDebug.Controls.Add(this.label2); + this.gbxBoxDebug.Controls.Add(this.tbxDutFlowRateFromDutPeriodCmPerH); + this.gbxBoxDebug.Controls.Add(this.tbxRefFrequencyFromRefPeriodHz); + this.gbxBoxDebug.Controls.Add(this.label5); + this.gbxBoxDebug.Controls.Add(this.tbxRefPeriodMs); + this.gbxBoxDebug.Controls.Add(this.label4); + this.gbxBoxDebug.Controls.Add(this.label3); + this.gbxBoxDebug.Location = new System.Drawing.Point(0, -1); + this.gbxBoxDebug.Name = "gbxBoxDebug"; + this.gbxBoxDebug.Size = new System.Drawing.Size(288, 175); + this.gbxBoxDebug.TabIndex = 83; + this.gbxBoxDebug.TabStop = false; + this.gbxBoxDebug.Text = "Debug"; + this.gbxBoxDebug.Visible = false; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(10, 101); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(128, 13); + this.label7.TabIndex = 96; + this.label7.Text = "Flow Rate f(frequ.) [m³/h]:"; + // + // tbxRefFlowRateFromRefFrequencyCmPerH + // + this.tbxRefFlowRateFromRefFrequencyCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxRefFlowRateFromRefFrequencyCmPerH.Location = new System.Drawing.Point(153, 99); + this.tbxRefFlowRateFromRefFrequencyCmPerH.Name = "tbxRefFlowRateFromRefFrequencyCmPerH"; + this.tbxRefFlowRateFromRefFrequencyCmPerH.ReadOnly = true; + this.tbxRefFlowRateFromRefFrequencyCmPerH.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxRefFlowRateFromRefFrequencyCmPerH.Size = new System.Drawing.Size(60, 20); + this.tbxRefFlowRateFromRefFrequencyCmPerH.TabIndex = 95; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(10, 52); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(117, 13); + this.label6.TabIndex = 94; + this.label6.Text = "Frequency (direct) [Hz]:"; + // + // tbxRefFrequencyDirectHz + // + this.tbxRefFrequencyDirectHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxRefFrequencyDirectHz.Location = new System.Drawing.Point(153, 50); + this.tbxRefFrequencyDirectHz.Name = "tbxRefFrequencyDirectHz"; + this.tbxRefFrequencyDirectHz.ReadOnly = true; + this.tbxRefFrequencyDirectHz.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxRefFrequencyDirectHz.Size = new System.Drawing.Size(60, 20); + this.tbxRefFrequencyDirectHz.TabIndex = 93; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(10, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(123, 13); + this.label1.TabIndex = 83; + this.label1.Text = "Frequency f(period) [Hz]:"; + // + // tbxDutPeriodMs + // + this.tbxDutPeriodMs.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxDutPeriodMs.Location = new System.Drawing.Point(220, 123); + this.tbxDutPeriodMs.Name = "tbxDutPeriodMs"; + this.tbxDutPeriodMs.ReadOnly = true; + this.tbxDutPeriodMs.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxDutPeriodMs.Size = new System.Drawing.Size(60, 20); + this.tbxDutPeriodMs.TabIndex = 92; + // + // tbxRefFlowRateFromRefPeriodCmPerH + // + this.tbxRefFlowRateFromRefPeriodCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxRefFlowRateFromRefPeriodCmPerH.Location = new System.Drawing.Point(153, 74); + this.tbxRefFlowRateFromRefPeriodCmPerH.Name = "tbxRefFlowRateFromRefPeriodCmPerH"; + this.tbxRefFlowRateFromRefPeriodCmPerH.ReadOnly = true; + this.tbxRefFlowRateFromRefPeriodCmPerH.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxRefFlowRateFromRefPeriodCmPerH.Size = new System.Drawing.Size(60, 20); + this.tbxRefFlowRateFromRefPeriodCmPerH.TabIndex = 81; + // + // tbxDutFrequencyFromDutPeriodHz + // + this.tbxDutFrequencyFromDutPeriodHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxDutFrequencyFromDutPeriodHz.Location = new System.Drawing.Point(220, 25); + this.tbxDutFrequencyFromDutPeriodHz.Name = "tbxDutFrequencyFromDutPeriodHz"; + this.tbxDutFrequencyFromDutPeriodHz.ReadOnly = true; + this.tbxDutFrequencyFromDutPeriodHz.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxDutFrequencyFromDutPeriodHz.Size = new System.Drawing.Size(60, 20); + this.tbxDutFrequencyFromDutPeriodHz.TabIndex = 91; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(10, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(130, 13); + this.label2.TabIndex = 80; + this.label2.Text = "Flow Rate f(period) [m³/h]:"; + // + // tbxDutFlowRateFromDutPeriodCmPerH + // + this.tbxDutFlowRateFromDutPeriodCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxDutFlowRateFromDutPeriodCmPerH.Location = new System.Drawing.Point(220, 74); + this.tbxDutFlowRateFromDutPeriodCmPerH.Name = "tbxDutFlowRateFromDutPeriodCmPerH"; + this.tbxDutFlowRateFromDutPeriodCmPerH.ReadOnly = true; + this.tbxDutFlowRateFromDutPeriodCmPerH.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxDutFlowRateFromDutPeriodCmPerH.Size = new System.Drawing.Size(60, 20); + this.tbxDutFlowRateFromDutPeriodCmPerH.TabIndex = 90; + // + // tbxRefFrequencyFromRefPeriodHz + // + this.tbxRefFrequencyFromRefPeriodHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxRefFrequencyFromRefPeriodHz.Location = new System.Drawing.Point(153, 25); + this.tbxRefFrequencyFromRefPeriodHz.Name = "tbxRefFrequencyFromRefPeriodHz"; + this.tbxRefFrequencyFromRefPeriodHz.ReadOnly = true; + this.tbxRefFrequencyFromRefPeriodHz.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxRefFrequencyFromRefPeriodHz.Size = new System.Drawing.Size(60, 20); + this.tbxRefFrequencyFromRefPeriodHz.TabIndex = 82; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(232, 9); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(30, 13); + this.label5.TabIndex = 89; + this.label5.Text = "DUT"; + // + // tbxRefPeriodMs + // + this.tbxRefPeriodMs.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbxRefPeriodMs.Location = new System.Drawing.Point(153, 123); + this.tbxRefPeriodMs.Name = "tbxRefPeriodMs"; + this.tbxRefPeriodMs.ReadOnly = true; + this.tbxRefPeriodMs.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.tbxRefPeriodMs.Size = new System.Drawing.Size(60, 20); + this.tbxRefPeriodMs.TabIndex = 85; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(169, 9); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(28, 13); + this.label4.TabIndex = 88; + this.label4.Text = "REF"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(10, 125); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(62, 13); + this.label3.TabIndex = 84; + this.label3.Text = "Period [ms]:"; + // // btnSaveSetupToFm2014 // - this.btnSaveSetupToFm2014.Location = new System.Drawing.Point(173, 144); + this.btnSaveSetupToFm2014.Location = new System.Drawing.Point(163, 144); this.btnSaveSetupToFm2014.Name = "btnSaveSetupToFm2014"; - this.btnSaveSetupToFm2014.Size = new System.Drawing.Size(110, 25); + this.btnSaveSetupToFm2014.Size = new System.Drawing.Size(120, 25); this.btnSaveSetupToFm2014.TabIndex = 7; this.btnSaveSetupToFm2014.Text = "Save"; this.btnSaveSetupToFm2014.UseVisualStyleBackColor = true; @@ -327,6 +503,7 @@ "9"}); this.cbxToleranceDisplayAttenuation.Location = new System.Drawing.Point(220, 101); this.cbxToleranceDisplayAttenuation.Name = "cbxToleranceDisplayAttenuation"; + this.cbxToleranceDisplayAttenuation.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.cbxToleranceDisplayAttenuation.Size = new System.Drawing.Size(60, 21); this.cbxToleranceDisplayAttenuation.TabIndex = 6; this.cbxToleranceDisplayAttenuation.Text = "3"; @@ -374,8 +551,10 @@ this.tbxRefPulsesPerCm.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxRefPulsesPerCm.Location = new System.Drawing.Point(220, 26); this.tbxRefPulsesPerCm.Name = "tbxRefPulsesPerCm"; + this.tbxRefPulsesPerCm.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxRefPulsesPerCm.Size = new System.Drawing.Size(60, 20); this.tbxRefPulsesPerCm.TabIndex = 4; + this.tbxRefPulsesPerCm.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.tbxRefPulsesPerCm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxRefPulsesPerCm_KeyDown); this.tbxRefPulsesPerCm.Leave += new System.EventHandler(this.tbxRefPulsesPerCm_Leave); // @@ -384,8 +563,10 @@ this.tbxDutPulsesPerCm.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxDutPulsesPerCm.Location = new System.Drawing.Point(220, 51); this.tbxDutPulsesPerCm.Name = "tbxDutPulsesPerCm"; + this.tbxDutPulsesPerCm.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxDutPulsesPerCm.Size = new System.Drawing.Size(60, 20); this.tbxDutPulsesPerCm.TabIndex = 5; + this.tbxDutPulsesPerCm.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.tbxDutPulsesPerCm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxDutPulsesPerCm_KeyDown); this.tbxDutPulsesPerCm.Leave += new System.EventHandler(this.tbxDutPulsesPerCm_Leave); // @@ -395,8 +576,10 @@ this.tbxScaleRefToDut.Location = new System.Drawing.Point(220, 76); this.tbxScaleRefToDut.Name = "tbxScaleRefToDut"; this.tbxScaleRefToDut.ReadOnly = true; + this.tbxScaleRefToDut.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxScaleRefToDut.Size = new System.Drawing.Size(60, 20); this.tbxScaleRefToDut.TabIndex = 66; + this.tbxScaleRefToDut.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lblUpdateTimeValue // @@ -450,9 +633,9 @@ // // btnDutToRefRegulation // - this.btnDutToRefRegulation.Location = new System.Drawing.Point(113, 144); + this.btnDutToRefRegulation.Location = new System.Drawing.Point(104, 144); this.btnDutToRefRegulation.Name = "btnDutToRefRegulation"; - this.btnDutToRefRegulation.Size = new System.Drawing.Size(110, 25); + this.btnDutToRefRegulation.Size = new System.Drawing.Size(120, 25); this.btnDutToRefRegulation.TabIndex = 11; this.btnDutToRefRegulation.Text = "Start Regulation"; this.btnDutToRefRegulation.UseVisualStyleBackColor = true; @@ -492,8 +675,10 @@ this.tbxDutPulsesMeasured.Location = new System.Drawing.Point(164, 51); this.tbxDutPulsesMeasured.Name = "tbxDutPulsesMeasured"; this.tbxDutPulsesMeasured.ReadOnly = true; + this.tbxDutPulsesMeasured.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxDutPulsesMeasured.Size = new System.Drawing.Size(60, 20); this.tbxDutPulsesMeasured.TabIndex = 75; + this.tbxDutPulsesMeasured.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lblPulseVolumeCmRelation // @@ -510,8 +695,10 @@ this.tbxRefCalibrationResultPulsePerCm.Location = new System.Drawing.Point(164, 102); this.tbxRefCalibrationResultPulsePerCm.Name = "tbxRefCalibrationResultPulsePerCm"; this.tbxRefCalibrationResultPulsePerCm.ReadOnly = true; + this.tbxRefCalibrationResultPulsePerCm.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxRefCalibrationResultPulsePerCm.Size = new System.Drawing.Size(60, 20); this.tbxRefCalibrationResultPulsePerCm.TabIndex = 73; + this.tbxRefCalibrationResultPulsePerCm.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lblWeightScaleVolume // @@ -527,8 +714,10 @@ this.tbxVolumeMeasuredLiters.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxVolumeMeasuredLiters.Location = new System.Drawing.Point(164, 77); this.tbxVolumeMeasuredLiters.Name = "tbxVolumeMeasuredLiters"; + this.tbxVolumeMeasuredLiters.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxVolumeMeasuredLiters.Size = new System.Drawing.Size(60, 20); this.tbxVolumeMeasuredLiters.TabIndex = 8; + this.tbxVolumeMeasuredLiters.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.tbxVolumeMeasuredLiters.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxManualInputVolumeLiters_KeyStoke); this.tbxVolumeMeasuredLiters.Leave += new System.EventHandler(this.tbxManualInputVolumeLiters_Leave); // @@ -547,14 +736,16 @@ this.tbxRefPulsesMeasured.Location = new System.Drawing.Point(164, 26); this.tbxRefPulsesMeasured.Name = "tbxRefPulsesMeasured"; this.tbxRefPulsesMeasured.ReadOnly = true; + this.tbxRefPulsesMeasured.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxRefPulsesMeasured.Size = new System.Drawing.Size(60, 20); this.tbxRefPulsesMeasured.TabIndex = 69; + this.tbxRefPulsesMeasured.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // btnManualRefCalibration // - this.btnManualRefCalibration.Location = new System.Drawing.Point(114, 130); + this.btnManualRefCalibration.Location = new System.Drawing.Point(104, 130); this.btnManualRefCalibration.Name = "btnManualRefCalibration"; - this.btnManualRefCalibration.Size = new System.Drawing.Size(110, 25); + this.btnManualRefCalibration.Size = new System.Drawing.Size(120, 25); this.btnManualRefCalibration.TabIndex = 9; this.btnManualRefCalibration.Text = "Start Calibration"; this.btnManualRefCalibration.UseVisualStyleBackColor = true; @@ -592,8 +783,10 @@ this.tbxRefFrequencyHz.Location = new System.Drawing.Point(163, 51); this.tbxRefFrequencyHz.Name = "tbxRefFrequencyHz"; this.tbxRefFrequencyHz.ReadOnly = true; + this.tbxRefFrequencyHz.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxRefFrequencyHz.Size = new System.Drawing.Size(60, 20); this.tbxRefFrequencyHz.TabIndex = 78; + this.tbxRefFrequencyHz.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // chkUseDampedTolerance // @@ -622,8 +815,10 @@ this.tbxActualMeasuredToleranceDutToRef.Location = new System.Drawing.Point(163, 25); this.tbxActualMeasuredToleranceDutToRef.Name = "tbxActualMeasuredToleranceDutToRef"; this.tbxActualMeasuredToleranceDutToRef.ReadOnly = true; + this.tbxActualMeasuredToleranceDutToRef.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxActualMeasuredToleranceDutToRef.Size = new System.Drawing.Size(60, 20); this.tbxActualMeasuredToleranceDutToRef.TabIndex = 77; + this.tbxActualMeasuredToleranceDutToRef.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lblActualFlowRateCmPerHour // @@ -640,8 +835,10 @@ this.tbxActualFlowRateCmPerHour.Location = new System.Drawing.Point(163, 77); this.tbxActualFlowRateCmPerHour.Name = "tbxActualFlowRateCmPerHour"; this.tbxActualFlowRateCmPerHour.ReadOnly = true; + this.tbxActualFlowRateCmPerHour.RightToLeft = System.Windows.Forms.RightToLeft.No; this.tbxActualFlowRateCmPerHour.Size = new System.Drawing.Size(60, 20); this.tbxActualFlowRateCmPerHour.TabIndex = 75; + this.tbxActualFlowRateCmPerHour.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // pictureBox1 // @@ -653,166 +850,6 @@ this.pictureBox1.TabIndex = 86; this.pictureBox1.TabStop = false; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 25); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(123, 13); - this.label1.TabIndex = 83; - this.label1.Text = "Frequency f(period) [Hz]:"; - // - // tbxRefFrequencyFromRefPeriodHz - // - this.tbxRefFrequencyFromRefPeriodHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxRefFrequencyFromRefPeriodHz.Location = new System.Drawing.Point(153, 25); - this.tbxRefFrequencyFromRefPeriodHz.Name = "tbxRefFrequencyFromRefPeriodHz"; - this.tbxRefFrequencyFromRefPeriodHz.ReadOnly = true; - this.tbxRefFrequencyFromRefPeriodHz.Size = new System.Drawing.Size(60, 20); - this.tbxRefFrequencyFromRefPeriodHz.TabIndex = 82; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(10, 76); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(130, 13); - this.label2.TabIndex = 80; - this.label2.Text = "Flow Rate f(period) [m³/h]:"; - // - // tbxRefFlowRateFromRefPeriodCmPerH - // - this.tbxRefFlowRateFromRefPeriodCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxRefFlowRateFromRefPeriodCmPerH.Location = new System.Drawing.Point(153, 74); - this.tbxRefFlowRateFromRefPeriodCmPerH.Name = "tbxRefFlowRateFromRefPeriodCmPerH"; - this.tbxRefFlowRateFromRefPeriodCmPerH.ReadOnly = true; - this.tbxRefFlowRateFromRefPeriodCmPerH.Size = new System.Drawing.Size(60, 20); - this.tbxRefFlowRateFromRefPeriodCmPerH.TabIndex = 81; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(10, 125); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(62, 13); - this.label3.TabIndex = 84; - this.label3.Text = "Period [ms]:"; - // - // tbxRefPeriodMs - // - this.tbxRefPeriodMs.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxRefPeriodMs.Location = new System.Drawing.Point(153, 123); - this.tbxRefPeriodMs.Name = "tbxRefPeriodMs"; - this.tbxRefPeriodMs.ReadOnly = true; - this.tbxRefPeriodMs.Size = new System.Drawing.Size(60, 20); - this.tbxRefPeriodMs.TabIndex = 85; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(169, 9); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(28, 13); - this.label4.TabIndex = 88; - this.label4.Text = "REF"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(232, 9); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(30, 13); - this.label5.TabIndex = 89; - this.label5.Text = "DUT"; - // - // tbxDutPeriodMs - // - this.tbxDutPeriodMs.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxDutPeriodMs.Location = new System.Drawing.Point(220, 123); - this.tbxDutPeriodMs.Name = "tbxDutPeriodMs"; - this.tbxDutPeriodMs.ReadOnly = true; - this.tbxDutPeriodMs.Size = new System.Drawing.Size(60, 20); - this.tbxDutPeriodMs.TabIndex = 92; - // - // tbxDutFrequencyFromDutPeriodHz - // - this.tbxDutFrequencyFromDutPeriodHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxDutFrequencyFromDutPeriodHz.Location = new System.Drawing.Point(220, 25); - this.tbxDutFrequencyFromDutPeriodHz.Name = "tbxDutFrequencyFromDutPeriodHz"; - this.tbxDutFrequencyFromDutPeriodHz.ReadOnly = true; - this.tbxDutFrequencyFromDutPeriodHz.Size = new System.Drawing.Size(60, 20); - this.tbxDutFrequencyFromDutPeriodHz.TabIndex = 91; - // - // tbxDutFlowRateFromDutPeriodCmPerH - // - this.tbxDutFlowRateFromDutPeriodCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxDutFlowRateFromDutPeriodCmPerH.Location = new System.Drawing.Point(220, 74); - this.tbxDutFlowRateFromDutPeriodCmPerH.Name = "tbxDutFlowRateFromDutPeriodCmPerH"; - this.tbxDutFlowRateFromDutPeriodCmPerH.ReadOnly = true; - this.tbxDutFlowRateFromDutPeriodCmPerH.Size = new System.Drawing.Size(60, 20); - this.tbxDutFlowRateFromDutPeriodCmPerH.TabIndex = 90; - // - // grpBoxDebug - // - this.grpBoxDebug.Controls.Add(this.label7); - this.grpBoxDebug.Controls.Add(this.tbxRefFlowRateFromRefFrequencyCmPerH); - this.grpBoxDebug.Controls.Add(this.label6); - this.grpBoxDebug.Controls.Add(this.tbxRefFrequencyDirectHz); - this.grpBoxDebug.Controls.Add(this.label1); - this.grpBoxDebug.Controls.Add(this.tbxDutPeriodMs); - this.grpBoxDebug.Controls.Add(this.tbxRefFlowRateFromRefPeriodCmPerH); - this.grpBoxDebug.Controls.Add(this.tbxDutFrequencyFromDutPeriodHz); - this.grpBoxDebug.Controls.Add(this.label2); - this.grpBoxDebug.Controls.Add(this.tbxDutFlowRateFromDutPeriodCmPerH); - this.grpBoxDebug.Controls.Add(this.tbxRefFrequencyFromRefPeriodHz); - this.grpBoxDebug.Controls.Add(this.label5); - this.grpBoxDebug.Controls.Add(this.tbxRefPeriodMs); - this.grpBoxDebug.Controls.Add(this.label4); - this.grpBoxDebug.Controls.Add(this.label3); - this.grpBoxDebug.Location = new System.Drawing.Point(8, 238); - this.grpBoxDebug.Name = "grpBoxDebug"; - this.grpBoxDebug.Size = new System.Drawing.Size(288, 175); - this.grpBoxDebug.TabIndex = 83; - this.grpBoxDebug.TabStop = false; - this.grpBoxDebug.Text = "Debug"; - this.grpBoxDebug.Visible = false; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(10, 101); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(128, 13); - this.label7.TabIndex = 96; - this.label7.Text = "Flow Rate f(frequ.) [m³/h]:"; - // - // tbxRefFlowRateFromRefFrequencyCmPerH - // - this.tbxRefFlowRateFromRefFrequencyCmPerH.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxRefFlowRateFromRefFrequencyCmPerH.Location = new System.Drawing.Point(153, 99); - this.tbxRefFlowRateFromRefFrequencyCmPerH.Name = "tbxRefFlowRateFromRefFrequencyCmPerH"; - this.tbxRefFlowRateFromRefFrequencyCmPerH.ReadOnly = true; - this.tbxRefFlowRateFromRefFrequencyCmPerH.Size = new System.Drawing.Size(60, 20); - this.tbxRefFlowRateFromRefFrequencyCmPerH.TabIndex = 95; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(10, 52); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(117, 13); - this.label6.TabIndex = 94; - this.label6.Text = "Frequency (direct) [Hz]:"; - // - // tbxRefFrequencyDirectHz - // - this.tbxRefFrequencyDirectHz.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbxRefFrequencyDirectHz.Location = new System.Drawing.Point(153, 50); - this.tbxRefFrequencyDirectHz.Name = "tbxRefFrequencyDirectHz"; - this.tbxRefFrequencyDirectHz.ReadOnly = true; - this.tbxRefFrequencyDirectHz.Size = new System.Drawing.Size(60, 20); - this.tbxRefFrequencyDirectHz.TabIndex = 93; - // // menuStrip1 // this.menuStrip1.Location = new System.Drawing.Point(0, 0); @@ -825,8 +862,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(543, 461); - this.Controls.Add(this.grpBoxDebug); + this.ClientSize = new System.Drawing.Size(543, 460); this.Controls.Add(this.gbxRegulationSetup); this.Controls.Add(this.gbxDutToRefRegulation); this.Controls.Add(this.pictureBox1); @@ -852,13 +888,13 @@ ((System.ComponentModel.ISupportInitialize)(this.picFM2014)).EndInit(); this.gbxRegulationSetup.ResumeLayout(false); this.gbxRegulationSetup.PerformLayout(); + this.gbxBoxDebug.ResumeLayout(false); + this.gbxBoxDebug.PerformLayout(); this.gbxManualRefCalibration.ResumeLayout(false); this.gbxManualRefCalibration.PerformLayout(); this.gbxDutToRefRegulation.ResumeLayout(false); this.gbxDutToRefRegulation.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.grpBoxDebug.ResumeLayout(false); - this.grpBoxDebug.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -925,7 +961,7 @@ private System.Windows.Forms.TextBox tbxDutPeriodMs; private System.Windows.Forms.TextBox tbxDutFrequencyFromDutPeriodHz; private System.Windows.Forms.TextBox tbxDutFlowRateFromDutPeriodCmPerH; - private System.Windows.Forms.GroupBox grpBoxDebug; + private System.Windows.Forms.GroupBox gbxBoxDebug; private System.Windows.Forms.Label label6; private System.Windows.Forms.TextBox tbxRefFrequencyDirectHz; private System.Windows.Forms.Label label7; diff --git a/MiniPrf/Ui/FrmMainMiniPrf.cs b/MiniPrf/Ui/FrmMainMiniPrf.cs index ae4c3a67..24e6a444 100644 --- a/MiniPrf/Ui/FrmMainMiniPrf.cs +++ b/MiniPrf/Ui/FrmMainMiniPrf.cs @@ -90,8 +90,12 @@ namespace Sensus.MiniPrf.Ui // internal reminders of changed items to avoid write access on startup if items are preloaded private Int32 _comPortIdx; private Int32 _addressIdx; - private Int32 _currentOutputDisplayRange_percent; - private Byte _toleranceDisplayAttenuation; + private Int32 _currentOutputDisplayRangeIdx; + + // Reminder of settings in standalone measurement to avoid repeated storage af already stored values + private UInt32 _initialRefPulsesPerCm; + private UInt16 _initialDutPulsesPerCm; + private Byte _initialCurrentOutputAttenuation; /// /// The regulation setup will be stored directly to the FM2014 being able to use it at startup @@ -140,7 +144,7 @@ namespace Sensus.MiniPrf.Ui _fm2014RegulationSetupHasChanged = false; _programConfigSetupHasChanged = false; - grpBoxDebug.Visible = false; + gbxBoxDebug.Visible = false; gbxDutToRefRegulation.Visible = true; gbxRegulationSetup.Visible = true; @@ -165,10 +169,11 @@ namespace Sensus.MiniPrf.Ui { cbxProgramComPort.Items.Add(comPort); } - cbxProgramComPort.Text = cbxProgramComPort.Items[_comPortIdx].ToString(); + + // Select the last address var itemContent = _fm2014Config.Address ?? 1; - for (var idx = 0; idx < cbxFM2014Address.MaxDropDownItems; idx++) + for (var idx = 0; idx < cbxFM2014Address.Items.Count; idx++) { if (!cbxFM2014Address.Items[idx].ToString().Equals(itemContent.ToString())) continue; @@ -177,12 +182,13 @@ namespace Sensus.MiniPrf.Ui break; } + // Select the current output range itemContent = _fm2014Config.CommonCurrentOutputDisplayRangeNominal_percent; - for (var idx = 0; idx < cbxToleranceDisplayRange.MaxDropDownItems; idx++) + for (var idx = 0; idx < cbxToleranceDisplayRange.Items.Count; idx++) { if (!cbxToleranceDisplayRange.Items[idx].ToString().Equals(itemContent.ToString())) continue; - _currentOutputDisplayRange_percent = idx; + _currentOutputDisplayRangeIdx = idx; cbxToleranceDisplayRange.SelectedItem = cbxToleranceDisplayRange.Items[idx]; break; } @@ -230,11 +236,13 @@ namespace Sensus.MiniPrf.Ui gbxDutToRefRegulation.Text = Resources.StrGbxDutToRefRegulation; lblActualFlowRateCmPerHour.Text = Resources.StrLblActualMeasuredFlowRate; tbxActualFlowRateCmPerHour.Text = ""; + tbxActualFlowRateCmPerHour.BackColor = ColorStandardDisplayField; lblActualMeasuredTolerance.Text = Resources.StrLblActualMeasuredToleranceDutToRef; tbxActualMeasuredToleranceDutToRef.Text = ""; chkUseDampedTolerance.Text = Resources.StrChkUseDampedTolerance; btnDutToRefRegulation.Text = Resources.StrBtnStartRegulation; tbxRefFrequencyHz.Text = ""; + tbxRefFrequencyHz.BackColor = ColorStandardDisplayField; // Process status lblActualProcess.Text = Resources.StrLblProcessStatus; @@ -267,9 +275,16 @@ namespace Sensus.MiniPrf.Ui _programConfigSetupHasChanged = false; _fm2014Config.SharedSerialPort = cbxProgramComPort.Text; - _fm2014Config.Address = _addressIdx; - _fm2014Config.CommonCurrentOutputDisplayRangeNominal_percent = _currentOutputDisplayRange_percent; - + if (int.TryParse(cbxFM2014Address.SelectedItem.ToString(), out var address)) + { + _fm2014Config.Address = address; + } + if (int.TryParse(cbxToleranceDisplayRange.SelectedItem.ToString(), out var tolerancePercent) + && (tolerancePercent == FM2014.CURRENT_OUTPUT_DISPLAY_RANGE_STANDARD_NOMINAL_percent || + tolerancePercent == FM2014.CURRENT_OUTPUT_DISPLAY_RANGE_EXTENDED_NOMINAL_percent)) + { + _fm2014Config.CommonCurrentOutputDisplayRangeNominal_percent = tolerancePercent; + } _fm2014Config.Update(); })); } @@ -759,31 +774,34 @@ namespace Sensus.MiniPrf.Ui LogText($"{resp.AnswerStr}: {resp.IntValue:D} {resp.Unit}"); switch (resp.CmdName) { - case CmdName.CMD_REF_GET_PLS_CTR: - case CmdName.CMD_REF_GET_PLS_CTR_BU: + case CmdName.CmdGetRefPulsesCounted: + case CmdName.CmdGetRefPulsesCountedBackup: tbxRefPulsesMeasured.Text = $@"{resp.IntValue:D}"; break; - case CmdName.CMD_DUT_GET_PLS_CTR: - case CmdName.CMD_DUT_GET_PLS_CTR_BU: + case CmdName.CmdGetDutPulsesCounted: + case CmdName.CmdGetDutPulsesCountedBackup: tbxDutPulsesMeasured.Text = $@"{resp.IntValue:D}"; break; - case CmdName.CMD_REF_LPP_SCALE: + case CmdName.CmdSetRefPulsesPerCm: tbxRefPulsesPerCm.Text = $@"{resp.IntValue:D}"; + _initialRefPulsesPerCm = (UInt32)resp.IntValue; break; - case CmdName.CMD_DUT_LPP_SCALE: + case CmdName.CmdSetDutPulsesPerCm: tbxDutPulsesPerCm.Text = $@"{resp.IntValue:D}"; + _initialDutPulsesPerCm = (UInt16)resp.IntValue; break; - case CmdName.CMD_MEAS_SET_ATTN: + case CmdName.CmdSetCurrentOutputAttenuation: var idx = cbxToleranceDisplayAttenuation.FindString($@"{resp.IntValue}"); cbxToleranceDisplayAttenuation.SelectedIndex = idx; + _initialCurrentOutputAttenuation = (Byte)resp.IntValue; break; - case CmdName.CMD_GET_REF_FREQU: + case CmdName.CmdGetRefFrequency: tbxRefFrequencyHz.Text = $@"{resp.IntValue:D}"; tbxRefFrequencyDirectHz.Text = $@"{resp.IntValue:D}"; tbxRefFrequencyHz.BackColor = statusColor; tbxActualFlowRateCmPerHour.BackColor = statusColor; break; - case CmdName.CMD_RST_MEAS: + case CmdName.CmdResetMeasurement: // Immediately lock all buttons and input fields until reset is finished SetFM2014AccessLocked(); // Check countdown of reset method @@ -798,36 +816,36 @@ namespace Sensus.MiniPrf.Ui LogText($"{resp.AnswerStr}: {resp.DoubleValue:F2} {resp.Unit}"); switch (resp.CmdName) { - case CmdName.CMD_GET_UDTLC: - case CmdName.CMD_GET_DTLC: + case CmdName.CmdGetDutToRefToleranceUndamped: + case CmdName.CmdGetDutToRefToleranceDamped: tbxActualMeasuredToleranceDutToRef.Text = $@"{resp.DoubleValue:F2}"; tbxActualMeasuredToleranceDutToRef.BackColor = statusColor; break; - case CmdName.CMD_REF_SET_SCALE: + case CmdName.CmdRefToDutScale: tbxScaleRefToDut.Text = $@"{resp.DoubleValue:F4}"; break; // DEBUG - case CmdName.CMD_GET_REF_PERIOD: + case CmdName.CmdGetRefPeriod: tbxRefPeriodMs.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_GET_DUT_PERIOD: + case CmdName.CmdGetDutPeriod: tbxDutPeriodMs.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_CAL_FREQU_REF_PERIOD: + case CmdName.CmdCalculatedFrequRefPeriod: tbxRefFrequencyFromRefPeriodHz.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_CAL_FREQU_DUT_PERIOD: + case CmdName.CmdCalculatedFrequencyDutPeriod: tbxDutFrequencyFromDutPeriodHz.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_CAL_FLOW_REF_FREQU: + case CmdName.CmdCalculatedFlowRefFrequ: tbxRefFlowRateFromRefFrequencyCmPerH.Text = $@"{resp.DoubleValue:F3}"; // TODO THW Check if the actual flow shall be taken based on 'REF Frequency' tbxActualFlowRateCmPerHour.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_CAL_FLOW_REF_PERIOD: + case CmdName.CmdCalculatedFlowRefPeriod: tbxRefFlowRateFromRefPeriodCmPerH.Text = $@"{resp.DoubleValue:F3}"; break; - case CmdName.CMD_CAL_FLOW_DUT_PERIOD: + case CmdName.CmdCalculatedFlowDutPeriod: tbxDutFlowRateFromDutPeriodCmPerH.Text = $@"{resp.DoubleValue:F3}"; break; @@ -879,30 +897,13 @@ namespace Sensus.MiniPrf.Ui _startTime = DateTimeOffset.UtcNow; Invoke(new Action(() => { - if (FM2014.SharedCyclicMeasSequ == CyclicMeasSequ.IDLE) + if (FM2014.SharedCyclicMeasSequ == CyclicMeasSequ.idle) { if (FM2014.RegisteredFm2014s == null || FM2014.RegisteredFm2014s.Count == 0) return; - // Take the settings from the inputs - UInt32 refPulses_per_cm = 1000; - UInt16 dutPulses_per_cm = 100; - UInt16 doublePulseDeadtime_ms = 0; - if (int.TryParse(tbxRefPulsesPerCm.Text, out var pulses_per_cm) && - FM2014.PULSES_PER_CM_REGULATION_SETUP_MIN <= pulses_per_cm && - FM2014.REF_PULSES_PER_CM_REGULATION_INPUT_MAX >= pulses_per_cm) - { - refPulses_per_cm = (UInt32)pulses_per_cm; - } - if (int.TryParse(tbxDutPulsesPerCm.Text, out pulses_per_cm) && - FM2014.PULSES_PER_CM_REGULATION_SETUP_MIN <= pulses_per_cm && - FM2014.PULSES_PER_CM_REGULATION_SETUP_MAX >= pulses_per_cm) - { - dutPulses_per_cm = (UInt16)pulses_per_cm; - } - - if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms, - _toleranceDisplayAttenuation)) + if (FM2014.RegulationMeasurement(Fm2014.RefPulses_per_cm, Fm2014.DutPulses_per_cm, + Fm2014.DoublePulseDeadtime_ms, Fm2014.CurrentOutputAttenuation)) { _autoProgressBar = true; ActionControl(true); @@ -912,11 +913,10 @@ namespace Sensus.MiniPrf.Ui } else { - _autoProgressBar = false; // Deactivate the button temporary to avoid repeated execution as the reset takes a certain time + _autoProgressBar = false; btnDutToRefRegulation.Enabled = false; FM2014.ResetHardwareAllDevices(); - ActionControl(false); btnDutToRefRegulation.Text = Resources.StrBtnStartRegulation; } })); @@ -933,7 +933,7 @@ namespace Sensus.MiniPrf.Ui _startTime = DateTimeOffset.UtcNow; Invoke(new Action(() => { - if (FM2014.SharedCyclicMeasSequ == CyclicMeasSequ.IDLE) + if (FM2014.SharedCyclicMeasSequ == CyclicMeasSequ.idle) { tbxRefPulsesMeasured.Text = ""; tbxDutPulsesMeasured.Text = ""; @@ -954,8 +954,8 @@ namespace Sensus.MiniPrf.Ui else { // Deactivate the button temporary to avoid repeated execution as the reset takes a certain time - btnManualRefCalibration.Enabled = false; _autoProgressBar = false; + btnManualRefCalibration.Enabled = false; FM2014.ResetHardwareAllDevices(); } })); @@ -969,18 +969,19 @@ namespace Sensus.MiniPrf.Ui /// /// - Initial. /// - private void cbxFM2014BaseSettings_SelectedValueChanged(Object sender, EventArgs e) + private void cbxProgramSettings_Changed(Object sender, EventArgs e) { Invoke(new Action(() => { - if (_currentOutputDisplayRange_percent != cbxToleranceDisplayRange.SelectedIndex || + if (_currentOutputDisplayRangeIdx != cbxToleranceDisplayRange.SelectedIndex || _addressIdx != cbxFM2014Address.SelectedIndex || _comPortIdx != cbxProgramComPort.SelectedIndex) { - _currentOutputDisplayRange_percent = cbxToleranceDisplayRange.SelectedIndex; + _currentOutputDisplayRangeIdx = cbxToleranceDisplayRange.SelectedIndex; _addressIdx = cbxFM2014Address.SelectedIndex; _comPortIdx = cbxProgramComPort.SelectedIndex; StoreProgramConfiguration(); + Init(); } })); } @@ -1079,7 +1080,7 @@ namespace Sensus.MiniPrf.Ui /// /// /// - /// + /// /// - Initial. /// private void tbxRefPulsesPerCm_Leave(Object sender, EventArgs e) @@ -1114,15 +1115,24 @@ namespace Sensus.MiniPrf.Ui return; } + tbxRefPulsesPerCm.BackColor = ColorStandardInputField; + // Check if values have changed and need to be updated in the standalone setup - if (backupPulses_per_cm != pulses_per_cm || tbxRefPulsesPerCm.BackColor == ColorProcessFailed) + if (backupPulses_per_cm != pulses_per_cm && _initialRefPulsesPerCm != pulses_per_cm) { DutToRefRegulationSetupHasChanged(); } + else + { + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; + } } else { tbxRefPulsesPerCm.BackColor = ColorProcessFailed; + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; } })); } @@ -1203,15 +1213,24 @@ namespace Sensus.MiniPrf.Ui return; } + tbxDutPulsesPerCm.BackColor = ColorStandardInputField; + // Check if values have changed and need to be updated in the standalone setup - if (backupPulses_per_cm != Fm2014.DutPulses_per_cm) + if (backupPulses_per_cm != pulses_per_cm && _initialDutPulsesPerCm != pulses_per_cm) { DutToRefRegulationSetupHasChanged(); } + else + { + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; + } } else { tbxDutPulsesPerCm.BackColor = ColorProcessFailed; + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; } })); } @@ -1305,15 +1324,24 @@ namespace Sensus.MiniPrf.Ui tbxRefCalibrationResultPulsePerCm.BackColor = ColorProcessFailed; return; } + tbxVolumeMeasuredLiters.BackColor = ColorStandardInputField; + tbxRefCalibrationResultPulsePerCm.BackColor = ColorStandardInputField; // Check if values have changed and need to be updated in the standalone setup - if (backupPulses_per_cm != Fm2014.RefPulses_per_cm) + if (backupPulses_per_cm != pulses_per_cm && _initialRefPulsesPerCm != pulses_per_cm) { DutToRefRegulationSetupHasChanged(); } + else + { + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; + } } else { + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; tbxVolumeMeasuredLiters.BackColor = ColorProcessFailed; tbxRefCalibrationResultPulsePerCm.BackColor = ColorProcessFailed; tbxRefCalibrationResultPulsePerCm.Text = Resources.StrError; @@ -1331,13 +1359,10 @@ namespace Sensus.MiniPrf.Ui { Invoke(new Action(() => { - grpBoxDebug.Visible = !grpBoxDebug.Visible; + gbxBoxDebug.Visible = !gbxBoxDebug.Visible; + gbxRegulationSetup.Visible = !gbxBoxDebug.Visible; if (Fm2014 != null) - Fm2014.RequestDebugInformation = grpBoxDebug.Visible; - - //gbxDutToRefRegulation.Visible = !grpBoxDebug.Visible; - gbxRegulationSetup.Visible = !grpBoxDebug.Visible; - + Fm2014.RequestDebugInformation = gbxBoxDebug.Visible; })); } @@ -1353,15 +1378,21 @@ namespace Sensus.MiniPrf.Ui Invoke(new Action(() => { + //Backup the actual setting to detect changes + var backupAttenuation = Fm2014.CurrentOutputAttenuation; + if (byte.TryParse(cbxToleranceDisplayAttenuation.SelectedItem.ToString(), out var attenuation) && attenuation >= FM2014.CURRENT_OUTPUT_ATTENUATION_MIN && attenuation <= FM2014.CURRENT_OUTPUT_ATTENUATION_MAX && - _toleranceDisplayAttenuation != attenuation) + backupAttenuation != attenuation && _initialCurrentOutputAttenuation != attenuation) { - _fm2014RegulationSetupHasChanged = true; - _toleranceDisplayAttenuation = attenuation; Fm2014.CurrentOutputAttenuation = attenuation; - btnSaveSetupToFm2014.Enabled = true; + DutToRefRegulationSetupHasChanged(); + } + else + { + _fm2014RegulationSetupHasChanged = false; + btnSaveSetupToFm2014.Enabled = false; } })); } diff --git a/MiniPrf/Ui/Properties/Resources.Designer.cs b/MiniPrf/Ui/Properties/Resources.Designer.cs index c329ea41..2c42a2f0 100644 --- a/MiniPrf/Ui/Properties/Resources.Designer.cs +++ b/MiniPrf/Ui/Properties/Resources.Designer.cs @@ -90,7 +90,7 @@ namespace Sensus.MiniPrf.Ui.Properties { } /// - /// Looks up a localized string similar to Save. + /// Looks up a localized string similar to Store in FM2014. /// internal static string StrBtnSaveRegulationSetup { get { diff --git a/MiniPrf/Ui/Properties/Resources.de.resx b/MiniPrf/Ui/Properties/Resources.de.resx index 86b058a6..2bd6f6c4 100644 --- a/MiniPrf/Ui/Properties/Resources.de.resx +++ b/MiniPrf/Ui/Properties/Resources.de.resx @@ -184,7 +184,7 @@ Dämpfung []: - Speichern + In FM2014 Speichern Handkalibrierung REF zu Waage diff --git a/MiniPrf/Ui/Properties/Resources.resx b/MiniPrf/Ui/Properties/Resources.resx index 39803013..51e13c35 100644 --- a/MiniPrf/Ui/Properties/Resources.resx +++ b/MiniPrf/Ui/Properties/Resources.resx @@ -184,7 +184,7 @@ Attenuation []: - Save + Store in FM2014 Manual Calibration REF to Weight-Scale