open-insight/LSL2/STPROC/REACT_SERVS_SERVICES.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

164 lines
6.8 KiB
Plaintext

Compile function React_Servs_Services(@Service, @Params)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : React_Servs_Services
Description : Handler program for all module related services.
Notes : The generic parameters should contain all the necessary information to process the services. Often
this will be information like the data Record and Key ID.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
History : (Date, Initials, Notes)
08/02/22 djs Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert LOGICAL
$Insert RLIST_EQUATES
$Insert REACT_SERVS_EQUATES
Declare function Database_Services, Error_Services, SRP_JSON, React_Servs_Services
Declare subroutine SRP_JSON, Error_Services, React_Servs_Services
GoToService
Return Response or ""
//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------
Service GetReactMetrics()
Response = ''
ReactMetrics = Xlate('APP_INFO', 'REACTOR_METRICS', 1, 'X', '')
Swap @VM with @FM in ReactMetrics
Response = ReactMetrics
end service
Service GetAssociatedMetrics(ServID)
AssocMetrics = Xlate('REACT_SERVS', ServID, REACT_SERVS_ASSOC_METRICS$, 'X', '')
Response = AssocMetrics
end service
Service GetReactServs()
Response = ''
Query = 'SELECT REACT_SERVS BY SERV_ID'
GoSub ClearCursors
RList(Query, TARGET_ACTIVELIST$, '', '', '')
If Not(Get_Status(ErrCode)) then
EOF = False$
Loop
ReadNext KeyID else EOF = True$
Until EOF
Response<-1> = KeyID
Repeat
end
End Service
Service ConvertRecordToJSON(KeyID, Record, itemURL)
jsonRecord = ''
If KeyID NE '' then
If Record EQ '' then Record = Database_Services('ReadDataRow', 'REACT_SERVS', KeyID)
If Error_Services('NoError') then
@DICT = Database_Services('GetTableHandle', 'DICT.REACT_SERVS')
@ID = KeyID
@RECORD = Record
If SRP_JSON(objJSON, 'New', 'Object') then
If SRP_JSON(objReactServ, 'New', 'Object') then
SRP_JSON(objReactServ, 'SetValue', 'keyId', @ID)
SRP_JSON(objReactServ, 'SetValue', 'reactType', {REACT_TYPE})
SRP_JSON(objReactServ, 'SetValue', 'action', {ACTION})
SRP_JSON(objReactServ, 'SetValue', 'description', {DESCRIPTION})
//SRP_JSON(objReactServ, 'SetValue', 'graphiteOrTube', OConv({GRAPHITE_OR_TUBE}, '[GRAPHITE_OR_TUBE_CONV]'))
SRP_JSON(objReactServ, 'SetValue', 'graphiteOrTube', {GRAPHITE_OR_TUBE})
SRP_JSON(objReactServ, 'SetValue', 'inactiveDate', OConv({INACTIVE_DATE}, 'D4/'))
SRP_JSON(objReactServ, 'SetValue', 'injectorChange', {INJECTOR_CHANGE}, 'Boolean')
SRP_JSON(objReactServ, 'SetValue', 'noteRequired', {NOTE_REQ}, 'Boolean')
SRP_JSON(objReactServ, 'SetValue', 'pmDays', {PM_DAYS})
SRP_JSON(objReactServ, 'SetValue', 'reactGas', {REACT_GAS})
SRP_JSON(objReactServ, 'SetValue', 'reactItem', {REACT_ITEM})
SRP_JSON(objReactServ, 'SetValue', 'reactItemDesc', {REACT_ITEM_DESC})
SRP_JSON(objReactServ, 'SetValue', 'reactItemType', {REACT_ITEM_TYPE})
SRP_JSON(objReactServ, 'SetValue', 'reactServCatId', {REACT_SERV_CAT_ID})
SRP_JSON(objReactServ, 'SetValue', 'reactServCatDesc', {REACT_SERV_CAT_DESC})
SRP_JSON(objReactServ, 'SetValue', 'reactSystem', {REACT_SYSTEM})
SRP_JSON(objReactServ, 'SetValue', 'requireArmWandData', {REQ_ARM_WAND_DATA})
SRP_JSON(objReactServ, 'SetValue', 'status', {STATUS})
SRP_JSON(objReactServ, 'SetValue', 'svcDesc', {SVC_DESC})
SRP_JSON(objReactServ, 'SetValue', 'sysDesc', {SYS_DESC})
SRP_JSON(objReactServ, 'SetValue', 'tcChangeService', {TC_CHANGE_SERVICE})
SRP_JSON(objJSON, 'Set', 'reactServ', objReactServ)
SRP_JSON(objReactServ, 'Release')
end
If itemURL NE '' then
// The itemURL was passed in so add HAL+JSON properties.
// Create the _links property and then all link objects needed for this resource.
If SRP_JSON(objLinks, 'New', 'Object') then
// Create a self link.
If SRP_JSON(objLink, 'New', 'Object') then
SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String')
SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String')
SRP_JSON(objLinks, 'Set', 'self', objLink)
SRP_JSON(objLink, 'Release')
end
SRP_JSON(objJSON, 'Set', '_links', objLinks)
SRP_JSON(objLinks, 'Release')
end
// Create the _class property for this resource.
SRP_JSON(objJSON, 'SetValue', '_class', 'resource')
end
jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled')
SRP_JSON(objJSON, 'Release')
end else
Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.')
end
end
end else
Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
end
Response = jsonRecord
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ClearCursors:
For counter = 0 to 8
ClearSelect counter
Next counter
return