Compile function RDS_LAYER_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$insert RDS_LAYER_EQUATES

Declare function   Database_Services, Error_Services, SRP_JSONX, SRP_JSONX_END, SRP_JSON
Declare subroutine Error_Services, SRP_JSONX, SRP_JSONX_BEGIN, SRP_JSON


GoToService

Return Response or ""

//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------

Service ConvertRecordToJSON(KeyID, Record, itemURL)
    
    jsonRecord    = ''

    If KeyID NE '' then
        If Record EQ '' then Record = Database_Services('ReadDataRow', 'RDS_LAYER', KeyID)
        If Error_Services('NoError') then
            @DICT       = Database_Services('GetTableHandle', 'DICT.RDS_LAYER')
            @ID         = KeyID
            @RECORD     = Record
            If SRP_JSON(objRDSLayer, 'New', 'Object') then
                SRP_JSON(objRDSLayer, 'SetValue', 'keyID', @ID)
                SRP_JSON(objRDSLayer, 'SetValue', 'EpiTime', OCONV(Record<RDS_LAYER_EPI_TIME$>, 'MD1'))
                SRP_JSON(objRDSLayer, 'SetValue', 'DiluentAdjParam', OCONV(Record<RDS_LAYER_DILUENT_ADJ_PARAM$>,'MD2'))
                SRP_JSON(objRDSLayer, 'SetValue', 'DopantFlow', OCONV(Record<RDS_LAYER_DOPANT_FLOW$>,'MD2'))
                SRP_JSON(objRDSLayer, 'SetValue', 'HCLFlow', OCONV(Record<RDS_LAYER_HCL_FLOW$>,'MD2'))
                SRP_JSON(objRDSLayer, 'SetValue', 'BakeTime', OCONV(Record<RDS_LAYER_BAKE_TIME$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'EpiH2Flow', OCONV(Record<RDS_LAYER_EPI_H2_FLOW$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'TCSFlow', OCONV(Record<RDS_LAYER_TCS_FLOW$>, 'MD1'))
                SRP_JSON(objRDSLayer, 'SetValue', 'DCSFlow', OCONV(Record<RDS_LAYER_DCS_FLOW$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'FOffset', OCONV(Record<RDS_LAYER_F_OFFSET$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'SOffset', OCONV(Record<RDS_LAYER_S_OFFSET$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'ROffset', OCONV(Record<RDS_LAYER_R_OFFSET$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'Etch1', OCONV(Record<RDS_LAYER_ETCH1$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'Etch2', OCONV(Record<RDS_LAYER_ETCH2$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'Etch3', OCONV(Record<RDS_LAYER_ETCH3$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'AUX1', OCONV(Record<RDS_LAYER_AUX1$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'AUX2', OCONV(Record<RDS_LAYER_AUX2$>,'[SECONDS_CONV]'))
                SRP_JSON(objRDSLayer, 'SetValue', 'ULTemp', OCONV(Record<RDS_LAYER_UL_TEMP$>,'MD0'))
                SRP_JSON(objRDSLayer, 'SetValue', 'SuscEtch', OCONV(Record<RDS_LAYER_SUSC_ETCH$>,'MD1'))
                jsonRecord = SRP_JSON(objRDSLayer, 'Stringify', 'Styled')
                SRP_JSON(objRDSLayer, 'Release')
                
            end
*            SRP_JsonX_Begin('rdslayer', '{')
*            SRP_JsonX('keyId',@ID)
*            SRP_JsonX('EpiTime', OCONV(Record<RDS_LAYER_EPI_TIME$>, 'MD1'))
*            SRP_JsonX('DiluentAdjParam', OCONV(Record<RDS_LAYER_DILUENT_ADJ_PARAM$>,'MD2'))
*            SRP_JsonX('DopantFlow', OCONV(Record<RDS_LAYER_DOPANT_FLOW$>,'MD2'))
*            SRP_JsonX('HCLFlow', OCONV(Record<RDS_LAYER_HCL_FLOW$>,'MD2'))
*            SRP_JsonX('BakeTime', OCONV(Record<RDS_LAYER_BAKE_TIME$>,'[SECONDS_CONV]'))
*            SRP_JsonX('EpiH2Flow', OCONV(Record<RDS_LAYER_EPI_H2_FLOW$>,'MD0'))
*            SRP_JsonX('TCSFlow', OCONV(Record<RDS_LAYER_TCS_FLOW$>, 'MD1'))
*            SRP_JsonX('DCSFlow', OCONV(Record<RDS_LAYER_DCS_FLOW$>,'MD0'))
*            SRP_JsonX('FOffset', OCONV(Record<RDS_LAYER_F_OFFSET$>,'MD0'))
*            SRP_JsonX('SOffset', OCONV(Record<RDS_LAYER_S_OFFSET$>,'MD0'))
*            SRP_JsonX('ROffset', OCONV(Record<RDS_LAYER_R_OFFSET$>,'MD0'))
*            SRP_JsonX('Etch1', OCONV(Record<RDS_LAYER_ETCH1$>,'[SECONDS_CONV]'))
*            SRP_JsonX('Etch2', OCONV(Record<RDS_LAYER_ETCH2$>,'[SECONDS_CONV]'))
*            SRP_JsonX('Etch3', OCONV(Record<RDS_LAYER_ETCH3$>,'[SECONDS_CONV]'))
*            SRP_JsonX('AUX1', OCONV(Record<RDS_LAYER_AUX1$>,'[SECONDS_CONV]'))
*            SRP_JsonX('AUX2', OCONV(Record<RDS_LAYER_AUX2$>,'[SECONDS_CONV]'))
*            SRP_JsonX('ULTemp', OCONV(Record<RDS_LAYER_UL_TEMP$>,'MD0'))
*            SRP_JsonX('SuscEtch', OCONV(Record<RDS_LAYER_SUSC_ETCH$>,'MD1'))
*            jsonRecord  = SRP_JsonX_End('Pretty')
        end
    end else
        Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
    end
    Response    = jsonRecord
end service


