PC-DMIS crashes after script run

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

  • PC-DMIS crashes after script run

    I made a script with dialog box where operafor fill your name and select and choose machine number and type of part. Everything is passed to variables for report header. My problem is that pcdmis ramdom crashes with program execution. Sometimes it is working with no problems and somethimes script causes pcdmis crash many times. And another strange thing is that sometimes dialog box opened but all listboxes are empty. Please do you have some suggestions, what is the cause of these crashes? Here is the script:

    Sub Main

    Dim App As Object
    Set App = CreateObject ("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object

    Dim strLine As String
    Dim strDefaultText As String

    Open "D:\operator.txt" For Input As #1
    Line Input #1, strLine
    strLine = mid(strLine,2,len(strLine)-3)
    strDefaultText = strLine
    Close #1

    Dim LaserList$(11)
    LaserList(0) = "Laser 1"
    LaserList(1) = "Laser 2"
    LaserList(2) = "Laser 3"
    LaserList(3) = "Laser 4"
    LaserList(4) = "Laser 5"
    LaserList(5) = "Laser 6"
    LaserList(6) = "Laser 7"
    LaserList(7) = "Laser 8"
    LaserList(8) = "Laser 9"
    LaserList(9) = "Laser 10"
    LaserList(10) = "Laser 11"
    LaserList(11) = "Laser 12"

    Dim SeatType$(2)
    SeatType(0) = "LH"
    SeatType(1) = "RH"
    SeatType(2) = "CC"

    Dim Shift$(1)
    Shift(0) = "Ranní"
    Shift(1) = "Noční"

    Begin Dialog DIALOG_1 31,32,135,135,"CMPV"
    Listbox 15,12,30,30, SeatType$(),.seat
    GroupBox 7,3,45,40,"Typ",.GroupBox1
    Listbox 15,60,30,23, Shift$(),.sft
    GroupBox 7,50,45,33,"Směna",.GroupBox2
    Listbox 70,12,48,66, LaserList$(),.laser
    GroupBox 65,3,60,80,"Laser",.GroupBox3
    Text 16,86,30,12, "Jméno:"
    TextBox 16,96,60,12, .name1
    OKButton 18,112,40,14
    CancelButton 80,112,40,14
    End Dialog

    Dim Dialg As DIALOG_1
    Dialg.name1 = strDefaultText

    Dim ShiftTime
    ShiftTime = Hour(Time)
    If ShiftTime >= 6 And ShiftTime < 18 Then
    Dialg.sft = 0
    Else
    Dialg.sft = 1
    End If

    Dim buttonval As Integer
    buttonval = Dialog(Dialg)

    Dim Opr
    Opr = Dialg.name1
    Open "D:\operator.txt" For Output As #1
    Write #1, Opr
    Close #1

    Dim SeatTpe As String
    Dim LaserNum As String
    Dim ShiftName As String

    If buttonval = 0 Then
    MsgBox "Cancel"
    Else
    Select Case Dialg.seat
    Case 0
    SeatTpe = "LH"
    Case 1
    SeatTpe = "RH"
    Case 2
    SeatTpe = "CC"
    End Select
    Select Case Dialg.laser
    Case 0
    LaserNum = "Laser 1"
    Case 1
    LaserNum = "Laser 2"
    Case 2
    LaserNum = "Laser 3"
    Case 3
    LaserNum = "Laser 4"
    Case 4
    LaserNum = "Laser 5"
    Case 5
    LaserNum = "Laser 6"
    Case 6
    LaserNum = "Laser 7"
    Case 7
    LaserNum = "Laser 8"
    Case 8
    LaserNum = "Laser 9"
    Case 9
    LaserNum = "Laser 10"
    Case 10
    LaserNum = "Laser 11"
    Case 11
    LaserNum = "Laser 12"
    End Select

    Select Case Dialg.sft
    Case 0
    ShiftName = "R"
    Case 1
    ShiftName = "N"
    End Select


    Dim bln

    For Each Cmd In Cmds
    If Cmd.Type = ASSIGNMENT Then
    If Cmd.GetText(DEST_EXPR,0) = "SEAT" Then
    bln = Cmd.PutText("""" + SeatTpe + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    If Cmd.GetText(DEST_EXPR,0) = "LASER" Then
    bln = Cmd.PutText("""" + LaserNum + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    If Cmd.GetText(DEST_EXPR,0) = "NAME" Then
    bln = Cmd.PutText("""" + Opr + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    If Cmd.GetText(DEST_EXPR,0) = "SHIFT" Then
    bln = Cmd.PutText("""" + ShiftName + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    End If
    Next Cmd
    End If
    End Sub

  • #2
    Why do you modify the ASSIGN commands? Why not use GetVariableValue and SetVariableValue instead in the script?

    Which version of PC-DMIS?

    How long is PC-DMIS run between restarts? Do you restart only after crashes? My recommendation to customers is to restart PC-DMIS at least each shift start, to minimize problems with resource leaks. The later versions are better, some older versions worse. It also depends on what the program is doing...
    AndersI
    SW support - Hexagon Metrology Nordic AB

    Comment


    • Robert Hulman
      Robert Hulman commented
      Editing a comment
      We restart Pc dmis each shift at least and we use version 2017 R1

  • #3
    The Get/SetVariableValue only changes the value of the variable, not the actual command in the program. Maybe OP wants it changed so they have traceability or something?
    PC-DMIS CAD++ 2o19 R1 SP4

    Comment


    • AndersI
      AndersI commented
      Editing a comment
      He's writing things to a file too, so I don't see the big need for changing the program. Also, if he's changing the program, it is imperative that the ASSIGN statements come *after* the script call, or the changes will not be seen in the current run. Also, I'm allergic to selfmodifying programs...

    • vpt.se
      vpt.se commented
      Editing a comment
      Missed that one, but yes - one of them feels redundant unless "operator.txt" is read by something else.

    • Robert Hulman
      Robert Hulman commented
      Editing a comment
      Yes i write operators name to txt to hold operators name during shift, because without that i would have to type the name each run

  • #4
    I'll say it again, but I'd use Forms for this type of thing.

    So much easier.
    Automettech - Automated Metrology Technology

    Comment


    • vpt.se
      vpt.se commented
      Editing a comment
      I thought the same as you, AndersI but then quickly realised that by doing so - I was the only one that could understand the sources/edit them...

      So now I try to my coding in PC-DMIS basic, VBA or C# instead.

    • AndersI
      AndersI commented
      Editing a comment
      Job security...

    • vpt.se
      vpt.se commented
      Editing a comment
      Lol! Well, at least I had that going for me...

Related Topics

Collapse

Working...
X