/*
 * SHMPZDataSync.c
 *
 *  Created on: Nov 17, 2025
 *      Author: tummalanr
 */


#include "FreeRTOS.h"
#include "event_groups.h"
#include "queue.h"
#include "AppGlobal.h"
#include "ShmDataSyncExterns.h"




/*!
 *  <!-- Description: -->
 *
 *  \brief
 *          This Function is used for Updating the ISEM Base Module Acyclic Parameter Data in Shared Memory.
 *
 *  <!-- Parameters and return values: -->
 *  \param[in]      pzno        -    Pressure Zone number.
 *                  paramid      -    Specifies the  ParameterId as in Valve_FeatureParamId
 *                  paramwrdata  -    Parameter Data as in usdorwdata
 *  \return     AppRET_T    -
 *                              AppRET_OK       : Success.
 *                              AppSHMUpdateErr : Failure.
 */
AppRET_T    ISEMBase_Acyclic_ParamShmUpdate(uint8_t pzno, Valve_FeatureParamId paramid, usdorwdata  paramwrdata)
{
    AppRET_T sts = AppSHMUpdateErr;

    //DebugP_log("%s pzno[%d] paramid[%d]\r\n",__func__,pzno,paramid);

    sts = pzx_sharemem_acycliclock();
    if(sts != AppRET_OK) {
        return sts;
    }
        switch(paramid)
        {
            case    PZBckplnIdenDeviceType:
                                        PZxACyclic_info[pzno].isembaseserviceobj.identinfo.DeviceType =  paramwrdata.fourbyte;
                                        break;
            case    PZBckplnIdenVendorName:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.VendorName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenVendorId:
                                        PZxACyclic_info[pzno].isembaseserviceobj.identinfo.VendorID = paramwrdata.fourbyte;
                                        break;
            case    PZBckplnIdenDeviceName:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.DeviceName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenDeviceId:
                                        PZxACyclic_info[pzno].isembaseserviceobj.identinfo.DeviceID = paramwrdata.fourbyte;
                                        break;
            case    PZBckplnIdenVariantId:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.VariantID[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenHWRev:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.HWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenSerialNo:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.SlNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenSWPartNo:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.SWPartNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZBckplnIdenSWRev:
                                        strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.identinfo.SWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PZPostErrStatus:
                                        PZxACyclic_info[pzno].isembaseserviceobj.posterrsts = paramwrdata.fourbyte;
                                        break;
            case    PZBckplnVAVoltage:
                                    PZxACyclic_info[pzno].isembaseserviceobj.VAVBVoltage[0u] = paramwrdata.fourbyte;
                                    break;
            case    PZBckplnVBVoltage:
                                    PZxACyclic_info[pzno].isembaseserviceobj.VAVBVoltage[1u] = paramwrdata.fourbyte;
                                    break;
            case    PZBckplnOperatingHours:
                                    PZxACyclic_info[pzno].isembaseserviceobj.opertiontimehr = paramwrdata.fourbyte;
                                    break;
            case    PZBckplnOperatingMins:
                                    PZxACyclic_info[pzno].isembaseserviceobj.opertiontimemin = paramwrdata.twobyte;
                                    break;
            case    PZBckplnMinTemperature:
                                    PZxACyclic_info[pzno].isembaseserviceobj.mintemperature = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PZBckplnMaxTemperature:
                                    PZxACyclic_info[pzno].isembaseserviceobj.maxtemperature = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PZBckplnMesrdTemperature:
                                    PZxACyclic_info[pzno].isembaseserviceobj.measuredtemperature = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PZBckplnMEMLIFECYCLE:
                                    PZxACyclic_info[pzno].isembaseserviceobj.memorylifecycle = paramwrdata.fourbyte;
                                    break;
            case    PZBckplnEDSVERSION:
                                    strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.edsverno[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PZBckplnEDSDATE:
                                    strncpy((char *)&PZxACyclic_info[pzno].isembaseserviceobj.edsverdate[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PZBckplnIsemenable:
                                    PZxACyclic_info[pzno].isembaseserviceobj.moduleenable = paramwrdata.onebyte;
                                    break;
            case    PZslotsenable:
                                    PZxACyclic_info[pzno].isembaseserviceobj.slotsenable = paramwrdata.fourbyte;
                                    break;
            case     PZisemdiagenable:
                                    PZxACyclic_info[pzno].isembaseserviceobj.isemdiagenable = paramwrdata.onebyte;
                                    break;
            case    PZdiagvalveenable:
                                    PZxACyclic_info[pzno].isembaseserviceobj.diagvalveenable = paramwrdata.fourbyte;
                                    break;
            case    PressureZoneId:
                                    PZxACyclic_info[pzno].pressurezoneinfo.PressureZoneId = paramwrdata.onebyte;
                                    //DebugP_log("%s  pzno[%d] PressureZoneId[%d]\r\n",__func__,pzno,PZxACyclic_info[pzno].pressurezoneinfo.PressureZoneId);
                                    break;
            case    PZSlotCount:
                                    PZxACyclic_info[pzno].pressurezoneinfo.SlotCount = paramwrdata.onebyte;
                                    //DebugP_log("%s  pzno[%d] PZSlotCount[%d]\r\n",__func__,pzno,PZxACyclic_info[pzno].pressurezoneinfo.SlotCount);
                                    break;
            case    PZNoOfStationsPresent:
                                    PZxACyclic_info[pzno].pressurezoneinfo.noofStationsPresent = paramwrdata.onebyte;
                                    break;
            case    PZStationCoilAPresence:
                                    PZxACyclic_info[pzno].pressurezoneinfo.StationCoilAPresent = paramwrdata.fourbyte;
                                    break;
            case    PZStationCoilBPresence:
                                    PZxACyclic_info[pzno].pressurezoneinfo.StationCoilBPresent = paramwrdata.fourbyte;
                                    break;
            case    PZIsemDiagPresence:
                                    PZxACyclic_info[pzno].pressurezoneinfo.isemdiagnosticPresent = paramwrdata.onebyte;
                                    break;
            case    PZDiagValvePresenceCount:
                                    PZxACyclic_info[pzno].pressurezoneinfo.diagvalvePresentCnt = paramwrdata.onebyte;
                                    break;
            case    PZDiagValvePresencePosition:
                                    PZxACyclic_info[pzno].pressurezoneinfo.diagvalvepos = paramwrdata.fourbyte;
                                    break;
            case    PZPortedPropValvePresence:
                                    PZxACyclic_info[pzno].pressurezoneinfo.PropTypePresent = paramwrdata.onebyte;
                                    break;
            default:
                        sts = AppSHMUpdateErr;
                        break;
        }//switch(paramid)
        pzx_sharemem_acyclicunlock();

    return AppRET_OK;
}


/*!
 *  <!-- Description: -->
 *
 *  \brief
 *          This Function is used for Updating the ISEM Diage Module Acyclic Parameter Data in Shared Memory.
 *
 *  <!-- Parameters and return values: -->
 *  \param[in]      pzno        -    Pressure Zone number.
 *                  paramid      -    Specifies the  ParameterId as in Valve_FeatureParamId
 *                  paramwrdata  -    Parameter Data as in usdorwdata
 *  \return     AppRET_T    -
 *                              AppRET_OK       : Success.
 *                              AppSHMUpdateErr : Failure.
 */
AppRET_T    ISEMDiag_Acyclic_ParamShmUpdate(uint8_t pzno, Valve_FeatureParamId paramid, usdorwdata  paramwrdata)
{
    AppRET_T sts = AppSHMUpdateErr;

    sts = pzx_sharemem_acycliclock();
    if(sts != AppRET_OK) {
      return sts;
    }

        switch(paramid)
        {
            case    IsemDiagIdenDeviceType:
                                        PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.DeviceType =  paramwrdata.fourbyte;
                                        //DebugP_log("%s-pzno[%d]paramid[%d] [%#x / %#x]\r\n",__func__,pzno,paramid,paramwrdata.fourbyte,PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.DeviceType);
                                        break;
            case    IsemDiagIdenVendorName:
                                        strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.VendorName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        //DebugP_log("%s-pzno[%d]paramid[%d] [%-16.16s]\r\n",__func__,pzno,paramid,&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.VendorName[0]);
                                        break;
            case    IsemDiagIdenVendorId:
                                        PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.VendorID = paramwrdata.fourbyte;
                                        break;
            case    IsemDiagIdenDeviceName:
                                        strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.DeviceName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    IsemDiagIdenDeviceId:
                                        PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.DeviceID = paramwrdata.fourbyte;
                                        break;
            case    IsemDiagIdenVariantId:
                                    strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.VariantID[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    IsemDiagIdenHWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.HWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    IsemDiagIdenSerialNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.SlNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    IsemDiagIdenSWPartNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.SWPartNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    IsemDiagIdenSWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].isemdiagserviceobj.identinfo.SWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    IsemDiagPowerOnMins:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.PowerOnMins = paramwrdata.twobyte;
                                    //DebugP_log("%s-pzno[%d]paramid[%d] PowerOnMins[%#x]\r\n",__func__,pzno,paramid,PZxACyclic_info[pzno].isemdiagserviceobj.PowerOnMins);
                                    break;
            case    IsemDiagPowerOnHours:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.PowerOnHours = paramwrdata.fourbyte;
                                    //DebugP_log("%s-pzno[%d]paramid[%d] PowerOnHours[%#x]\r\n",__func__,pzno,paramid,PZxACyclic_info[pzno].isemdiagserviceobj.PowerOnHours);
                                    break;
            case    IsemDiagOperatingMins:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.OperatingMins = paramwrdata.twobyte;
                                    break;
            case    IsemDiagOperatingHours:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.OperatingHours = paramwrdata.fourbyte;
                                    break;
            case    IsemDiagOperatingTemperature:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.operationalparams.OperatingTemperature = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMsrdAtmosphericPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.operationalparams.MeasuredAtmosphericPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMeasuredSupplyPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.operationalparams.MeasuredSupplyPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMeasuredAuxVoltage:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.operationalparams.MeasuredAuxiliaryVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMeasuredAuxCurrent:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.operationalparams.MeasuredAuxiliaryCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMaxApplSupPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.userconfigparams.MaxApplPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMinApplSupPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.userconfigparams.MinApplPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagApplSupPressureHystres:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.userconfigparams.ApplPressureHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagRatedAuxVoltageHystres:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.userconfigparams.RatedAuxVoltageHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagRatedAuxCurrentHystres:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.userconfigparams.RatedAuxCurrentHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            //Prod Config Params
            case    IsemDiagMaxRatedSupPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.MaxRatedPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMinRatedSupPressure:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.MinRatedPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case     IsemDiagRatedSupPressHystresis:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.RatedPressureHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMaxRatedAuxVoltage:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.MaxRatedVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMinRatedAuxVoltage:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.MinRatedVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagMaxRatedAuxCurrent:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.MaxRatedCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    IsemDiagADCSpanCorrection:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.Adcspan = paramwrdata.twobyte;
                                    break;
            case    IsemDiagAuxCurMesSpanCorrection:
                                    PZxACyclic_info[pzno].isemdiagserviceobj.prodconfigparams.AuxCurMesSpanCorrection = paramwrdata.twobyte;
                                    break;
            default:
                        sts = AppSHMUpdateErr;
                        break;
        }//switch(paramid)
        pzx_sharemem_acyclicunlock();

    return AppRET_OK;

}


/*!
 *  <!-- Description: -->
 *
 *  \brief
 *          This Function is used for Updating the Diag Valve Module Acyclic Parameter Data in Shared Memory.
 *
 *  <!-- Parameters and return values: -->
 *  \param[in]      pzno        -    Pressure Zone number.
 *                  paramid      -    Specifies the  ParameterId as in Valve_FeatureParamId
 *                  paramwrdata  -    Parameter Data as in usdorwdata
 *  \return     AppRET_T    -
 *                              AppRET_OK       : Success.
 *                              AppSHMUpdateErr : Failure.
 */
AppRET_T    DiagValve_Acyclic_ParamShmUpdate(uint8_t pzno, uint8_t dvno, Valve_FeatureParamId paramid, usdorwdata  paramwrdata)
{
    AppRET_T sts = AppSHMUpdateErr;

    if( (dvno >= 1) && (dvno <=24)) {
            dvno -=1u;
    }
    else {
        return AppSHMUpdateErr;
    }

    sts = pzx_sharemem_acycliclock();
    if(sts != AppRET_OK) {
        return sts;
    }

        switch(paramid)
        {
            case    DiagValIdenDeviceType:
                                        PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.DeviceType =  paramwrdata.fourbyte;
                                        break;
            case    DiagValIdenVendorName:
                                        strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.VendorName[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    DiagValIdenVendorId:
                                        PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.VendorID = paramwrdata.fourbyte;
                                        break;
            case    DiagValIdenDeviceName:
                                        strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.DeviceName[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    DiagValIdenDeviceId:
                                        PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.DeviceID = paramwrdata.fourbyte;
                                        break;
            case    DiagValIdenVariantId:
                                    strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.VariantID[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    DiagValIdenHWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.HWRev[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    DiagValIdenSerialNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.SlNo[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    DiagValIdenSWPartNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.SWPartNo[0u], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    DiagValIdenSWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].diagvaleservieobj[dvno].identinfo.SWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    DiagValPowerOnMins:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].PowerOnMins = paramwrdata.twobyte;
                                    break;
            case    DiagValPowerOnHours:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].PowerOnHours = paramwrdata.fourbyte;
                                    break;
            case    DiagValOperatingMins:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].OperatingMins = paramwrdata.twobyte;
                                    break;
            case    DiagValOperatingHours:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].OperatingHours = paramwrdata.fourbyte;
                                    break;
            case    DiagValveOperatingTemperature:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].OperatingTemperature = (int16_t)paramwrdata.twobyte;
                                    break;
            //UserConfigParams (DiagVal)
            case    DiagValValveSliceFunction:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ValveSliceFunct = paramwrdata.twobyte;
                                    //DebugP_log("%s-pzno[%d]dvno[%d] paramid[DiagValValveSliceFunction] paramwrdata[%#x][%" PRId64 "]ms\r\n",__func__,pzno,dvno,PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ValveSliceFunct,(ClockP_getTimeUsec()/1000));
                                    break;
            case    DiagValValveSlice12Side:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ValveSlice12Side = paramwrdata.twobyte;
                                    //DebugP_log("%s-pzno[%d]dvno[%d] paramid[DiagValValveSlice12Side] paramwrdata[%#x]\r\n",__func__,pzno,dvno,PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ValveSlice12Side);
                                      break;
            case    DiagValPort2PressMonitngDely:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Port2PressMontrDelay = paramwrdata.twobyte;
                                    //DebugP_log("%s-pzno[%d]dvno[%d] paramid[DiagValPort2PressMonitngDely] paramwrdata[%#x]\r\n",__func__,pzno,dvno,PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Port2PressMontrDelay);

                                    break;
            case    DiagValPort4PressMonitngDely:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Port4PressMontrDelay = paramwrdata.twobyte;
                                    break;
            case    DiagValPort2ApplPresCyclRating:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Port2ApplPrsCylRating = paramwrdata.fourbyte;
                                    break;
            case    DiagValPort4ApplPresCyclRating:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Port4ApplPrsCylRating = paramwrdata.fourbyte;
                                    break;
            case     DiagValMaxApplOprPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.MaxApplPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMinApplOprPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.MinApplPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValApplOprPressureHysteresis:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ApplPressureHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValExhaustPressHysteresis:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.ExhaustlPressureHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValRatedAuxVoltageHystersis:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.RatedAuxVoltageHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValValve12ApplCycleRating:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Valve12ApplCyleRating = paramwrdata.fourbyte;
                                    break;
            case    DiagValValve14ApplCycleRating:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].UserConfigparams.Valve14ApplCyleRating = paramwrdata.fourbyte;
                                    break;

            //OperatingParams(DiagVal)Monitor Coils (Intelligent Coil)
            case    DiagValCoil12HitCurrent:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil12HitCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12HitPower:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil12HitPower = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12HoldCurrent:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil12HoldCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12HoldVoltage:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil12HoldVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12HoldPower:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil12HoldPower = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14HitCurrent:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil14HitCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14HitPower:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil14HitPower = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14HoldCurrent:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil14HoldCurrent = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14HoldVoltage:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil14HoldVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14HoldPower:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Coil14HoldPower = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMeasuredAuxSupVoltage:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.MeasuredAuxVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValPort2MeasuredPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Port2MeasuredPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValPort4MeasuredPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Port4MeasuredPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValPort2PressureCycleCounter:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Port2PressureCycleCounter = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValPort4PressureCycleCounter:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Port4PressureCycleCounter = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValValve12CycleCounter:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Valve12CycleCntr = paramwrdata.fourbyte;
                                    break;
            case    DiagValValve14CycleCounter:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].Operatingparams.Valve14CycleCntr = paramwrdata.fourbyte;
                                    break;
            case    DiagValveWarningEventCount:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].WarnEventcount = paramwrdata.twobyte;
                                    break;
            case    DiagValveFaultEventCount:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].FaultEventcount = paramwrdata.twobyte;
                                    break;

            //case    DiagValErrorStatus:
                                    //PZxACyclic_info[pzno].diagvaleservieobj[dvno].ErrorStatus = paramwrdata.onebyte;
                                    //break;

            //Production config implement later******************************
            case    DiagValMaxRatedOprPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.MaxRatedPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMinRatedOpPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.MinRatedPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValRatedOprPressureHystres:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.RatedPressureHyst = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMaxExhaustPressure:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.MaxExhaustPressure = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12MaxRatedHitCur:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.Coil12MaxRatedHitCurnt = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil12MinRatedHitCur:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.Coil12MinRatedHitCurnt = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14MaxRatedHitCur:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.Coil14MaxRatedHitCurnt = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValCoil14MinRatedHitCur:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.Coil14MinRatedHitCurnt = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMaxRatedAuxVoltage:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.MaxRatedVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValMinRatedAuxVoltage:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.MinRatedVoltage = (int16_t)paramwrdata.twobyte;
                                    break;
            case    DiagValADCSpanCorrection:
                                    PZxACyclic_info[pzno].diagvaleservieobj[dvno].ProdConfigparams.Adcspan = paramwrdata.twobyte;
                                    break;
            default:
                        sts = AppSHMUpdateErr;
                        break;
        }//switch(paramid)
        pzx_sharemem_acyclicunlock();

    return AppRET_OK;
}

