# Add Scheduler activity in ControlPanel template

# Add ProcessTypes.txt help
dev-linux
Ivan Maslov 5 years ago
parent 18b98d89d3
commit b3ff62e771

@ -16,28 +16,12 @@ gRobotToOrchestratorKeyList = ["Storage",gRobotKeyStr,"RobotToOrchestrator"]
gOrchestratorToRobotResetKeyList = ["Storage",gRobotKeyStr,"OrchestratorToRobotReset"] gOrchestratorToRobotResetKeyList = ["Storage",gRobotKeyStr,"OrchestratorToRobotReset"]
gOrchestratorToRobotResetSafeStopKeyList = gOrchestratorToRobotResetKeyList+["SafeTurnOffBool"] gOrchestratorToRobotResetSafeStopKeyList = gOrchestratorToRobotResetKeyList+["SafeTurnOffBool"]
# Function, which is generate Dict for front-endswith # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def ControlPanelRenderDict(inGSettings): # Activity list
"""result={
"HeaderLeftText":"<Robot name>",
"HeaderRightText":"<header>",
"DataStorageKey":"Robot_Name", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side
"SubheaderText": "State: <span style=\"color:green\">Turned on</span>",
"BodyKeyValueList":[
{"Key":"Session list","Value":""},
{"Key":"Session list","Value":""}
],
"FooterText":"Last update: 9:38:00 09.10.2019",
"FooterButtonX2List":[
{"Text":"Turn on", "Color":"green", "Link":"", "OnClick": lOnClickRunButton.replace("\\","\\\\")},
],
"FooterButtonX1List":[
{"Text":"Kill", "Color":"red", "Link":"", "OnClick": lOnClickForceCloseButton.replace("\\","\\\\")}
]
}"""
# START :: Create activities :: START #
## Robot START (create RDP session, send CMD to start process) ## Robot START (create RDP session, send CMD to start process)
lActivityROBOTStartList = [ gActivityROBOTStartTimeHH_MMStr = "03:00" # Time "HH:MM" [Server time] to execute activity, example "05:10"
gActivityROBOTStartWeekdayList = [0,1,2,3,4] # WeekdayList when atcivity is starting, default [0,1,2,3,4,5,6]
gActivityROBOTStartList = [
{ # Start RDP Session { # Start RDP Session
"DefNameStr":"RDPSessionConnect", # Function name in RobotRDPActive.Processor "DefNameStr":"RDPSessionConnect", # Function name in RobotRDPActive.Processor
"ArgList":[], # Args list "ArgList":[], # Args list
@ -49,11 +33,10 @@ def ControlPanelRenderDict(inGSettings):
"ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr": f"{gRobotProcessNameWOEXEStr}.exe", "inFilePathStr": gRobotStartFilePathStr, "inFlagGetAbsPathBool": False} # Args dictionary "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr": f"{gRobotProcessNameWOEXEStr}.exe", "inFilePathStr": gRobotStartFilePathStr, "inFlagGetAbsPathBool": False} # Args dictionary
} }
] ]
lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(lActivityROBOTStartList)});".replace("\"","\'") ## Robot FORCE STOP (send CMD to stop process, logoff)
## Robot SAFE STOP (SAFE STOP COMMAND (FROM ROBOT RULES), Logoff must do robot when safe turn off) gActivityROBOTStopTimeHH_MMStr = "08:00" # Time "HH:MM" [Server time] to execute activity, example "05:10"
lActivityROBOTSafeStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(gOrchestratorToRobotResetSafeStopKeyList)},true);".replace("\"","\'") gActivityROBOTStopWeekdayList = [0,1,2,3,4] # WeekdayList when atcivity is starting, default [0,1,2,3,4,5,6]
## Robot FORCE STOP (create RDP session, send CMD to start process) gActivityROBOTStopList = [
lActivityROBOTStopList = [
{ # Kill process { # Kill process
"DefNameStr":"RDPSessionProcessStop", # Function name in RobotRDPActive.Processor "DefNameStr":"RDPSessionProcessStop", # Function name in RobotRDPActive.Processor
"ArgList":[], # Args list "ArgList":[], # Args list
@ -65,7 +48,33 @@ def ControlPanelRenderDict(inGSettings):
"ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr} # Args dictionary "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr} # Args dictionary
} }
] ]
lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(lActivityROBOTStopList)});".replace("\"","\'") # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Function, which is generate Dict for front-endswith
def ControlPanelRenderDict(inGSettings):
"""result={
"HeaderLeftText":"<Robot name>",
"HeaderRightText":"<header>",
"DataStorageKey":"Robot_Name", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side
"SubheaderText": "State: <span style=\"color:green\">Turned on</span>",
"BodyKeyValueList":[
{"Key":"Session list","Value":""},
{"Key":"Session list","Value":""}
],
"FooterText":"Last update: 9:38:00 09.10.2019",
"FooterButtonX2List":[
{"Text":"Turn on", "Color":"green", "Link":"", "OnClick": lOnClickRunButton.replace("\\","\\\\")},
],
"FooterButtonX1List":[
{"Text":"Kill", "Color":"red", "Link":"", "OnClick": lOnClickForceCloseButton.replace("\\","\\\\")}
]
}"""
# START :: Create activities :: START #
## Robot START (create RDP session, send CMD to start process)
lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStartList)});".replace("\"","\'")
## Robot SAFE STOP (SAFE STOP COMMAND (FROM ROBOT RULES), Logoff must do robot when safe turn off)
lActivityROBOTSafeStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(gOrchestratorToRobotResetSafeStopKeyList)},true);".replace("\"","\'")
## Robot FORCE STOP (send CMD to stop process, logoff)
lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStopList)});".replace("\"","\'")
# END :: Create activities :: END # # END :: Create activities :: END #
# START :: Init result dict template :: START # # START :: Init result dict template :: START #
# lBodyKeyValue_r3_start=f'<a onclick="{lActivityROBOTStartEscaped}" style=\"color:green\">Start</a>' # lBodyKeyValue_r3_start=f'<a onclick="{lActivityROBOTStartEscaped}" style=\"color:green\">Start</a>'
@ -117,8 +126,32 @@ def TechDictKeyList_ItemGet(inDict, inKeyList, inDefault={}):
lResult=inDefault lResult=inDefault
return lResult return lResult
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Scheduler to start/stop process
## Start ROBOT at time
lActivityTimeItemRobotStart = {
"TimeHH:MM": gActivityROBOTStartTimeHH_MMStr, #Time [HH:MM] to trigger activity
"WeekdayList": gActivityROBOTStartWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
"Activity":{
"Type": "GlobalDictKeyListValueSet", #Activity type
"KeyList": ['RobotRDPActive','ActivityList'] # RobotRDP Active ActivityList
"Value": gActivityROBOTStartList # ActivityList - see upper
}
}
## Force stop ROBOT at time
lActivityTimeItemRobotStop = {
"TimeHH:MM": gActivityROBOTStopTimeHH_MMStr, #Time [HH:MM] to trigger activity
"WeekdayList": gActivityROBOTStopWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
"Activity":{
"Type": "GlobalDictKeyListValueSet", #Activity type
"KeyList": ['RobotRDPActive','ActivityList'] # RobotRDP Active ActivityList
"Value": gActivityROBOTStopList # ActivityList - see upper
}
}
#Orchestrator settings update #Orchestrator settings update
def SettingsUpdate(inGSettings): def SettingsUpdate(inGSettings):
#Add RobotRDPActive in control panel #Add RobotRDPActive in control panel
inGSettings["ControlPanelDict"]["RobotList"].append({"RenderFunction": ControlPanelRenderDict, "KeyStr": gControlPanelKeyStr}) inGSettings["ControlPanelDict"]["RobotList"].append({"RenderFunction": ControlPanelRenderDict, "KeyStr": gControlPanelKeyStr})
# Add scheduler activity in Scheduler.ActivityTimeList
inGSettings["Scheduler"]["ActivityTimeList"].append(lActivityTimeItemRobotStart)
inGSettings["Scheduler"]["ActivityTimeList"].append(lActivityTimeItemRobotStop)
return inGSettings return inGSettings

