vendredi 3 mai 2013

Utilisation Focas

Difficile de trouver des informations sur la programmation Focas pour cn Fanuc sur le NET. Voici donc ma petite contribution avec un premier code pour tester la connexion

'---------------------
' Ethernet connexion
'---------------------
' allocate library handle 3
Declare Function cnc_allclibhndl3 Lib "fwlib32.dll" (ByVal sIPaddr As String, ByVal nPort As Integer, ByVal nTimeout As Long, FlibHndl As Integer) As Integer

Private Sub Form_Load()
Dim LibHndl As Integer
Dim Ret As Integer


'  192.0.0.1 Addresse connexion Ethernet sur CN (Attention deux ports généralement port communication et Data serveur)
'  8193 : Port Focas
Ret = cnc_allclibhndl3("192.0.0.1", "8193", 10, LibHndl)

if Ret Then call Status_of_Function(Ret)

End Sub


'---------------------------------------
' Gestion erreur sur fonction focas
'--------------------------------------
Sub Status_of_Function(ByRef Error As Integer, Optional FocasFonction As String)

Dim MSGA As String
Dim MSGB As String

'Return  Meaning  Explanation and Error handling
Select Case Error
Case EW_PROTOCOL
    MSGA = "(-17)  Protocol error (Ethernet version only)": MSGB = "Data from Ethernet Board is incorrect." & vbCrLf & "Contact with the service section or the section in charge."
Case EW_SOCKET
    MSGA = "(-16)  Socket error (Ethernet version only)": MSGB = "Investigate CNC power supply, Ethernet cable and I/F board."
Case EW_NODLL
    MSGA = "(-15)  DLL file error": MSGB = "There is no DLL file for each CNC series corresponding to specified node."
Case EW_BUS
    MSGA = "(-11)  Bus error (HSSB version only)": MSGB = "A bus error of CNC system occurred." & vbCrLf & "Contact with the service section or the section in charge."
Case EW_SYSTEM2
    MSGA = "(-10)  System error (2) (HSSB version only)": MSGB = "A system error of CNC system occurred." & vbCrLf & "Contact with the service section or the section in charge."
Case EW_HSSB
    MSGA = "(-9)  Communication error of HSSB (HSSB version only)": MSGB = "Investigate the serial line or I/F board of HSSB."
Case EW_HANDLE
    MSGA = "(-8)  Handle number error  Get the library handle number."
Case EW_VERSION
    MSGA = "(-7)  Version mismatch between the CNC/PMC and library": MSGB = "The CNC/PMC version does not match that of the library." & vbCrLf & "Replace the library or the CNC/PMC control software."
Case EW_UNEXP
    MSGA = "(-6)  Abnormal library state": MSGB = "An unanticipated error occurred." & vbCrLf & "Contact with the section in charge."
Case EW_SYSTEM
    MSGA = "(-5)  System error (HSSB version only)": MSGB = "A system error of CNC occurred." & vbCrLf & "Contact with the service section or the section in charge."
Case EW_PARITY
    MSGA = "(-4)  Shared RAM parity error (HSSB version only)": MSGB = "A hardware error occurred." & vbCrLf & "Contact with the service section."
Case EW_MMCSYS
    MSGA = "(-3)  FANUC drivers installation error (HSSB version only)": MSGB = "The drivers required for execution are not installed."
Case EW_RESET
    MSGA = "(-2)  Reset or stop request": MSGB = "The RESET or STOP button was pressed." & vbCrLf & "Call the termination function."
Case EW_BUSY
    MSGA = "(-1)  Busy": MSGB = "Wait until the completion of CNC processing, or retry."
Case EW_OK
    MSGA = "(0)  Normal termination"
    Exit Sub
Case EW_FUNC
    MSGA = "(1)  Error(function is not executed, or not available)": MSGB = "Specific function which must be executed beforehand has not been executed." & vbCrLf & "Otherwise that function is not available."
Case EW_LENGTH
    MSGA = "(2)  Error(data block length error, error of number of data)": MSGB = "Check and correct the data block length or number of data."
Case EW_NUMBER
    MSGA = "(3)  Error(data number error)": MSGB = "Check and correct the data number."
Case EW_ATTRIB
    MSGA = "(4)  Error(data attribute error)": MSGB = "Check and correct the data attribute."
Case EW_DATA
    MSGA = "(5)  Error(data error)": MSGB = "Check and correct the data." & vbCrLf & "For the following operations, this code indicates that the specified program cannot be found." & vbCrLf & "Delete specified program" & vbCrLf & "Search specified program" & vbCrLf & "Start uploading NC program"

Case EW_NOOPT
    MSGA = "(6)  Error(no option)": MSGB = "There is no corresponding CNC option."
Case EW_PROT
    MSGA = "(7)  Error(write protection)": MSGB = "Write operation is prohibited."
Case EW_OVRFLOW
    MSGA = "(8)  Error(memory overflow)": MSGB = "CNC tape memory is overflowed."
Case EW_PARAM
    MSGA = "(9)  Error(CNC parameter error)": MSGB = "CNC parameter is set incorrectly."
Case EW_BUFFER
    MSGA = "(10)  Error(buffer empty/full)": MSGB = "The buffer is empty or full." & vbCrLf & "Wait until completion of CNC processing, or retry."
Case EW_PATH
    MSGA = "(11)  Error(path number error)": MSGB = "A path number is incorrect."
Case EW_MODE
    MSGA = "(12)  Error(CNC mode error)": MSGB = "The CNC mode is incorrect." & vbCrLf & "Correct the CNC mode."
Case EW_REJECT
    MSGA = "(13)  Error(CNC execution rejection)": MSGB = "The execution at the CNC is rejected." & vbCrLf & "Check the condition of execution."
Case EW_DTSRVR
    MSGA = "(14)  Error(Data server error)": MSGB = "Some errors occur at the data server."
Case EW_ALARM
    MSGA = "(15)  Error(alarm)": MSGB = "The function cannot be executed due to an alarm in CNC." & vbCrLf & "Remove the cause of alarm."
Case EW_STOP
    MSGA = "(16)  Error(stop)": MSGB = "CNC status is stop or emergency."
Case EW_PASSWD
    MSGA = "(17)  Error(State of data protection)": MSGB = "Data is protected by the CNC data protection function."

Case Else
    MSGA = "Erreur inconnue  :" & Error
    MSGB = "Numéro d'erreur inconnue"
End Select

MsgBox "ERREUR SUR FONCTION FOCAS -> " & FocasFonction & " : " & MSGA & vbCrLf & vbCrLf & MSGB

End Sub

Aucun commentaire:

Enregistrer un commentaire