Python scripting for PDF reports

ReportUtility methods

Previous  Chapter  Next

 

Methods

 

__init__(self):

 

Initialization.

 


 

createAutoExecutePDFReport(self, Operator, apppath, selection = ""):

 

Pass Command from AutoExecute, e.g. after Download

     

     Args:

        Operator:                the CENPyOlpProgramModifyOperator

        apppath:                the Location of the Caller Script. Needed to find the Images

        selection (optional):        desired List of Selection of Columns (and its Order). Otherwise the pre-defined Columns are taken.

                                 Possible Items : "Name", "MotionType", "Length", "Speed", "Time", "Costs", "CollReach", "Events", "Various"

 


 

createAuxCommandsPDFReport(self, Operator, apppath, selection = ""):

 

Pass Command from Program Dashboard's "Auxiliary Commands"

     

     Args:

        Operator:                the CENPyOlpProgramModifyOperator

        apppath:                the Location of the Caller Script. Needed to find the Images

        selection (optional):        desired List of Selection of Columns (and its Order). Otherwise the pre-defined Columns are taken.

                                 Possible Items : "Name", "MotionType", "Length", "Speed", "Time", "Costs", "CollReach", "Events", "Various"


 

createPDFReport(self, Operator, apppath, repfilepath, selection = ""):

 

Main Method to create the PDF Report

     

     Args:

        Operator:                the CENPyOlpProgramModifyOperator

        apppath:                the Location of the Caller Script. Needed to find the Images

        repfilepath:                the Location of the where the PDF Report should be written.

        selection (optional):        desired Selection of Columns (and its Order). Otherwise the pre-defined Columns are taken.

                                 Possible Items : "Name", "MotionType", "Length", "Speed", "Time", "Costs", "CollReach", "Events", "Various"

 


 

buildReportName(self, programName):

 

Build Report File Name, to be inheritate if customizing desired.

     

     Args:

        programName:                the Process Program Name

     

     Returns:

        str: fileName:                the desired File Name

 


 

defineFont(self)

 

Defines the desired Font Type and size to Globals.

Note : CN & JP are only supported by one unique Font, Size can be adjusted)

 


 

defineColumnTitleWidth(self, columns):

 

Defines the Order of the desired Table Columns.

     Note: internal Column Name and its Place in the Order must be fix

     

     Args:

        columns :                the desired List of Columns in desired Order

                                   Possible Items : "Name", "MotionType", "Length", "Speed", "Time", "Costs", "CollReach", "Events"

     

     Returns:

        strList: headLine   :        the List of the Columns Header Names in desired Order

        strList: colWidth   :        the List of the Columns Width in desired Order

        intList: order      :        the List of the ordered Column Numbers

        int :    totalWidth :        the total Width of all Columns to define Portrait or Landscape Format

 


 