@ -0,0 +1,69 @@
#Input arg
# [
# {
# "Type": <RemoteMachineProcessingRun>,
# host: <localhost>,
# port: <port>,
# bodyObject: <object dict, int, str, list>
# },
# {
# "Type": "CMDStart",
# "Command": ""
# },
# {
# "Type": "OrchestratorRestart"
# },
# {
# "Type": "GlobalDictKeyListValueSet",
# "KeyList": ["key1","key2",...],
# "Value": <List, Dict, String, int>
# },
# {
# "Type": "GlobalDictKeyListValueAppend",
# "KeyList": ["key1","key2",...],
# "Value": <List, Dict, String, int>
# },
# {
# "Type": "GlobalDictKeyListValueGet",
# "KeyList": ["key1","key2",...]
# },
# {
# "Type":"ProcessStart",
# "Path":"",
# "ArgList":[]
#
# },
# {
# "Type":"ProcessStartIfTurnedOff",
# "CheckTaskName":"", #Check if current task name is not active (then start process),
# "Path":"",
# "ArgList":[]
#
# },
# {
# "Type":"ProcessStop",
# "Name":"",
# "FlagForce":True,
# "User":"" #Empty, user or %username%
# },
# {
# "Type":"PythonStart",
# "ModuleName":"",
# "FunctionName":"",
# "ArgList":[],
# "ArgDict":{}
# },
# {
# "Type":"WindowsLogon",
# "Domain":"",
# "User":"",
# "Password":""
# # Return "Result": True - user is logged on, False - user is not logged on
# }
# ]
##################################
#Output result
# <input arg> with attributes:
# "DateTimeUTCStringStart"
# "DateTimeUTCStringStop"
# "Result"
Loading…
Cancel
Save