Python scripting - Objects

CENPyOlpController

 

Methods

 

GetName(): string

 

o

return

the controller name

 

Returns the controller name.

 

[Example]

contName = olpController.GetName()

 


 

GetManufacturer(): string

 

o

return

the controller manufacturer

 

Returns the controller manufacturer.

 

[Example]

contManufacturer = olpController.GetManufacturer()

 


 

GetActors(itemType: FSItemType, itemSubType: ItemSubType, actorType: FSActorType): list

 

o

itemType

Specifies the item types to be returned

 

o

itemSubType

Specifies the item sub type to be returned

 

o

actorType

Specifies the actor type to be returned

 

o

return

list of CENPyOlpActor objects. Output of all specified actors in this controller

 

Returns the attached actors of specified type.

 

[Example]

   controller = eco.GetController()

   actors = controller.GetActors(FSITEMTYPE_PRODUCTION, ITEM_MACHINE_ROBOT, FSACTOR_NONE)

   actorsCount = len(actors)

   for i in range(0, actorsCount):

      actor = actors[i]

      actorName = actor.GetName()

      actorResourceName = actor.GetResourceName()

      logOperator.LogDebug('actor[' + str(i) +'] actorName = '+ actorName + '; actorResourceName = ' + actorResourceName)

      logOperator.LogDebug('actor[' + str(i) +'] ItemType(): = '+ str(actor.AskItemType()) + '; ItemSubType = ' + str(actor.AskItemSubType()))

 


 

GetSensors(itemType: FSItemType, itemSubType: ItemSubType, sensorType: FSSensorType): list

 

o

itemType

Specifies the item types to be returned

 

o

itemSubType

Specifies the item sub type to be returned, If equal to ItemSubType::SUBITEM_NONE no filtering is done by item subtype

 

o

sensorType

Specifies the sensor type to be returned, If equal to FSSensorType::None, no filtering is done by sensor type

 

o

return

list of CENPyOlpSensor objects. Output of all specified sensors which respect the given filters

 

Gets all sensors of which are on a controlled item.

 

[Example]

   sensors = controller.GetSensors(0, 0, 0)

 


 

GetSignalNumber (signalName: string): int

 

o

signalName

signal name

 

o

return

The signal number of the found signal

 

Searches for the first signal with the given name, found on a controller signal connection for this controller,

 and returns its signal number.

 

 

[Example]

signalA_Num = olpController.GetSignalNumber('signalA')

 


 

GetUuId(): string

 

o

return

current name of the controller

 

Returns the controller unique id.

 

[Example]

cID = olpController.GetUuId()

 


 

GetActiveToolFrameIndex(): int

 

o

return

Returns the index of the active tool frame defined in the unit setup, or -1 if active tool is not set

 

GetActiveToolframeIndex() with lowercase "frame" can also be used.

 

[Example]

activeToolFrameIndex = olpController.GetActiveToolFrameIndex()

 


 

GetActiveBaseFrameIndex(): int

 

o

return

Returns the index of the active base frame defined in the unit setup, or -1 if active tool is not set

 

GetActiveBaseframeIndex() with lowercase "frame" can also be used.

 

[Example]

activeBaseFrameIndex = olpController.GetActiveBaseFrameIndex()

 


 

·

GetActiveToolFrameMatrix(): CENPyOlpMatrix

 

o

return

Returns the matrix of the active tool frame defined in the unit setup

 

GetActiveToolframeMatrix() with lowercase "frame" can also be used.

 

[Example]

activeToolFrameMatrix = olpController.GetActiveToolFrameMatrix()

 


 

·

GetActiveBaseFrameMatrix(): CENPyOlpMatrix

 

o

return

Returns the matrix of the active base frame defined in the unit setup

 

GetActiveBaseframeMatrix() with lowercase "frame" can also be used.

 

[Example]

activeBaseFrameMatrix = olpController.GetActiveBaseFrameMatrix()

 


 

GetResources(itemType: FSItemType, itemSubType: ItemSubType): list

 

o

itemType

Specifies the item type to be returned. If equal to ItemType::ITEM_NONE no filtering is done by item type

 

o

itemSubType

Specifies the item sub type to be returned. If equal to ItemSubType::SUBITEM_NONE no filtering is done by item subtype

 

o

return

list of CENPyOlpResource objects. Output of all specified resources which respect the given filters

 

Gets all resources that are controlled by this controller.

 

[Example]

   resources = controller.GetResources(1, 0)

 


 

IsTeamController(): bool

 

o

return

True if the team controller is selected

 

Returns whether the controller is a team controller.

 

[Example]

   controller = Operator.GetController()

   logging.LogInfo("Is Team controller: " + str(controller.IsTeamController()))

 


 

GetTeamController(): CENPyOlpController

 

o

return

Object of CENPyOlpController class

 

Returns the Team controller to which the current controller is connected. If there is no Team controller, the return value will be None.

 

[Example]

   controller = Operator.GetController()

   if controller.IsTeamController() is False:

      teamController = controller.GetTeamController()

      logging.LogInfo("Team controller name: " + str(teamController.GetName()))

 


 

GetControllers(): list

 

o

return

list of CENPyOlpController objects

 

Gets all controllers connected to the current controller.

 