defineColName(self):

 

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColMotionType(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColLength(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColSpeed(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColTime(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColCosts(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColCollReach(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColEvents(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

defineColVarious(self):

 

Defines the Table Header Name and Width of the Item

 

         Returns:

                   str:        the Header Name of the Column

                   int:        the Column Width

 


 

header(self):

 

Defines the common Header of the PDF Report, called from FPDF Base Class

 


 

cenheader(self, Operator, path, portrLands):

 

Defines the customized Header of the PDF Report, underneath common Header

     

     Args:

        Operator :                the CENPyOlpProgramModifyOperator

        path :                        the Location of the Caller Script. Needed to find the Images

        portrLands :                if Report is created in Portrait or Landscape Mode

 


 

cenfooter(self, path, portrLands):

 

Defines the customized Footer of the PDF Report, underneath common Header

     

     Args:

        path :                        the Location of the Caller Script. Needed to find the Images

        portrLands :                if Report is created in Portrait or Landscape Mode

 


 

footer(self):

 

Defines the common Footer of the PDF Report, called from FPDF Base Class

 


 

setCosts(self, cost):

 

Sets the Costs per Meter

     

     Args:

        cost :                        Value of the Costs per Meter


 

setCurrency(self, currency):

 

Sets the desired Currency

     

     Args:

        currency :                the desired Currency

                                       Euro "E"

                                       Dollar "D"

                                       Pound "P"

                                       Yen/Yuan "Y"

 


 

getCurrencyCode(self):

 

Returns the Ascii Code of the desired Currency

        Euro "E", Dollar "D", Pound "P", Yen/Yuan "Y"

     

     Returns:

        int: currency:                Ascii Value of the Currency

 

                                   euroCode = 128

                                   dllrCode = 36

                                   poundCode = 163

                                   yenCode = 165

 


 

setLanguage(self, language):

 

Sets the desired Language

     

     Args:

        language :                the desired NLS Language

                                       english "EN",  german "DE",  french "FR",  chinese "CN",  japanese "JP"

 


 

setHeaderLogo(self, logo):

 

Sets the Logo shown on Reports top/right

     

     Args:

        logo :                        the Name of the Logo File ()

 


 

setFooterLogo(self, logo):

 

Sets the Logo shown on Reports bottom/left

     

     Args:

        logo :                        the Name of the Logo File ()

 


 

body(self, Operator, headLine, colWidths, order):

 

Defines the customized Body of the PDF Report.

     

     Args:

        Operator:                the CENPyOlpProgramModifyOperator

        headLine :                the List of the Columns Header Names

        colWidths :                the List of the Columns Width

        order :                        the List of the ordered Column Numbers

 


 

collectelements(self, Operator, order, costPerMeter):

 

Collect all the necessary Information from the Program and writes it to a List

     

     Args:

        Operator :                the CENPyOlpProgramModifyOperator

        order :                        the List of the ordered Column Numbers

        costPerMeter :                the Value of the Costs per Meter

     

     Returns:

        strList: columns     :        the List of all TPE Informations

        double:  totalLength :        the Summary of all Path Length

        double:  totalCosts  :        the Summary of all Path Costs

 


 

columnOrder(self, order, unsorted):

 

Sorts the complete Range of Columns to the desired Order of the single Columns

     

     Args:

        order    :                        the numeric List of the desired Order

        unsorted :                the complete Range of Information per TPE

     

     Returns:

        strList: sorted:                the List of the sorted and desired Columns per TPE

 


 

header_table(self, Operator):

 

Write a Table with common Program Information

     

     Args:

        Operator :                the CENPyOlpProgramModifyOperator

 


 

intermediateBlockBefore(self, Operator, paramList):

 

Anything between CenHeader and TPE List (Template for Inheritance)

     

     Args:

        Operator :                the CENPyOlpProgramModifyOperator

        paramList :                the List of used Parameters

                                   paramList = [(totalLength)(totalCosts)(costPerMeter)(order.count(6))(currency)

                                                             0            1                  2                    3                    4

 


 

intermediateBlockAfter(self, Operator, paramList):

 

Anything between TPE List and CenFooter (Template for Inheritance)

     

     Args:

        Operator :                the CENPyOlpProgramModifyOperator

        paramList :                the List of used Parameters

 


 

getRGBColours(self, item):

 

Get the RGB Colours for the Table Header Row.

     Can be set in the Report NLS File by "headerrowcolor=176.195.52" (Cenit green)

     

     Args:

        item : the desired Item from NLS File

 

     Returns:

        red   :                        the Portion of RED

        green :                        the Portion of GREEN

        blue  :                        the Portion of BLUE

 


 

colored_table(self, headings, rows, colWidths):

 

Write the Program TPEs Information to the Table

     

     Args:

        headings :                the List of the Table Header

        rows :                        the List of the TPE Information

        colWidths :                the List of the Column Width

 


 

getSpeedEvent(self, eventHandler, opTpe, beforeAfter = -1):

 

Checks the TPE for a Speed Event

     

     Args:

        eventHandler:                The event handler

        opTpe:                        the current tool path element

        beforeAfter:                get only desired Events (before/after/all)

     

     Returns:

        bool:   speedEvent :        Bool True/False if a TPE contains a specific Event

        double:                    speed : the Value of the Speed Event in mm/s

        int:                              insPos : the InsertPosition of the Speed Event before/after

 


 

technoEventsExist(self, eventHandler, opTpes):

 

Checks if program contains Techno Events

     

     Args:

        eventHandler:                The event handler

        opTpes:                        array of the Ops TPEs

     

     Returns:

        bool :                        True/False if a Tool On/Off exists (for Cost Calculation)

 


 

getTechnoEvent(self, eventHandler, opTpe, beforeAfter = -1):

 

Checks the TPE for a Techno Event

     

     Args:

        eventHandler:                The event handler

        opTpE:                        the current tool path element

        beforeAfter:                get only desired Events (before/after/all)

     

     Returns:

        bool: technoEvent :        Bool True/False if a TPE contains a specific Event

        int:    retVal :                an Integer 0=no Event  1=Tool ON  -1=Tool OFF

        int:       insPos :                the InsertPosition of the Techno Event before/after

 


 

getAccuracyEvent(self, eventHandler, opTpe):

 

Checks the TPE for an Accuracy Event

     

     Args:

        eventHandler:                the event handler

        opTpE:                        the current tool path element

     

     Returns:

        int: criteria :                an Criteria Integer  A_OFF=0 A_ON=1 A_JOINTDISTANCE=2 A_DISTANCE=3 A_ORIENTATION=4 A_VELOCITY=5

        double: value :                the Value of the Accuracy

        int:   insPos :                the InsertPosition of the Accuracy Event before/after

 


 

calculateCosts(self, costPerMeter, length, technoState, motionType):

 

Calculates Costs per TPE dependent to TechnoState, MotionType, etc. if desired

Might be inherited for own Calculation.

     

     Args:

        costPerMeter:                the Costs per Meter moving

        length:                        the length of the TPE

        technoState:                1=Tool ON  -1=Tool OFF

        motionType :                the Motion Type  MOTIONTYPE_CIR _LIN _PTP

     

     Returns:

        double: costs :                the Costs of the TPE

 


 

getMotionTypeString(self, operator, opTpe):

 

Get the Motion Type of the TPE (PTP, LIN, CIR)

Might be inherited for own desired Information in PlugIn Script

     

     Args:

        operator:                the CENPyOlpProgramModifyOperator

        opTpe:                        the current tool path element

     

     Returns:

        str: motionTypeStr :        the String of the Motion Type


 

getCollisionReachabilityString(self, operator, opTpe):

 

Get the Collision and/or Reachability of the TPE,

Might be inherited for own desired Information in PlugIn Script

     

     Args:

        operator:                the CENPyOlpProgramModifyOperator

        opTpe:                        the current tool path element

     

     Returns:

        str: collReachStr :        the String of the CollisionReachability


 

getVariousField(self, operator, opTpe):

 

Template, might be inherited for own desired Information in PlugIn Script

     

     Args:

        operator:                the CENPyOlpProgramModifyOperator

        opTpe:                        the current tool path element

     

     Returns:

        str: variousString :        the String for Column "Various"


 

calcLinLength(self, teachHandler, lastTpE, opTpe):

 

Calculates linear tool path length

     

     Args:

        teachHandler:                the teach handler

        lastTpE:                        the last tool path element

        opTpe:                        the current tool path element

     

     Returns:

        double: length :                the linear Length between the last and current TPE


 

calcCircLength(self, teachHandler, lastTpE, opTpe):

 

Calculates linear tool path length

     

     Args:

        teachHandler:                the teach handler

        lastTpE:                        the last tool path element

        opTpe:                        the current tool path element

     

     Returns:

        double: length :                the linear Length between the last and current TPE


 

getVector(self, point1, point2):

 

Gets vector through two points

     

     Args:

        point1:                First point

        point2:                Second point

     

     Returns:

        double:                the Vector between the two Points


 

getVectorLength(self, vector):

 

Calculates vector length

     

     Args:

        vector:                the vector to calculate the length for

     

     Returns:

        double:                the Vector Length


 

getVectorScalar(self, vector1, vector2):

 

Calculates two vectors scalar product

     

     Args:

        vector1:                the first vector

        vector2:                the second vector

     

     Returns:

        double:                the scalar Product of the two given Vectors


 

saveReportAs(self, defaultFileName: str, apppath: str):

 

Calls the usual file save dialog

     

     Args:

        defaultFileName:        default file name

        apppath:                        the Application Path for Pictures and Icons

     

     Returns:

        str: fullpath:                the selected path and file name


 

getReportLocation(self, apppath: str):

 

Calls the Folder select dialog

     

     Args:

        apppath:        the Application Path for Pictures and Icons

     

     Returns:

        str: path:        the selected path


 

extendedSaveUI(self, Operator, defaultFileName, apppath):

 

Extended File Save dialogue with Costs Settings

     

     Args:

        Operator:                the CENPyOlpProgramModifyOperator

        defaultFileName:        the default Filename of the PDF Report

        apppath:                the Location of the Caller Script. Needed to find the Images


 

createDialogueUI(self, window: UserInterface, defaultFileName, defaultDlPath):

 

Create the window elements and functions of extended File Save dialogue

     

     Args:

        window: UserInterface:        the Window Handler

        defaultFileName:        the default Filename of the PDF Report

        defaultDlPath:                the default Location of the PDF Report


 

getsetValues(self, write, inList, myFileName="E2PDFReport.ini"):

 

Read or write settings to the INI file

     

     Args:

        write :                bool for writing = true, reading=false

        inList :                List of Values in Case of writing = true

        myFileName :        optional, default is "E2PDFReport.ini"

     

     Returns:

        strList: outList :        List of Values in Case of reading=false


 


Previous
Previous page
Chapter
Chapter page
Next
Next page