/*!
 *  <!-- Description: -->
 *
 *  \brief
 *          This Function is used for Updating the Internal PROP Valve Acyclic Parameter Data in Shared Memory.
 *
 *  <!-- Parameters and return values: -->
 *  \param[in]      pzno        -    Pressure Zone number.
 *                  paramid      -    Specifies the  ParameterId as in Valve_FeatureParamId
 *                  paramwrdata  -    Parameter Data as in usdorwdata
 *  \return     AppRET_T    -
 *                              AppRET_OK       : Success.
 *                              AppSHMUpdateErr : Failure.
 */
AppRET_T    IntrPROPValve_Acyclic_ParamShmUpdate(uint8_t pzno, Valve_FeatureParamId paramid, usdorwdata  paramwrdata)
{
    AppRET_T sts = AppSHMUpdateErr;

    sts = pzx_sharemem_acycliclock();
    if(sts != AppRET_OK) {
        return sts;
    }

        switch(paramid)
        {
            case    PropValIdenDeviceType:
                                        PZxACyclic_info[pzno].PropValveservieobj.identinfo.DeviceType =  paramwrdata.fourbyte;
                                        break;
            case    PropValIdenVendorName:
                                        strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.VendorName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PropValIdenVendorId:
                                        PZxACyclic_info[pzno].PropValveservieobj.identinfo.VendorID = paramwrdata.fourbyte;
                                        break;
            case    PropValIdenDeviceName:
                                        strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.DeviceName[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                        break;
            case    PropValIdenDeviceId:
                                        PZxACyclic_info[pzno].PropValveservieobj.identinfo.DeviceID = paramwrdata.fourbyte;
                                        break;
            case    PropValIdenVariantId:
                                    strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.VariantID[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PropValIdenHWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.HWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PropValIdenSerialNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.SlNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PropValIdenSWPartNo:
                                    strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.SWPartNo[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PropValIdenSWRev:
                                    strncpy((char *)&PZxACyclic_info[pzno].PropValveservieobj.identinfo.SWRev[0], (char *)&paramwrdata.str[0],STR_MAX_LEN);
                                    break;
            case    PropValCalibrZeroPressPoint:
                                    PZxACyclic_info[pzno].PropValveservieobj.Calibrationparams.Calibzeropressurepoint = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PropValCalibrSpanPressPoint:
                                    PZxACyclic_info[pzno].PropValveservieobj.Calibrationparams.Calibspanpressurepoint = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PropValBtnStsBitMaskRegister:
                                    PZxACyclic_info[pzno].PropValveservieobj.Calibrationparams.Buttonstsbitmaskreg = paramwrdata.twobyte;
                                    break;
            case    PropValOperatingMins:
                                    PZxACyclic_info[pzno].PropValveservieobj.Operatingparams.OperatingMins = paramwrdata.twobyte;
                                    break;
            case    PropValOperatingHours:
                                    PZxACyclic_info[pzno].PropValveservieobj.Operatingparams.OperatingHours = paramwrdata.fourbyte;
                                    break;
            case    PropValTemperature:
                                    PZxACyclic_info[pzno].PropValveservieobj.Operatingparams.Temperature = paramwrdata.twobyte;
                                    break;
            case    PropValCycleCounter:
                                    PZxACyclic_info[pzno].PropValveservieobj.Operatingparams.CycleCounter = paramwrdata.fourbyte;
                                    break;
            case    PropValControlKP:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.ControlKP = paramwrdata.twobyte;
                                    break;
            case    PropValControlKI:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.ControlKI = paramwrdata.twobyte;
                                    break;
            case    PropValControlKD:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.ControlKD = paramwrdata.twobyte;
                                    break;
            case    PropValSpanAdjust:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.SpanAdjust = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PropValZeroAdjust:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.ZeroAdjust = (int16_t)paramwrdata.twobyte;
                                    break;
            case    PropValLCDBrightness:
                                    PZxACyclic_info[pzno].PropValveservieobj.UserConfigparams.LCDBrightness = paramwrdata.twobyte;
                                    break;
            default:
                        sts = AppSHMUpdateErr;
                        break;
        }//switch(paramid)
        pzx_sharemem_acyclicunlock();


    return AppRET_OK;
}


/*!
 *  <!-- Description: -->
 *
 *  \brief
 *          This Function is used for Getting the Diag Valve Module Curve Data and save in Shared Memory.
 *
 *  <!-- Parameters and return values: -->
 *  \param[in]      pzno        -    Pressure Zone number.
 *
 *                  CurveData  -     Curve Data
 *  \return     AppRET_T    -
 *                              AppRET_OK       : Success.
 *                              AppSHMUpdateErr : Failure.
 */
AppRET_T    DiagValve_CurveData_ShmUpdate(uint8_t pzno, int16_t *CurveData)
{
    AppRET_T sts = AppRET_OK;
    uint8_t  datasize = (DIAGVALVE_CURVEPOINTS) + 1u;

    sts = pzx_sharemem_acycliclock();
    if(sts == AppRET_OK)
    {

        for(uint8_t i = 0u; i < datasize ; i++)
        {
            PZxACyclic_info[pzno].DiagValve_Curve[i] = CurveData[i];
        }
        pzx_sharemem_acyclicunlock();

    }//if(sts == AppRET_OK)
    else
    {
        sts = AppSHMUpdateErr;
    }

return sts;

}