[Example]

   controller = Operator.GetController()

   connectedControllers = controller.GetControllers()

   for connectedController in connectedControllers:

      logging.LogInfo("Connected controller name: " + str(connectedController.GetName()))

 


 

GetProgramNames(): list

 

o

return

list of string objects

 

Gets a list of program names on this controller.

 

[Example]

   olpController = Operator.GetController()

   allProgramNames = olpController.GetProgramNames()

   for prgName in allProgramNames:

      if prgName == "PRG001":

         allTpes = CENPyOlpProgramModifyOperator.GetProgramTpElementsByName(prgName)

 


 

GetLogicPortByName (portName: string): CENPyOlpPort

 

o

portName

Logic port name to search for

 

o

return

Found Olp port

 

Returns the first logic port found on the current controller with the given name.

 

[Example]

   olpPort = olpController.GetLogicPortByName("TestOutputBool")

 


 

 

GetAttributeByName(name: string):  CENPyOlpAttribute

 

 

o

name

Name of attribute to search for

 

o

return

CENPyOlpAttribute object

 

Gets a user-defined attribute object by the given name.

 

[Example]

   attribObject = olpController.GetAttributeByName("AttributeName")

 


   

GetAttributeIntegerByName(name: string):  CENPyOlpAttributeInt

 

 

o

name

Name of attribute to search for

 

o

return

CENPyOlpAttributeInt object

 

Gets the Integer attribute object by the given name.

 

[Example]

   attribObject = olpController.GetAttributeIntegerByName("AttributeName")

 


   

GetAttributeFloatByName(name: string):  CENPyOlpAttributeDouble

 

 

o

name

Name of attribute to search for

 

o

return

CENPyOlpAttributeDouble object

 

Gets the Float attribute object by the given name.

 

[Example]

   attribObject = olpController.GetAttributeFloatByName("AttributeName")

 


   

GetAttributeStringByName(name: string): CENPyOlpAttributeString

 

 

o

name

Name of attribute to search for

 

o

return

CENPyOlpAttributeString object

 

Gets the String attribute object by the given name.

 

[Example]

   attribObject = olpController.GetAttributeStringByName("AttributeName")

 


   

GetAttributeBoolByName(name: string): CENPyOlpAttributeBool

 

 

o

name

Name of attribute to search for

 

o

return

CENPyOlpAttributeBool object

 

Gets the Bool attribute object by the given name.

 

[Example]

   attribObject = olpController.GetAttributeBoolByName("AttributeName")

 


 

GetOutputDirectory(): string

 

 

o

return

Output directory path

 

Returns the download output directory of the program. First gets the root download directory of an active program, and if it is empty, gets the output directory from the translator.

 

[Example]

   outputDirectoryPath = olpController.GetOutputDirectory()

 


 

CreateProgram(name: string, startStateName: string, isMain: bool): CENPyOlpProgram

 

o

name

Name of the program to create. Optional. If not set, the default naming rule is applied.

 

o

startStateName

Name of the start state to be used or to be created. Optional. In not set the default start state is used.

 

o

isMain

If true, a Main program will be created, otherwise a sub-program. Optional. If not set, the default value is used. Default value: True.

 

o

return

CENPyOlpProgram object

 

Creates a new controller program and sets it active.

 

[Example]

   firstProgram = controller.CreateProgram()

   secondProgram = controller.CreateProgram("NewProgram")

   thirdProgram = controller.CreateProgram("NewProgram", "StartState_NewProgram_1")

   fourthProgram = controller.CreateProgram("NewProgram", "StartState_NewProgram_2", False)

 


 

GetLastGeneratedFilePathsFromDownload(): list

 

o

return

list of strings with absolute paths to the last generated files. It is empty if the download is not done yet.

 

Gets the absolute file paths generated during the last download.

 

[Example]

  downloadPaths = olpController.GetLastGeneratedFilePathsFromDownload()

 


 

GetLastSelectedFilePathsFromUpload(): list

 

o

return

list of strings with absolute paths to the last selected files. It is empty if the upload is not done yet.

 

Gets the absolute file paths selected during the last upload.

 

[Example]

  uploadPaths = olpController.GetLastSelectedFilePathsFromUpload()

 


 

·

DownloadProgramByName (programName: string): DownloadErrorCodes

 

o

programName

Name of the program to find and download, if it exists.

 

o

return

ERRDOWNLOAD_NOERROR if completed successful, error code otherwise

 

Downloads the program specified by its name from the current controller.

 

[Example]

from centypes import *

from cenpylib import *

def ModifyActiveProgram(Operator: CENPyOlpProgramModifyOperator):

   logging = Operator.GetLoggerOperator()

   programNameToDownload = "PRG001"

   teamController = Operator.GetController().GetTeamController()

   for counter, controller in enumerate(teamController.GetControllers(), 1):

      controllerName = controller.GetName()

      logging.LogInfo(f"Controller <{counter}> name: {controllerName}")

      error = controller.DownloadProgramByName(programNameToDownload)

      if error is ERRDOWNLOAD_NOERROR:

         logging.LogInfo(f"Program named {programNameToDownload} was successfully downloaded from the controller {controllerName}.")

      else:

         logging.LogError(f"Failed to download program {programNameToDownload} from the controller {controllerName}. Error code: {error}.")

 


 

 

 


Previous
Page précédente
Chapter
Page principale du chapitre
Next
Page suivante