Reporting CMM Usage - run time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reporting CMM Usage - run time

    This is my solution to get run time of multiple CMMs . I'm using this for a while and had no issues at all.
    It creates CSV file: (date)10/06/14,(time when finished)08:45,(run time)4.9,(shift)1 Shift,(machine)Sheffield 2,(program)T block op 80)
    Shifts are 6AM-2:30PM;2:30PM-11PM;11PM-6AM.
    N: is location on server.

    .........Program.........

    STARTUP =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
    ALIGNMENT/END
    ASSIGN/STR_TIMER=""
    CS10 =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\WAI\PC-DMIS\2013\BAS\TIMER.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/

    .............................................


    your routine here

    ............................................
    CS5 =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\WAI\PC-DMIS\2013\BAS\CMM LOAD.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/
    PROGRAM/END




    .............TIMER.BAS contents...........

    Sub Main

    'connect To PCD program
    Dim ObjApp As Object
    Dim ObjPart As Object
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram


    Dim Vavt As String 'Records Start
    Vavt = Timer


    Dim Vav As Object
    Set Vav = ObjPart.GetVariableValue("STR_TIMER")

    Vav.StringValue = Vavt
    ObjPart.SetVariableValue "STR_TIMER" ,Vav 'returns start time To program

    End Sub


    ........CMM LOAD.BAS contents........

    Sub main
    'connect To PCD program
    Dim ObjApp As Object
    Dim ObjPart As Object
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram

    Dim Varp As String
    Varp = ObjPart.PartName 'Name of run part

    Dim Varm As String
    Varm = "Sheffield 2" 'CMM #

    Dim Vart As String
    Set Vart = ObjPart.GetVariableValue("STR_TIMER")'Reads start time from variable

    Dim Dlx As String 'Current date
    Dlx = DateValue(Now)
    Dly = Format (Dlx , "mm/dd/yy")


    Dim Tts As String'Finish time
    Tts = TimeValue(Now)
    Th = Format (Tts , "h")
    Tm = Format (Tts , "n")
    Td = Th*60+Tm


    Tts = Format(Tts,"hh:nn")

    Dim Tx As String'finding out a shift
    If Td > 360 And Td < 870 Then
    Tx = 1
    ElseIf Td > 870 And Td < 1380 Then
    Tx = 2
    Else
    Tx = 3
    End If

    Dl1 = Format(Date,"yyyy")'Loop For jobs started before midnight (date)
    DL2 =Format(Date,"m")
    Dl3 =Format(Date,"d")

    If Tx = 3 And Td > 1380 Then
    Dly = DateSerial(Dl1,DL2,DL3+1)
    Dly = Format(Dly , "mm/dd/yy")
    End If

    Dim Vnow As Single
    Vnow = Timer

    Dim Vrun As Single
    If Vnow < Vart.StringValue Then'Loop For jobs started before midnight (cycle time)
    Vrun = Vnow + 86400 -Vart.StringValue
    Else
    Vrun = Vnow-Vart.StringValue
    End If

    'Converting seconds To minutes
    Dim Tt As Double
    Tt = Vrun/60

    Tt= Format (Tt ,"00.0")
    Tt = CStr(Tt)


    Dim Ttx As String
    Ttx = Tt

    Dim RunCyc As String
    'Processing data
    RunCyc = Dly+ ","+Tts+","+Ttx +"," +Tx+" Shift"+ ","+Varm+","+Varp

    On Error GoTo skip1
    'Saving new data
    Open "N:\CMM\Data\CMM Load.txt" For Append As #1
    Print #1, RunCyc
    Close #1

    GoTo skip2

    'Emergency Loop
    skip1:
    On Error GoTo skip2

    'Saving new data
    Open "C:\Data\CMM Load 1.txt" For Append As #2
    Print #2, RunCyc
    Close #2

    skip2:

    End Sub

Related Topics

Collapse

Working...
X