spostamento testSam in ramo superiore proj...

This commit is contained in:
Samuele E. Locatelli
2018-11-22 20:37:35 +01:00
parent f14590a37f
commit 287929dad7
368 changed files with 0 additions and 0 deletions
+717
View File
@@ -0,0 +1,717 @@
Option Strict Off
Option Explicit On
Module CndexLinkUserVB6
' OSAI S.p.A. Barone Canavese (Torino) Italy
'
' file: CndexLinkUser.BAS
' version: 3.0
'
'
' Errors management
'
' The DLL CndexLink uses the return code of the function and two double words
' for the error management. The double words are the class of the error and
' the error code.
' The return code of the functions is always a boolean. True means that the
' function has been executed without error, False means error during function
' execution.
' When the return code is False the parameters ErrClass and ErrNum report the
' codes related to the error
'
' The errors has been organized using classes to avoid error codes overlap
' Each class identify a level in the hierarchy of the modules used to
' communicate with the CNC
' For the error classes and error codes error definition please refer to the
' Cndex server interface documentation.
' The following codes could be not updated to last Cndex server version.
'
'
' The classes are the following:
'
' COM Class (class 1)
' The errors belonging to this class are generated by the COM interface
' that is used to carry out the calls to Cndex server.
'
' CNDEX SERVER Class (class 2)
' The errors belonging to this class can be generated either by the preliminary
' checks done by Cndex server on the called functions parameters or by internal
' errors of the server.
'
' NETBIOS Class (class 3)
' The errors belonging to this class depend by anomalies or errors during
' data exchange between Cndex server and the managed CNC connected through
' local network.
'
' CNC Class (class 4)
' The errors belonging to this class are generated by the elaboration of the
' commads by the CNC connected to Cndex.
'
' CNDEX INTERFACE Class (class 10)
' The errors belonging to this class are generated by CndexInterface DLL that
' is used to interface Cndex server.
'
'
' Error codes for COM classe (class 1)
'
' Questo e ' un elenco degli errori COM piu' comuni
'
' CO_E_SERVER_EXEC_FAILURE 0x80080005
' Su Windows 95/98 il server non puo' essere lanciato automaticamente ma bisogna
' metterlo in esecuzione manualmente, ricordando che quando non c'e' piu' nessuna
' applicazione attiva il server viene terminato automaticamente.
'
' RPC_S_SERVER_UNAVAILABLE 0x800706ba
' · assicurarsi che nel registry il valore del parametro <enableremoteconnect> sia Y
' · aggiungere o attivare il protocollo TCP/IP nella configurazione di rete
'
' E_ACCESSDENIED 0x80070005
' Su Windows NT/2000 lanciare l'utility dcomcnfg.exe e selezionare
' <the interactive user> o <this user> nella sezione identity dell'applicazione cndex,
' ed <everyone> nella sezione di launch permission
'
' REGDB_E_CLASSNOTREG 0x80040154
' Il server Cndex non e' stato registrato nel registry di Windows. Registrarlo con
' questo comando da eseguire in un DOS shell : cndex.exe /regserver
'
' CO_S_NOTALLINTERFACES 0x00080012
' La DLL proxy del server Cndex non e' stata registrata nel registry di Windows.
' Registrarla con questo comando da eseguire in un DOS shell : regsvr32 cndexps.dll
'
'
'
' Error codes for CNDEX SERVER classe (class 2)
'
' 1 No memory for dynamic memory allocation
' 2 Error creating syncronization events
' 3 Session aborted. It can not be used anymore.
' 4 Session not opened
' 5 It is not possible to allocate a network channel
' 6 It has been activated a function for an unexisting CNC process.
' 7 Broadcasting command aborted
' 8 User output buffer too small
' 9 Session already opened
' 10 Broadcasting list not valid
' 11 Realtime command aborted
' 12 The function is already active
' 13 The function is not active yet
' 14 Reciving thread terminated
' 15 Time-out. No answer (after an establish time) to the command sent to CNC.
' 16 The software release of the connected CNC is not compatible with the Cndex server protocol
' 17 The given session identifier is not valid
' 18 It is not possible to create the real-time thread
' 19 No network session channels available anymore
' 20 Error loading CNC symbols
' 23 It is not possible to create an instance of the session object
' 24 It is not possible to create the broadcasting thread
' 25 The function can not be executed during this phase of the CNC boot
' 26 Wrong parameter
' 27 Buffer not valid
' 29 The UserSession parameter is not valid (there is not a correspondig session)
' 31 The UserSession parameter is either not valid or the corrisponding session has
' automatically been closed by Cndex server.
'
'
' Error codes for NETBIOS class (class 3)
'
' 0x0001 Illegal buffer length
' 0x0003 Illegal command
' 0x0005 Command timed out
' 0x0006 Message incomplete, issue another command
' 0x0007 Illegal buffer address
' 0x0008 Session number out of range
' 0x0009 No resource available
' 0x000a Session closed
' 0x000b Command cancelled
' 0x000d Duplicate name
' 0x000e Name table full
' 0x000f No deletions, name has active sessions
' 0x0011 Local session table full
' 0x0012 Remote session table full
' 0x0013 Illegal name number
' 0x0014 No callname
' 0x0015 Cannot put * in NCB_NAME
' 0x0016 Name in use on remote adapter
' 0x0017 Name deleted
' 0x0018 Session ended abnormally
' 0x0019 Name conflict detected
' 0x0021 Interface busy, IRET before retrying
' 0x0022 Too many commands outstanding, retry later
' 0x0023 Ncb_lana_num field invalid
' 0x0024 Command completed while cancel occurring
' 0x0026 Command not valid to cancel
' 0x0030 Name defined by anther local process
' 0x0034 Environment undefined. RESET required
' 0x0035 Required OS resources exhausted
' 0x0036 Max number of applications exceeded
' 0x0037 No saps available for netbios
' 0x0038 Requested resources are not available
' 0x0039 Invalid ncb address or length > segment
' 0x003B Invalid NCB DDID
' 0x003C Lock of user area failed
' 0x003f NETBIOS not loaded
' 0x0040 System error
'
'
'
' Error codes for CNC class (class 4)
'
' For the error codes related to this class please refer to
' "MINI-DNC ETHERNET Functions Library" and "USER MANUAL" of the
' 10/Series CNC
'
'
'
' Error codes for CNDEX INTERFACE class (class 10)
'
' 1 ERR_SERVER_ALREADY_CREATED CNDEX server already created
' 2 ERR_CREATING_SERVER_OBJECT Error creating CNDEX server
' 3 ERR_SERVER_NOT_CREATED CNDEX server never created or already released
' 4 ERR_INVALID_PARAMETER Invalid value for one or more parameters
' 5 ERR_OPTION_NOT_ENABLED The COMMUNICATION option is not enabled for connected CNC
Public Const ON_ As Short = 1
Public Const OFF_ As Short = 0
'Boot phase
Public Const EMERG_SWITCH_PHASE As Short = 1
Public Const HW_BOOT_PHASE As Short = 2
Public Const SW_BOOT_PHASE As Short = 3
Public Const SYSTEM_UP_PHASE As Short = 4
Public Const SERVER_MODE_PHASE As Short = 5
Public Const REMOTE_SETUP_PHASE As Short = 6
' Classes of the Process Variables
Public Const E_VAR_CLASS As Short = 1
Public Const SN_VAR_CLASS As Short = 2
Public Const SC_VAR_CLASS As Short = 255
' 10 Series modes
Public Const MDI As Short = 1
'UPGRADE_NOTE: AUTO è stato aggiornato a AUTO_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
Public Const AUTO_Renamed As Short = 2
Public Const SEMI As Short = 3
Public Const MANJOG As Short = 4
Public Const INCJOG As Short = 5
Public Const PROFILE As Short = 6
Public Const HOME As Short = 7
' 10 Series Status
Public Const IDLE_ As Short = 1
Public Const CYCLE_ As Short = 2
Public Const HOLDA_ As Short = 3
Public Const RUNH_ As Short = 4
Public Const HRUN_ As Short = 5
Public Const ERRO_ As Short = 6
Public Const WAIT_ As Short = 7
Public Const RESET_ As Short = 8
Public Const EMERG_ As Short = 9
Public Const INPUT_ As Short = 10
' 10 Series SubStatus
Public Const MAS As Short = 6
Public Const MBR As Short = 4
Public Const NUM_ELEM_SEL_AXI As Short = 9
' Axes Position type selector
Public Const PROGPOS As Short = 1 ' Programmed positions
Public Const IntPos As Short = 2 ' Interpolated positions
Public Const TRANSDPOS As Short = 3 ' Transducer Position
Public Const ERRPOS As Short = 4 ' Following Errors
Public Const MAIN_PROGR_NAME_LEN As Short = 55
' Logic variables identifier
' boolean variables
Public Const I_CODE As Short = 0
Public Const O_CODE As Short = 1
Public Const M_CODE As Short = 2
Public Const G_CODE As Short = 3
Public Const S_CODE As Short = 4
Public Const P_CODE As Short = 7
Public Const U_CODE As Short = 8
' WORD variables
Public Const MW_CODE As Short = 20
Public Const GW_CODE As Short = 21
Public Const SW_CODE As Short = 22
Public Const PW_CODE As Short = 62
Public Const UW_CODE As Short = 63
'DOUBLE variables
Public Const MD_CODE As Short = 40
Public Const GD_CODE As Short = 41
Public Const PD_CODE As Short = 43
Public Const UD_CODE As Short = 44
' Tables identifiers
Public Const AXIS_TABLE_ID As Short = 1 ' AXIS TABLE identifier
Public Const TOOL_TABLE_ID As Short = 2 ' TOOL TABLE identifier
Public Const OFFSET_TABLE_ID As Short = 3 ' OFFSET TABLE identifier
Public Const USER_TABLE_ID As Short = 4 ' USER TABLE identifier
' Logical directory identifiers
Public Const PPDIR_PROGRAM As Short = 0 ' PROGRAM directory
Public Const PPDIR_USER As Short = 1 ' USER directory
Public Const PPDIR_SYSTEM As Short = 2 ' SYSTEM directory
Public Const PPDIR_OEM As Short = 3 ' OEM directory
Structure GETINTDATA
Dim AxisName As Byte
Dim Mode As Byte
Dim Position As Double
Dim TotalOffset As Double
End Structure
Structure PROCDATA
Dim Mode As Short
Dim status As Short
Dim substatus As Short
End Structure
Structure GetInfo1Data
Dim status As Byte ' process status
Dim substatus As Byte ' process substatus
Dim mode_select As Byte ' selected mode
Dim jog_dir As Byte ' 1 = negative 0 = positive
Dim speed_ov As Short ' speed override
Dim feed_ov As Short ' feed override
Dim rap_feed_ov As Short ' rapid feed override
Dim man_feed_ov As Short ' manual feed override
Dim jog_incr As Double ' incremental jog value
Dim num_ax_sel As Byte ' number of selected axes
<VBFixedArray(NUM_ELEM_SEL_AXI)> Dim ax_sel() As Byte 'array of selected axes
Dim actual_tool As Double ' actual active tool number
Dim progr_tool As Double ' programmed tool number
Dim actual_tool_off As Short ' actual tool offset number
Dim progr_tool_off As Short ' programmed tool offset number
Dim real_speed As Double ' real spindle feed
Dim progr_speed As Double ' programmed spindle feed
Dim progr_feed As Double ' programmed feed
Dim rapid_feed As Double ' rapid feed
Dim real_feed As Double ' real feed
Dim feed_mis_unit As Short ' misure unit of feed
'UPGRADE_WARNING: La dimensione della stringa di lunghezza fissa deve essere contenuta nel buffer. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(MAIN_PROGR_NAME_LEN), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=MAIN_PROGR_NAME_LEN)> Public main_progr_name() As Char ' active main part program name
Dim dry_run As Byte ' 1 = dry run modality active
Dim rapid_override As Byte ' 1 = rapid ovverride enable
Dim disable_slashed_blk As Byte ' 1 = slashed block disable
Dim optional_stop As Byte ' 1 = M00 stop enable
Dim force_rapid_feed As Byte ' 1 = rapid feed forced
Dim auto_jog_ret As Byte ' 1 = automatic jog return mode
Dim block_retrace As Byte ' 1 = multi block retrace active
Dim last_nc_error As Short ' last NC error. 0 = no error
<VBFixedArray(22)> Dim free() As Byte ' free
'UPGRADE_TODO: "Initialize" deve essere chiamato per inizializzare istanze di questa struttura. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B4BFF9E0-8631-45CF-910E-62AB3970F27B"'
Public Sub Initialize()
ReDim ax_sel(NUM_ELEM_SEL_AXI)
ReDim free(22)
End Sub
End Structure
Structure GetInfo2Data
Dim StatusWord As Short
Dim Urp As Double
Dim ActTool As Double
Dim ActOffset As Short
Dim ProgTool As Double
Dim ProgOffset As Short
Dim M_Status As Short
<VBFixedArray(15)> Dim M_Value() As Short
Dim Ax1Name As Byte
Dim Ax1Offset As Double
Dim Ax2Name As Byte
Dim Ax2Offset As Double
Dim Radius As Double
'UPGRADE_TODO: "Initialize" deve essere chiamato per inizializzare istanze di questa struttura. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B4BFF9E0-8631-45CF-910E-62AB3970F27B"'
Public Sub Initialize()
ReDim M_Value(15)
End Sub
End Structure
Structure GETBLKNUMDATA
Dim ppActNum As Short
Dim MainActBlk As Integer
Dim Sbr1ActBlk As Integer
Dim Sbr2ActBlk As Integer
Dim Sbr3ActBlk As Integer
Dim Sbr4ActBlk As Integer
End Structure
' Axis Table Descriptor
Structure AXIS_TABLE
Dim owner As Short ' ambient owner
Dim name As Short ' ascii axis name
Dim orig As Double ' actual origin
Dim free1 As Double ' FREE FIELD
Dim ofg92 As Double ' offset G92
Dim toff As Double ' actual tool offset
Dim free2 As Double ' FREE FIELD
Dim Offset As Double ' axis total offset
Dim orig1 As Double ' origin 1
Dim orig2 As Double ' origin 2
Dim orig3 As Double ' origin 3
Dim orig4 As Double ' origin 4
Dim orig5 As Double ' origin 5
Dim orig6 As Double ' origin 6
Dim orig7 As Double ' origin 7
Dim orig8 As Double ' origin 8
Dim orig9 As Double ' origin 9
Dim orig10 As Double ' origin 10
Dim reserved1 As Short ' reserved
Dim reserved2 As Short ' reserved
End Structure
' Tool table descriptor
Structure TOOL_TABLE
Dim Tcode As Double ' tool code
Dim pocket As Short ' pocket position
Dim tfamcol As Short ' random family
Dim tclass As Short ' tool class
Dim tstatus As Short ' status word
Dim tcntrl As Short ' control word
Dim maxtime As Double ' start life
Dim remtime As Double ' actual life
Dim tuser1 As Double ' user parameter 1
Dim tuser2 As Double ' user parameter 2
Dim tuser3 As Double ' user parameter 3
Dim tuser4 As Double ' user parameter 4
Dim tolfnr As Short ' offset number
End Structure
' Offset table descriptor
Structure OFFSET_TABLE
Dim tactl1 As Double ' actual tool lenght 1
Dim tcmaxl1 As Double ' max change lenght 1
Dim tcactl1 As Double ' actual change lenght 1
Dim tactl2 As Double ' actual tool lenght 2
Dim tcmaxl2 As Double ' max change lenght 2
Dim tcactl2 As Double ' actual change lenght 2
Dim tdiameter As Double ' diameter (ex radius)
Dim tcacdiam As Double ' diameter wear (ex tangle)
Dim torient As Short ' orientation
End Structure
' User table descriptor
Structure USER_TABLE
Dim user1 As Double ' user variable 1
Dim User2 As Double ' user variable 2
Dim user3 As Double ' user variable 3
Dim user4 As Double ' user variable 4
End Structure
Structure ERR_MSG
'UPGRADE_WARNING: La dimensione della stringa di lunghezza fissa deve essere contenuta nel buffer. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(40), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=40)> Public Msg1() As Char
'UPGRADE_WARNING: La dimensione della stringa di lunghezza fissa deve essere contenuta nel buffer. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
'UPGRADE_NOTE: MSG2 è stato aggiornato a MSG2_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
<VBFixedString(40), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=40)> Public MSG2_Renamed() As Char
'UPGRADE_WARNING: La dimensione della stringa di lunghezza fissa deve essere contenuta nel buffer. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
'UPGRADE_NOTE: MSG3 è stato aggiornato a MSG3_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
<VBFixedString(40), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=40)> Public MSG3_Renamed() As Char
'UPGRADE_WARNING: La dimensione della stringa di lunghezza fissa deve essere contenuta nel buffer. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(40), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=40)> Public Msg4() As Char
End Structure
Structure PLVARDESC
Dim Code As Short
Dim Index As Short
Dim Bit As Short
End Structure
Structure EMCY_TYPE
Dim usEmcyErrCode As Short
Dim usEmcyErrorReg As Byte
Dim SpecErrField As Integer
Dim reserved As Byte
End Structure
''''''' CNDEX SERVER FUNCTIONS PROTOTYPES '''''''
Declare Function ConnectServer_C Lib "CndexLink.DLL" (ByVal ServerAddress As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function ReleaseServer_C Lib "CndexLink.DLL" (ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' NET SESSION FUNCTIONS PROTOTYPES '''''''
Declare Function OpenSession_C Lib "CndexLink.DLL" (ByVal RemoteName As String, ByRef UserSession As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CloseSession_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function IsSessionOpened_C Lib "CndexLink.DLL" (ByVal UserSession As Short) As Short
''''''' CNC BOOT FUNCTIONS PROTOTYPES '''''''
Declare Function BootPhaseEnquiry_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef Phase As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function BootReboot_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function BootShutDown_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function BootMode_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal Mode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' GENERAL FUNCTIONS PROTOTYPES '''''''
Declare Function GetCodeNumber_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal CodeNumber As String, ByVal SwVersion As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_NOTE: Second è stato aggiornato a Second_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Minute è stato aggiornato a Minute_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Hour è stato aggiornato a Hour_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Day è stato aggiornato a Day_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Month è stato aggiornato a Month_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Year è stato aggiornato a Year_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
Declare Function GetDateTime_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef Year_Renamed As Short, ByRef Month_Renamed As Short, ByRef Day_Renamed As Short, ByRef Hour_Renamed As Short, ByRef Minute_Renamed As Short, ByRef Second_Renamed As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_NOTE: Second è stato aggiornato a Second_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Minute è stato aggiornato a Minute_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Hour è stato aggiornato a Hour_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Day è stato aggiornato a Day_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Month è stato aggiornato a Month_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_NOTE: Year è stato aggiornato a Year_Renamed. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
Declare Function SetDateTime_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal Year_Renamed As Short, ByVal Month_Renamed As Short, ByVal Day_Renamed As Short, ByVal Hour_Renamed As Short, ByVal Minute_Renamed As Short, ByVal Second_Renamed As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPInsertName_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal LogicalName As String, ByVal LogicalExt As String, ByVal LogicalDir As Short, ByVal PhysicalName As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPDeleteName_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal LogicalName As String, ByVal LogicalExt As String, ByVal LogicalDir As Short, ByRef NumberOfFilesDeleted As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPGetLogicalName_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal PhysicalName As String, ByVal LogicalName As String, ByVal LogicalExt As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPGetPhysicalName_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal LogicalName As String, ByVal LogicalExt As String, ByVal LogicalDir As Short, ByVal PhysicalName As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPGetLogicalDir_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal LogicalName As String, ByVal LogicalExt As String, ByRef LogicalDir As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function PPUpdate_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal LogicalName As String, ByVal LogicalExt As String, ByVal LogicalDir As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' PROCESS FUNCTIONS PROTOTYPES '''''''
Declare Function Cycle_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Cmd As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SyncroCycle_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function Reset_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function Hold_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Cmd As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetFeedManOver_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal FeedManOver As Short, ByVal Direction As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetFeedRateOver_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal FeedRateOver As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetFeedRapidOver_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal FeedRapidOver As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetSpeedRateOver_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal SpeedRateOver As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetManMovDirection_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Direction As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetMdiString_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal MdiString As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetProcessMode_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Mode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SelectProcess_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetSelectedProcess_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SelectProcAxis_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal AxisName As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SelectPartProgram_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal PartProgramName As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura GETINTDATA potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetAxesPosition_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal AxisName As Byte, ByVal Selector As Short, ByRef NumAxis As Short, ByRef IntPos As GETINTDATA, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura GetInfo1Data potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetNcInfo1_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef GetInfo1Data As GetInfo1Data, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura GetInfo2Data potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetNcInfo2_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef GetInfo2Data As GetInfo2Data, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura PROCDATA potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetProcessStatus_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef NewMode As PROCDATA, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura GETBLKNUMDATA potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetBlkNum_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef BlkNum As GETBLKNUMDATA, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function AxesRef_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal NumAx As Short, ByRef AxisName As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetVarE_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByRef Num As Short, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetVarSN_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByRef Num As Short, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetVarSC_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByRef Num As Short, ByVal text As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetVarJOG_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef Value As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetVarRCM_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef Value As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarE_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByVal Num As Short, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarSN_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByVal Num As Short, ByRef Value As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarSC_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Index As Short, ByVal Num As Short, ByVal text As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarJOG_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Value As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarUAS_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Mode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetVarRCM_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal Mode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura ERR_MSG potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function ReadErrMsg_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef SysErrMsg As ERR_MSG, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function ReadPartProgramMsg_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal PartProgramMsg As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetGCode_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef GCode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetMCode_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef MCode As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SkipPProgBlock_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal NumOfBlocks As Integer, ByVal Direction As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function Ese_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal BlockNum As Integer, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' PLC FUNCTIONS PROTOTYPES '''''''
'UPGRADE_WARNING: La struttura PLVARDESC potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetPLVarWord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByRef VarDesc As PLVARDESC, ByRef Values As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetPLVarWord_M_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByRef VarDesc As PLVARDESC, ByRef Values() As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura PLVARDESC potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetPLVarWord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByRef VarDesc As PLVARDESC, ByRef Values As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura PLVARDESC potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetPLVarDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByRef VarDesc As PLVARDESC, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura PLVARDESC potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetPLVarDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByRef VarDesc As PLVARDESC, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetPLVarAscii_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal Index As Short, ByVal Value As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetPLVarAscii_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal Index As Short, ByRef Value As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetPLStreamWord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByVal Code As Short, ByVal StartIndex As Short, ByRef Values As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetPLStreamDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByVal Code As Short, ByVal StartIndex As Short, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetPLStreamWord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByVal Code As Short, ByVal StartIndex As Short, ByRef Values As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetPLStreamDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal NumVar As Short, ByVal Code As Short, ByVal StartIndex As Short, ByRef Values As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function ReadWarningMsg_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal WarningMsg As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANReadSDO_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal idNode As Byte, ByVal Index As Short, ByVal subIndex As Byte, ByVal timeout As Short, ByVal Sync As Byte, ByRef data As Byte, ByRef DataLen As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANWriteSDO_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal idNode As Byte, ByVal Index As Short, ByVal subIndex As Byte, ByVal timeout As Short, ByVal Sync As Byte, ByRef data As Byte, ByRef DataLen As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANNMT_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal idNode As Byte, ByVal Cmd As Short, ByVal timeout As Short, ByVal Sync As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANSync_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal timeout As Short, ByVal Sync As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANInit_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal TickNr As Short, ByVal Inp1 As Short, ByVal Inp2 As Short, ByVal Out1 As Short, ByVal Out2 As Short, ByVal OffsDiagn As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura EMCY_TYPE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function CANGetEmergency_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal idNode As Byte, ByVal timeout As Short, ByVal Sync As Byte, ByRef NodeStatus As Short, ByRef AddInfo As Short, ByRef ProfNum As Short, ByRef NodeStateNG As Short, ByRef ActualErr As Short, ByRef EmcyLen As Short, ByRef EmcyData As EMCY_TYPE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANBoard_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal Cmd As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function CANConsoleCfg_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal DevNum As Short, ByVal idNode As Byte, ByVal InpOffs As Short, ByVal OutOffs As Short, ByVal timeout As Short, ByVal Sync As Byte, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' TABLES RELATED FUNCTIONS PROTOTYPES '''''''
'UPGRADE_WARNING: La struttura AXIS_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetAxisTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As AXIS_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura TOOL_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetToolTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As TOOL_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura OFFSET_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetOffsetTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As OFFSET_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura USER_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function GetUserTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As USER_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetTabFieldDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TableNum As Short, ByVal RecordNum As Short, ByVal FieldNum As Short, ByRef Value As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function GetTabFieldShort_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TableNum As Short, ByVal RecordNum As Short, ByVal FieldNum As Short, ByRef Value As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura AXIS_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetAxisTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As AXIS_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura TOOL_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetToolTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As TOOL_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura OFFSET_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetOffsetTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef Record As OFFSET_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_WARNING: La struttura USER_TABLE potrebbe richiedere attributi di marshalling da passare come argomento a questa istruzione Declare. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Declare Function SetUserTabRecord_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal RecordNum As Short, ByRef RecordBuff As USER_TABLE, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetTabFieldDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TableNum As Short, ByVal RecordNum As Short, ByVal FieldNum As Short, ByVal Value As Double, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetTabFieldShort_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TableNum As Short, ByVal RecordNum As Short, ByVal FieldNum As Short, ByVal Value As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function SetTabSem_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TableNum As Short, ByVal SemStatus As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function TabSemInfo_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByRef SemStatus As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function TabSearchDouble_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TabNum As Short, ByVal FieldNum As Short, ByVal StartIndex As Short, ByVal StopIndex As Short, ByVal Value As Double, ByRef MatchIndex As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function TabSearchShort_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal TabNum As Short, ByVal FieldNum As Short, ByVal StartIndex As Short, ByVal StopIndex As Short, ByVal Value As Short, ByVal Mask As Short, ByRef MatchIndex As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' O.S. FUNCTIONS PROTOTYPES '''''''
'UPGRADE_ISSUE: La dichiarazione di un parametro 'As Any' non è supportata. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="FAE78A8D-8978-4FD4-8208-5B7324A8F795"'
Declare Function GRead_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal MemId As Short, ByVal Offset As Short, ByVal Length As Short, ByRef Buffer As Object, ByRef BufferLength As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
'UPGRADE_ISSUE: La dichiarazione di un parametro 'As Any' non è supportata. Fare clic per ulteriori informazioni: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="FAE78A8D-8978-4FD4-8208-5B7324A8F795"'
Declare Function GWrite_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal MemId As Short, ByVal Offset As Short, ByVal Length As Short, ByRef Buffer As Object, ByRef BufferLength As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
''''''' ACTIVE PART PROGRAM DOWNLOAD FUNCTIONS PROTOTYPES '''''''
Declare Function DncInit_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal PathName As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function DncData_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByVal data As String, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function DncEof_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
Declare Function DncStop_C Lib "CndexLink.DLL" (ByVal UserSession As Short, ByVal ProcNum As Short, ByRef ErrClass As Integer, ByRef ErrNum As Integer) As Short
End Module
File diff suppressed because it is too large Load Diff
+377
View File
@@ -0,0 +1,377 @@
'
' libreria : VBlib
' file : ComCNOsaiVB6
'
' funzioni : connessione con CN OSAI come classe - override metodi per vecchie versioni WinNbi
'
' copyright 2008-2016 C.Viviani
'
Imports Microsoft.Win32
Public Class ComCNOSAIVB6
Inherits ComCNOsai
Public Sub New(ByRef szRemoteName As String, ByRef b_debug As Boolean)
MyBase.New(szRemoteName, b_debug)
End Sub
Public Overrides Function OpenSession() As Boolean
Dim nReturn As Short
'mi connetto al server Cndex
nReturn = ConnectServer_C("", mErrClass, mErrNum)
If nReturn = ERRORE_OSAI Then
Connected = False
ErrMsg = "Error on ConnectServer_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Else
'apro una sessione col CN
Connected = True
nReturn = OpenSession_C(NomeCn, SessionOpened, mErrClass, mErrNum)
If nReturn = ERRORE_OSAI Then
Connected = False
ErrMsg = "Error on OpenSession_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
End If
End If
Return Connected
End Function
Public Overrides Function CloseSession() As Boolean
Dim nReturn As Short
Dim bOk As Boolean
bOk = True
'chiudo la sessione
nReturn = CloseSession_C(SessionOpened, mErrClass, mErrNum)
If nReturn = ERRORE_OSAI Then
ErrMsg = "Error on CloseSession_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Connected = False
bOk = False
Else
Connected = False
End If
'rilascio il server Cndex
nReturn = ReleaseServer_C(mErrClass, mErrNum)
If nReturn = ERRORE_OSAI Then
ErrMsg = "Error on ReleaseServer_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Connected = False
bOk = False
Else
Connected = False
End If
Return bOk
End Function
'------------------------------
' Lettura variabile Short su Cn
'------------------------------
Public Overrides Function ReadShortVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Short
Dim nValues As Short
Dim pVar As PLVARDESC
Dim nComOk As Short ' Se 1 lettura OK Se 0 lettura KO
Dim nNumVarToBeReaded As Integer = 1 ' Numero di variabili da leggere (fisso a 1)
pVar.Code = CndexLinkUserVB6.GW_CODE
pVar.Index = szVar.nAddress
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = GetPLVarWord_C(SessionOpened, nNumVarToBeReaded, pVar, nValues, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on GetPLVarWord_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore
Else
' return con il valore letto
Return nValues
End If
Else ' gestione se debug
' ritorno true
Return 1
End If
End Function
'--------------------------------
' Lettura multi variabile MW su Cn
'--------------------------------
Public Overrides Function ReadMultipleVarMW(ByVal nAddress As Integer, ByRef nValues() As Short, ByVal nNumVarToRead As Short, Optional ByVal nProcess As Integer = 1) As Boolean
Dim pVar As PLVARDESC
Dim nComOk As Short ' Se 1 lettura OK Se 0 lettura KO
pVar.Code = CndexLinkUserVB6.MW_CODE
pVar.Index = nAddress
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = GetPLVarWord_M_C(SessionOpened, nNumVarToRead, pVar, nValues, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on GetPLVarWord_M_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return False
Else
' return con il valore letto
Return True
End If
Else ' gestione se debug
' ritorno true
Return True
End If
End Function
' -------------------------------
' Scrittura variabile Short su Cn
'---------------------------------
Public Overrides Function WriteShortVar(ByVal szVar As stVAR, ByVal nValue As Short, Optional ByVal nProcess As Integer = 1) As Boolean
Dim pVar As PLVARDESC
Dim nComOk As Short ' Se 1 scritt. OK Se 0 lettura KO
Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1)
If (Not (Debug)) Then ' Se macchina collegata
pVar.Bit = szVar.nBit
pVar.Code = CndexLinkUserVB6.GW_CODE
pVar.Index = szVar.nAddress
nComOk = SetPLVarWord_C(SessionOpened, nNumVarToBeWrited, pVar, nValue, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on SetPLVarWord_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return False
Else
Return True
End If
Else ' gestione in debug
Return True
End If
End Function
'--------------------------------
' Lettura variabile SC su Cn
'--------------------------------
Public Overrides Function ReadSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, Optional ByVal nProcess As Integer = 1) As String
Dim szValue As String = " "
Dim nComOk As Short ' Se 1 lettura OK Se 0 lettura KO
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = GetVarSC_C(SessionOpened, nProcess, nIndex, nNumChar, szValue, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on reading SC variable" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return "" ' In uscita setto variabile a ERRORVALUE errore
Else
' return con il valore letto
Return szValue
End If
Else ' gestione se debug
' ritorno true
Return "SC VAR - DEBUG"
End If
End Function
' ---------------------------------
' Scrittura variabile SC su Cn
'----------------------------------
Public Overrides Function WriteSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, ByVal szText As String, Optional ByVal nProcess As Integer = 1) As Boolean
Dim nComOk As Short ' Se 1 scrittura OK Se 0 scrittura KO
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = SetVarSC_C(SessionOpened, nProcess, nIndex, nNumChar, szText, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on writing SC variable" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return False ' In uscita setto variabile a ERRORVALUE errore
Else
Return True
End If
' se sono in debug
Else
Return True
End If ' Endif gestione macchina collegata
End Function
'------------------------------
' Lettura variabile E su Cn
'------------------------------
Public Overrides Function ReadVarE(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double
Dim dValues As Double
Dim pVar As PLVARDESC
Dim nComOk As Short ' Se 1 lettura OK Se 0 lettura KO
Dim nNumVarToBeReaded As Integer = 1 ' Numero di variabili da leggere (fisso a 1)
pVar.Code = CndexLinkUserVB6.GW_CODE
pVar.Index = szVar.nAddress
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = GetVarE_C(SessionOpened, nProcess, szVar.nAddress, nNumVarToBeReaded, dValues, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on GetVarE_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore
Else
' return con il valore letto
Return dValues
End If
Else ' gestione se debug
' ritorno true
Return 1
End If
End Function
'------------------------------
' Lettura process stato info Cn
'------------------------------
'
' ha causato molto dispiacere il fatto che se uso la Server.GetProcessStatus_C con winnbi < 3.1.1
' dà una UNRESOLVED a run time della GetProcessStatus_C8 ( notare l' "8" finale ) nella CNDEXLINK.DLL
'
' soluzione : con Win Nbi recenti, uso Server.GetProcessStatus_C ; con Winnbi vecchi, faccio override
' di questa funzione USANDO LA STRUTTURA NUOVA CndexLinkDotNet.Cndex.PROCDATA ( altrimenti non è possibile
' fare override; uso una variabile locale tipo vecchio ( PROCDATA ) e in caso di esito positivo,
' copio i dati risultanti.
'
' Attenzione : si ha lo stesso problema anche con la Server.GetNcInfo1_C ma curiosamente non con le funzioni
' di lettura scrittura variabili CN .... boh !!
Public Overrides Function NcProcessStatus(ByRef ncInfo As CndexLinkDotNet.Cndex.PROCDATA, Optional ByVal nProcess As Integer = 1) As Boolean
Dim nComOk As Short ' Se 1 lettura OK Se 0 lettura KO
Dim geppodata As PROCDATA ' trucco sporchissimo : la versione dotnet richiede un altro tipo di dati...
' se macchina collegata e non in debug
If (Not (Debug)) Then
nComOk = GetProcessStatus_C(SessionOpened, nProcess, geppodata, ErrClass, ErrNum)
If (nComOk = ERRORE_OSAI) Then
ErrMsg = "Error on GetProcessStatus_C" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)
Return False ' In uscita setto variabile a ERRORVALUE errore
Else
ncInfo.Status = geppodata.status
ncInfo.SubStatus = geppodata.substatus
Return True
End If
' se sono in debug
Else
Return True
End If ' Endif gestione macchina collegata
End Function
' -------------------------------------------------
' Lettura stato macchina su processo passato per parametro
'--------------------------------------------------
Public Overrides Function GetMachineStatus(Optional ByVal nProcess As Integer = 1) As Byte
'
' se non andasse, usare NcProcessStatus e prendere solo lo stato......
Dim RetVal As Short
Dim geppodata As PROCDATA ' trucco sporchissimo : la versione dotnet richiede un altro tipo di dati...
' se macchina collegata e non in debug
If (Not (Debug)) Then
RetVal = GetProcessStatus_C(SessionOpened, nProcess, geppodata, ErrClass, ErrNum)
If RetVal > 0 Then
Return Convert.ToByte(geppodata.status)
Else
ErrMsg = "Error on GetMachineStatus" & vbCrLf & what_happened()
Return 255
End If
' se sono in debug
Else
Return True
End If
End Function
End Class
File diff suppressed because it is too large Load Diff
+464
View File
@@ -0,0 +1,464 @@
Public Module IniRead
Public Const OVERWRITE As Boolean = True
Public Const APPEND As Boolean = True
Public Const DO_NOT_APPEND As Boolean = False
Public sz_ini_file_name As String
Public sz_program_path As String
Public sz_temporary_path As String
Public sz_allowed_extension As String
Public b_debug As Boolean
Public b_verbose As Boolean
Public b_test_nc As Boolean
Public b_send_file As Boolean
Public b_log_enabled As Boolean
Public szLogFileName As String
Public b_win7 As Boolean
Public b_open_control As Boolean
Public b_force_S10WLK32 As Boolean
Public b_no_WinNBI As Boolean
Public szNameNC As String
Public nVar_NC_state As Integer ' @STATUS_PRG PLC var number ( GW ) : Nc program state
Public nVar_prg_1_ok As Integer
Public nVar_prg_2_ok As Integer
Public sz_ODD_program_name As String
Public sz_EVEN_program_name As String
Public sz_AUTO_program_name As String
Public n_program_to_send As Short
Public szDefaultNameNC As String
Public szDefaultPathNC As String
Public lTimerInterval As Long
Public b_SerialBarCodeReader_enabled As Boolean
Public n_SerialBarCodeReader_comm_port As Int16
Public sz_SerialBarCodeReader_settings As String
Public b_UsbBarCodeReader_enabled As String
Public b_BarCodeInput_enabled As Boolean
Public b_FileInputMode_enabled As Boolean
Public sz_FileInputName As String
Public n_num_barcode_fields As Short
Public sz_barcode_mask As String
Public sz_barcode_preprocessing As String
Public b_Table_enabled As Boolean
Public sz_table_filename As String
Public b_reload_table As Boolean
Public b_ext_program_enabled As Boolean
Public sz_ext_program_filename As String
Public sz_ext_return_filename As String
Public sz_ext_temp_filename As String
Public b_CAM_program_enabled As Boolean
Public sz_CAM_program_exefilename As String
Public sz_CAM_data_path As String
Public sz_CAM_data_ext As String
Public sz_CAM_arguments As String
Public sz_CAM_return_ext As String
Public sz_CAM_Probe_ext As String
Public b_direct_mode_enabled As Boolean
Public sz_direct_prefix As String
Public sz_direct_suffix As String
Public b_select_mode_enabled As Boolean
Public sz_probe_arguments As String
Public sz_cn_arguments As String
Public n_L_var_1 As Int16
Public n_L_var_2 As Int16
Public n_L_value_1_on As Int16
Public n_L_value_1_off As Int16
Public n_L_value_2_on As Int16
Public n_L_value_2_off As Int16
Public n_timeout As Int16
Public sz_nc_probe_path As String
Public sz_nc_probe_ext As String
Public b_fixed_probe_file As Boolean
Public sz_nc_fixed_probe_file As String
Public b_read_DDF_file As Boolean
Public sz_property_1 As String
Public sz_property_2 As String
Public b_toolcomp_update As Boolean
Public n_toolcomp_number As Int16
Public sz_toolcomp_file As String
Public sz_toolcomp_command As String
#Region "registration"
'Questo campo e' il campo di referenza serve a creare la relativa KEy di sblocco
Public developerKey As String
'Richiede solo numeri interi
Public regTry As Integer
'Flag per identificare la registrazione del programma
Public pRegistered As Boolean
Public PC_serial_number As Long
Public sPC_serial_number As String
Public SW_version As String
Public registered_key As String
Public registered_key2 As String
Public registered_key3 As String
Public registered_customer As String
#End Region
#Region "example of INI file"
' file door_pro.ini
'[General]
'Program path = c:\Users\carlo\Documents\Projects\vs2008\door_pro\door_pro\programs
'allowed ext = .anc .TXT
'temp path = c:\Users\carlo\Documents\Projects\vs2008\door_pro\door_pro\temp
'
'w7 = true
'timer = 1000
'[Debug]
'debug = true
'verbose = false
'[Log]
'enabled = true
'Log file = c:\Users\carlo\Documents\Projects\vs2008\door_pro\door_pro\temp\log
'[NC]
'name = NC9000
'NC state = 230
'Prog1 ok = 232
'Prog2 ok = 233
'default_name = MAIN
'default_path = Y:\UPP\
'ODD_name = 1000
'EVEN_name = 2000
'AUTO_name = UPP\MAINAUTO
'program_to_send = 4
'[BarCode]
'fields = 1
'MASK = xx11111xxx223333xx44xxxxxx
'PreProcessing = "1-2"
'[SerialBarCodeReader]
'enabled = true
'Port = 4
'Settings=9600,n,8,1
'[UsbBarCodeReader]
'enabled = false
'[Table]
'enabled = true
'file = c:\pro_d\pro_d\prg\worklist.aut
'[CAM]
'enabled = true
'program = C:\abc\ww.exe
'datapath
'arguments
'return_file_ext = txt
'[Direct]
'enabled = true
'pre = C:\door_pro\programs\
'post = .cnc
'[Key]
' regkey = 12345
' regkey2 = 2345
' regkey3 = 2345
' customer = qwe
#End Region
Sub Ini_read()
sz_ini_file_name = Application.StartupPath & "\config\" & Application.ProductName & ".ini"
Dim ini As New IniReader(sz_ini_file_name)
ini.Section = "General" '-----------------------------------------------------
sz_program_path = clear_ending_bar(ini.ReadString("Program path"))
sz_temporary_path = clear_ending_bar(ini.ReadString("temp path"))
sz_allowed_extension = clear_starting_point(ini.ReadString("allowed ext").ToLower)
lTimerInterval = ini.ReadLong("timer", 1000)
b_win7 = ini.ReadBoolean("w7", False)
ini.Section = "Debug" '-----------------------------------------------------
b_debug = ini.ReadBoolean("debug", False)
b_verbose = ini.ReadBoolean("verbose", False)
b_test_nc = ini.ReadBoolean("test_nc", False)
b_send_file = ini.ReadBoolean("send_file", False)
ini.Section = "Log" '-----------------------------------------------------
b_log_enabled = ini.ReadBoolean("enabled", False)
szLogFileName = ini.ReadString("Log file")
ini.Section = "NC" '-----------------------------------------------------
b_open_control = ini.ReadBoolean("OpenControl", False)
b_force_S10WLK32 = ini.ReadBoolean("S10WLK32", False)
b_no_WinNBI = ini.ReadBoolean("No WinNBI", False)
szNameNC = ini.ReadString("name")
nVar_NC_state = ini.ReadInteger("NC state")
nVar_prg_1_ok = ini.ReadInteger("Prog1 ok")
nVar_prg_2_ok = ini.ReadInteger("Prog2 ok")
szDefaultNameNC = ini.ReadString("default_name")
szDefaultPathNC = clear_ending_bar(ini.ReadString("default_path"))
sz_ODD_program_name = ini.ReadString("ODD_name")
sz_EVEN_program_name = ini.ReadString("EVEN_name")
n_program_to_send = ini.ReadInteger("program_to_send", 1)
ini.Section = "BarCode" '-----------------------------------------------------
'[BarCode]
'fields = 1
'MASK = xx11111xxx223333xx44xxxxxx
'PreProcessing = "1-2"
n_num_barcode_fields = ini.ReadInteger("fields", 1)
sz_barcode_mask = ini.ReadString(ini.Section, "MASK", "11111111")
sz_barcode_preprocessing = ini.ReadString(ini.Section, "PreProcessing", "=")
ini.Section = "SerialBarCodeReader" '-----------------------------------------------------
'[SerialBarCodeReader]
'enabled = true
'Port = 4
'Settings=9600,n,8,1
b_SerialBarCodeReader_enabled = ini.ReadBoolean("enabled", False)
n_SerialBarCodeReader_comm_port = ini.ReadInteger("Port", 1)
sz_SerialBarCodeReader_settings = ini.ReadString(ini.Section, "Settings", "9600,None,8,1")
ini.Section = "UsbBarCodeReader" '-----------------------------------------------------
'[UsbBarCodeReader]
'enabled = true
b_UsbBarCodeReader_enabled = ini.ReadBoolean("enabled", False)
If b_UsbBarCodeReader_enabled And b_SerialBarCodeReader_enabled Then
Log.write_and_messagebox(" Both USB and serial bar code reader enabled - please disable one ... ", 34)
End
End If
b_BarCodeInput_enabled = b_UsbBarCodeReader_enabled Or b_SerialBarCodeReader_enabled
ini.Section = "FileInput" '-----------------------------------------------------
'[FileInput]
'enabled = true
'InputFile = C:\input\data.txt
b_FileInputMode_enabled = ini.ReadBoolean("enabled", False)
sz_FileInputName = ini.ReadString(ini.Section, "InputFile", "")
If b_BarCodeInput_enabled And b_FileInputMode_enabled Then
Log.write_and_messagebox(" Both file input and bar code mode enabled - please disable one ... ", 35)
End
End If
If (Not b_BarCodeInput_enabled) And (Not b_FileInputMode_enabled) Then
Log.write_and_messagebox(" No file input mode nor bar code mode enabled - please enable one ... ", 36)
End
End If
ini.Section = "Table" '-----------------------------------------------------
'[Table]
'enabled = true
'file = c:\pro_d\pro_d\prg\worklist.aut
b_Table_enabled = ini.ReadBoolean("enabled", False)
sz_table_filename = ini.ReadString("file")
b_reload_table = ini.ReadBoolean("reload", False)
ini.Section = "EXT" '-----------------------------------------------------
'[EXT]
'enabled = true
'program = C:\abc\ww.exe
'return_file = c:\pro_d\pro_d\prg\worklist.aut
b_ext_program_enabled = ini.ReadBoolean("enabled", False)
sz_ext_program_filename = ini.ReadString("program")
sz_ext_return_filename = ini.ReadString("return_file")
sz_ext_temp_filename = ini.ReadString("temp_file")
ini.Section = "CAM" '-----------------------------------------------------
'[CAM]
'enabled = true
'program = C:\abc\ww.exe
'datapath
'arguments
'return_file_ext = c:\pro_d\pro_d\prg\worklist.aut
b_CAM_program_enabled = ini.ReadBoolean("enabled", False)
sz_CAM_program_exefilename = ini.ReadString("program")
sz_CAM_data_path = (ini.ReadString("datapath"))
sz_CAM_data_path = sz_CAM_data_path.Replace("""", "")
sz_CAM_data_path = clear_ending_bar(sz_CAM_data_path)
sz_CAM_data_ext = clear_starting_point(ini.ReadString("dataext"))
sz_CAM_arguments = ini.ReadString("arguments")
sz_CAM_return_ext = clear_starting_point(ini.ReadString("return_file_ext"))
sz_CAM_Probe_ext = clear_starting_point(ini.ReadString("probe_file_ext"))
ini.Section = "Direct" '-----------------------------------------------------
'[Direct]
'enabled = true
'pre = C:\abc\ww\
'post = .cnc
b_direct_mode_enabled = ini.ReadBoolean("enabled", False)
sz_direct_prefix = ini.ReadString("pre")
sz_direct_suffix = ini.ReadString("post")
ini.Section = "Select" '-----------------------------------------------------
'[Select]
'enabled = true
'p_arguments = " 3"
'c_arguments = " 4"
'L var 1 = 916
'L var 2 = 919
'L value 1 on = 1
'L value 1 off = 0
'L value 2 on = 2
'L value 2 off = 2
'timeout = 300
' NC probe file path = m: \Cnc\DDF\
' NC probe file ext = dat
' fixed probe file = true
' NC_probe_file = UPP\PROGRA1\Data.prb
' read file = true
' prop1 = properties:
' prop2 = skinned
b_select_mode_enabled = ini.ReadBoolean("enabled", False)
sz_probe_arguments = ini.ReadString("p_arguments")
sz_cn_arguments = ini.ReadString("c_arguments")
n_L_var_1 = ini.ReadInteger("L var 1")
n_L_var_2 = ini.ReadInteger("L var 2")
n_L_value_1_on = ini.ReadInteger("L value 1 on")
n_L_value_1_off = ini.ReadInteger("L value 1 off")
n_L_value_2_on = ini.ReadInteger("L value 2 on")
n_L_value_2_off = ini.ReadInteger("L value 2 off")
n_timeout = ini.ReadInteger("timeout")
sz_nc_probe_path = ini.ReadString("NC probe file path")
sz_nc_probe_path = clear_ending_bar(sz_nc_probe_path)
sz_nc_probe_ext = clear_starting_point(ini.ReadString("NC probe file ext"))
b_fixed_probe_file = ini.ReadBoolean("fixed probe file", False)
sz_nc_fixed_probe_file = Trim(ini.ReadString("NC_probe_file"))
b_read_DDF_file = ini.ReadBoolean("read DDF file", False)
sz_property_1 = Trim(ini.ReadString("prop1"))
sz_property_2 = Trim(ini.ReadString("prop2"))
'----------- check that only one method is enabled
Dim n_methods As Short = 0
If b_Table_enabled Then n_methods = n_methods + 1
If b_ext_program_enabled Then n_methods = n_methods + 1
If b_CAM_program_enabled Then n_methods = n_methods + 1
If b_direct_mode_enabled Then n_methods = n_methods + 1
If b_select_mode_enabled Then n_methods = n_methods + 1
If n_methods > 1 Then
Log.write_and_messagebox(" Too many input modes enabled .. - please enable only one ... ", 38)
End
End If
If n_methods < 1 Then
Log.write_and_messagebox(" No input mode enabled ( CAM / Table / external / direct /.. - please enable one ... ", 40)
End
End If
ini.Section = "Key" '-----------------------------------------------------
' [Key]
' regkey = 12345
' regkey2 = 2345
' customer = qwe
registered_key = UCase$(ini.ReadString("regkey"))
registered_key2 = UCase$(ini.ReadString("regkey2"))
registered_key3 = UCase$(ini.ReadString("regkey3"))
registered_customer = ini.ReadString("Customer")
End Sub
Sub write_customer(ByVal sz_customer As String)
Dim ini As New IniReader(sz_ini_file_name)
ini.Write("Key", "Customer", sz_customer)
End Sub
Sub write_Program_path(ByVal sz_data_file_name As String)
Dim ini As New IniReader(sz_ini_file_name)
ini.Write("General", "Program path", sz_data_file_name)
End Sub
#Region "fuffa"
#End Region
End Module
+454
View File
@@ -0,0 +1,454 @@
'
' IniReader class
Imports System
Imports System.Text
Imports System.Collections
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
''' <summary>
''' The INIReader class can read keys from and write keys to an INI file.
''' </summary>
''' <remarks>
''' This class uses several Win32 API functions to read from and write to INI files. It will not work on Linux or FreeBSD.
''' </remarks>
Public Class IniReader
''' <summary>
''' The GetPrivateProfileInt function retrieves an integer associated with a key in the specified section of an initialization file.
''' </summary>
''' <param name="lpApplicationName">Pointer to a null-terminated string specifying the name of the section in the initialization file.</param>
''' <param name="lpKeyName">Pointer to the null-terminated string specifying the name of the key whose value is to be retrieved. This value is in the form of a string; the GetPrivateProfileInt function converts the string into an integer and returns the integer.</param>
''' <param name="nDefault">Specifies the default value to return if the key name cannot be found in the initialization file.</param>
''' <param name="lpFileName">Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.</param>
''' <returns>The return value is the integer equivalent of the string following the specified key name in the specified initialization file. If the key is not found, the return value is the specified default value. If the value of the key is less than zero, the return value is zero.</returns>
Private Declare Ansi Function GetPrivateProfileInt Lib "kernel32.dll" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
''' <summary>
''' The WritePrivateProfileString function copies a string into the specified section of an initialization file.
''' </summary>
''' <param name="lpApplicationName">Pointer to a null-terminated string containing the name of the section to which the string will be copied. If the section does not exist, it is created. The name of the section is case-independent; the string can be any combination of uppercase and lowercase letters.</param>
''' <param name="lpKeyName">Pointer to the null-terminated string containing the name of the key to be associated with a string. If the key does not exist in the specified section, it is created. If this parameter is NULL, the entire section, including all entries within the section, is deleted.</param>
''' <param name="lpString">Pointer to a null-terminated string to be written to the file. If this parameter is NULL, the key pointed to by the lpKeyName parameter is deleted.</param>
''' <param name="lpFileName">Pointer to a null-terminated string that specifies the name of the initialization file.</param>
''' <returns>If the function successfully copies the string to the initialization file, the return value is nonzero; if the function fails, or if it flushes the cached version of the most recently accessed initialization file, the return value is zero.</returns>
Private Declare Ansi Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
''' <summary>
''' The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.
''' </summary>
''' <param name="lpApplicationName">Pointer to a null-terminated string that specifies the name of the section containing the key name. If this parameter is NULL, the GetPrivateProfileString function copies all section names in the file to the supplied buffer.</param>
''' <param name="lpKeyName">Pointer to the null-terminated string specifying the name of the key whose associated string is to be retrieved. If this parameter is NULL, all key names in the section specified by the lpAppName parameter are copied to the buffer specified by the lpReturnedString parameter.</param>
''' <param name="lpDefault">Pointer to a null-terminated default string. If the lpKeyName key cannot be found in the initialization file, GetPrivateProfileString copies the default string to the lpReturnedString buffer. This parameter cannot be NULL. <br>Avoid specifying a default string with trailing blank characters. The function inserts a null character in the lpReturnedString buffer to strip any trailing blanks.</br></param>
''' <param name="lpReturnedString">Pointer to the buffer that receives the retrieved string.</param>
''' <param name="nSize">Specifies the size, in TCHARs, of the buffer pointed to by the lpReturnedString parameter.</param>
''' <param name="lpFileName">Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.</param>
''' <returns>The return value is the number of characters copied to the buffer, not including the terminating null character.</returns>
Private Declare Ansi Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
''' <summary>
''' The GetPrivateProfileSectionNames function retrieves the names of all sections in an initialization file.
''' </summary>
''' <param name="lpszReturnBuffer">Pointer to a buffer that receives the section names associated with the named file. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character.</param>
''' <param name="nSize">Specifies the size, in TCHARs, of the buffer pointed to by the lpszReturnBuffer parameter.</param>
''' <param name="lpFileName">Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter is NULL, the function searches the Win.ini file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.</param>
''' <returns>The return value specifies the number of characters copied to the specified buffer, not including the terminating null character. If the buffer is not large enough to contain all the section names associated with the specified initialization file, the return value is equal to the length specified by nSize minus two.</returns>
Private Declare Ansi Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer() As Byte, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
''' <summary>
''' The WritePrivateProfileSection function replaces the keys and values for the specified section in an initialization file.
''' </summary>
''' <param name="lpAppName">Pointer to a null-terminated string specifying the name of the section in which data is written. This section name is typically the name of the calling application.</param>
''' <param name="lpString">Pointer to a buffer containing the new key names and associated values that are to be written to the named section.</param>
''' <param name="lpFileName">Pointer to a null-terminated string containing the name of the initialization file. If this parameter does not contain a full path for the file, the function searches the Windows directory for the file. If the file does not exist and lpFileName does not contain a full path, the function creates the file in the Windows directory. The function does not create a file if lpFileName contains the full path and file name of a file that does not exist.</param>
''' <returns>If the function succeeds, the return value is nonzero.<br>If the function fails, the return value is zero.</br></returns>
Private Declare Ansi Function WritePrivateProfileSection Lib "kernel32.dll" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
''' <summary>Constructs a new IniReader instance.</summary>
''' <param name="file">Specifies the full path to the INI file (the file doesn't have to exist).</param>
Public Sub New(ByVal file As String)
Filename = file
End Sub
''' <summary>Gets or sets the full path to the INI file.</summary>
''' <value>A String representing the full path to the INI file.</value>
'''
Public Property Filename() As String
Get
Return m_Filename
End Get
Set(ByVal Value As String)
m_Filename = Value
End Set
End Property
''' <summary>Gets or sets the section you're working in. (aka 'the active section')</summary>
''' <value>A String representing the section you're working in.</value>
'''
Public Property Section() As String
Get
Return m_Section
End Get
Set(ByVal Value As String)
m_Section = Value
End Set
End Property
''' <summary>Reads an Integer from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The value to return if the specified key isn't found.</param>
''' <returns>Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadInteger(ByVal section As String, ByVal key As String, ByVal defVal As Integer) As Integer
Return GetPrivateProfileInt(section, key, defVal, Filename)
End Function
''' <summary>Reads an Integer from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified section/key pair, or returns 0 if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadInteger(ByVal section As String, ByVal key As String) As Integer
Return ReadInteger(section, key, 0)
End Function
''' <summary>Reads an Integer from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The section to search in.</param>
''' <returns>Returns the value of the specified Key, or returns the default value if the specified Key isn't found in the active section of the INI file.</returns>
Public Function ReadInteger(ByVal key As String, ByVal defVal As Integer) As Integer
Return ReadInteger(Section, key, defVal)
End Function
''' <summary>Reads an Integer from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified key, or returns 0 if the specified key isn't found in the active section of the INI file.</returns>
Public Function ReadInteger(ByVal key As String) As Integer
Return ReadInteger(key, 0)
End Function
''' <summary>Reads a String from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The value to return if the specified key isn't found.</param>
''' <returns>Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadString(ByVal section As String, ByVal key As String, ByVal defVal As String) As String
Dim sb As New StringBuilder(MAX_ENTRY)
Dim Ret As Integer = GetPrivateProfileString(section, key, defVal, sb, MAX_ENTRY, Filename)
Return sb.ToString()
End Function
''' <summary>Reads a String from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified section/key pair, or returns an empty String if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadString(ByVal section As String, ByVal key As String) As String
Return ReadString(section, key, "")
End Function
''' <summary>Reads a String from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified key, or returns an empty String if the specified key isn't found in the active section of the INI file.</returns>
Public Function ReadString(ByVal key As String) As String
Return ReadString(Section, key)
End Function
''' <summary>Reads a Long from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The value to return if the specified key isn't found.</param>
''' <returns>Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadLong(ByVal section As String, ByVal key As String, ByVal defVal As Long) As Long
Return Long.Parse(ReadString(section, key, defVal.ToString()))
End Function
''' <summary>Reads a Long from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified section/key pair, or returns 0 if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadLong(ByVal section As String, ByVal key As String) As Long
Return ReadLong(section, key, 0)
End Function
''' <summary>Reads a Long from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The section to search in.</param>
''' <returns>Returns the value of the specified key, or returns the default value if the specified key isn't found in the active section of the INI file.</returns>
Public Function ReadLong(ByVal key As String, ByVal defVal As Long) As Long
Return ReadLong(Section, key, defVal)
End Function
''' <summary>Reads a Long from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified Key, or returns 0 if the specified Key isn't found in the active section of the INI file.</returns>
Public Function ReadLong(ByVal key As String) As Long
Return ReadLong(key, 0)
End Function
''' <summary>Reads a Byte array from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified section/key pair, or returns null (Nothing in VB.NET) if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadByteArray(ByVal section As String, ByVal key As String) As Byte()
Try
Return Convert.FromBase64String(ReadString(section, key))
Catch
End Try
Return Nothing
End Function
''' <summary>Reads a Byte array from the specified key of the active section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified key, or returns null (Nothing in VB.NET) if the specified key pair isn't found in the active section of the INI file.</returns>
Public Function ReadByteArray(ByVal key As String) As Byte()
Return ReadByteArray(Section, key)
End Function
''' <summary>Reads a Boolean from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The value to return if the specified key isn't found.</param>
''' <returns>Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadBoolean(ByVal section As String, ByVal key As String, ByVal defVal As Boolean) As Boolean
Dim b_ret As Boolean = False
Try
b_ret = Boolean.Parse(ReadString(section, key, defVal.ToString()))
Catch
b_ret = False
End Try
Return b_ret
End Function
''' <summary>Reads a Boolean from the specified key of the specified section.</summary>
''' <param name="section">The section to search in.</param>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified section/key pair, or returns false if the specified section/key pair isn't found in the INI file.</returns>
Public Function ReadBoolean(ByVal section As String, ByVal key As String) As Boolean
Return ReadBoolean(section, key, False)
End Function
''' <summary>Reads a Boolean from the specified key of the specified section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <param name="defVal">The value to return if the specified key isn't found.</param>
''' <returns>Returns the value of the specified key pair, or returns the default value if the specified key isn't found in the active section of the INI file.</returns>
Public Function ReadBoolean(ByVal key As String, ByVal defVal As Boolean) As Boolean
Return ReadBoolean(Section, key, defVal)
End Function
''' <summary>Reads a Boolean from the specified key of the specified section.</summary>
''' <param name="key">The key from which to return the value.</param>
''' <returns>Returns the value of the specified key, or returns false if the specified key isn't found in the active section of the INI file.</returns>
Public Function ReadBoolean(ByVal key As String) As Boolean
Return ReadBoolean(Section, key)
End Function
''' <summary>Writes an Integer to the specified key in the specified section.</summary>
''' <param name="section">The section to write in.</param>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Integer) As Boolean
Return Write(section, key, value.ToString())
End Function
''' <summary>Writes an Integer to the specified key in the active section.</summary>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal key As String, ByVal value As Integer) As Boolean
Return Write(Section, key, value)
End Function
''' <summary>Writes a String to the specified key in the specified section.</summary>
''' <param name="section">Specifies the section to write in.</param>
''' <param name="key">Specifies the key to write to.</param>
''' <param name="value">Specifies the value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value As String) As Boolean
Return (WritePrivateProfileString(section, key, value, Filename) <> 0)
End Function
''' <summary>Writes a String to the specified key in the active section.</summary>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal key As String, ByVal value As String) As Boolean
Return Write(Section, key, value)
End Function
''' <summary>Writes a Long to the specified key in the specified section.</summary>
''' <param name="section">The section to write in.</param>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Long) As Boolean
Return Write(section, key, value.ToString())
End Function
''' <summary>Writes a Long to the specified key in the active section.</summary>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal key As String, ByVal value As Long) As Boolean
Return Write(Section, key, value)
End Function
''' <summary>Writes a Byte array to the specified key in the specified section.</summary>
''' <param name="section">The section to write in.</param>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value() As Byte) As Boolean
If value Is Nothing Then
Return Write(section, key, CType(Nothing, String))
Else
Return Write(section, key, value, 0, value.Length)
End If
End Function
''' <summary>Writes a Byte array to the specified key in the active section.</summary>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal key As String, ByVal value() As Byte) As Boolean
Return Write(Section, key, value)
End Function
''' <summary>Writes a Byte array to the specified key in the specified section.</summary>
''' <param name="section">The section to write in.</param>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <param name="offset">An offset in <i>value</i>.</param>
''' <param name="length">The number of elements of <i>value</i> to convert.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value() As Byte, ByVal offset As Integer, ByVal length As Integer) As Boolean
If value Is Nothing Then
Return Write(section, key, CType(Nothing, String))
Else
Return Write(section, key, Convert.ToBase64String(value, offset, length))
End If
End Function
''' <summary>Writes a Boolean to the specified key in the specified section.</summary>
''' <param name="section">The section to write in.</param>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Boolean) As Boolean
Return Write(section, key, value.ToString())
End Function
''' <summary>Writes a Boolean to the specified key in the active section.</summary>
''' <param name="key">The key to write to.</param>
''' <param name="value">The value to write.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function Write(ByVal key As String, ByVal value As Boolean) As Boolean
Return Write(Section, key, value)
End Function
''' <summary>Deletes a key from the specified section.</summary>
''' <param name="section">The section to delete from.</param>
''' <param name="key">The key to delete.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function DeleteKey(ByVal section As String, ByVal key As String) As Boolean
Return (WritePrivateProfileString(section, key, Nothing, Filename) <> 0)
End Function
''' <summary>Deletes a key from the active section.</summary>
''' <param name="key">The key to delete.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
'''
Public Function DeleteKey(ByVal key As String) As Boolean
Return (WritePrivateProfileString(Section, key, Nothing, Filename) <> 0)
End Function
''' <summary>Deletes a section from an INI file.</summary>
''' <param name="section">The section to delete.</param>
''' <returns>Returns true if the function succeeds, false otherwise.</returns>
Public Function DeleteSection(ByVal section As String) As Boolean
Return WritePrivateProfileSection(section, Nothing, Filename) <> 0
End Function
''' <summary>
''' Retrieves a list of all available sections in the INI file.
''' </summary>
''' <returns>
''' Returns an ArrayList with all available sections.
''' </returns>
Public Function GetSectionNames() As ArrayList
Try
Dim buffer(MAX_ENTRY) As Byte
GetPrivateProfileSectionNames(buffer, MAX_ENTRY, Filename)
Dim parts() As String = Encoding.ASCII.GetString(buffer).Trim(ControlChars.NullChar).Split(ControlChars.NullChar)
Return New ArrayList(parts)
Catch
End Try
Return Nothing
End Function
'Private variables and constants
''' <summary>
''' Holds the full path to the INI file.
''' </summary>
Private m_Filename As String
''' <summary>
''' Holds the active section name
''' </summary>
Private m_Section As String
''' <summary>
''' The maximum number of bytes in a section buffer.
''' </summary>
Private Const MAX_ENTRY As Integer = 32768
End Class
+60
View File
@@ -0,0 +1,60 @@
'
' libreria : VBlib
' file : L_File_aux
'
' funzioni : routines aux sui nomi file
'
' copyright 2008-2015 C.Viviani
'
Module L_File_aux
Function clear_ending_bar(ByVal a As String) As String ' clear the eventual ending "\" in a directory name
a = Trim(a)
If (Right$(a, 1) = "\") Then
a = Left$(a, Len(a) - 1)
End If
clear_ending_bar = a
End Function
Function add_ending_bar (ByVal s As String) As String
If Len(s) > 0 Then
If Right$(s, 1) <> "\" Then
add_ending_bar = s + "\"
Else
add_ending_bar = s
End If
Else
add_ending_bar = "\"
End If
End Function
Function clear_starting_point(ByVal a As String) As String ' clear the eventual starting "." in a file ext
a = Trim(a)
If (Left$(a, 1) = ".") Then
a = Right$(a, Len(a) - 1)
End If
clear_starting_point = a
End Function
Function true_false_from_yes_no(ByVal a As String) As Boolean
a = UCase$(a)
true_false_from_yes_no = False
If InStr(a, "Y") Then true_false_from_yes_no = True
If InStr(a, "S") Then true_false_from_yes_no = True
End Function
Function clear_starting_forward_bar(ByVal a As String) As String ' clear the eventual initial "/"
a = Trim(a)
If (Left$(a, 1) = "/") Then
a = Right$(a, Len(a) - 1)
End If
clear_starting_forward_bar = a
End Function
Function trim_to_n_char(ByVal a As String, ByVal n As Integer) As String
a = Trim(a)
If Len(a) > n Then a = Left$(a, n)
trim_to_n_char = a
End Function
End Module
+47
View File
@@ -0,0 +1,47 @@
'
' libreria : VBlib
' file : Log.vb
'
' funzioni : gestione log file
'
' copyright 2008-2017 C.Viviani
'
Imports System.IO
Imports Microsoft.VisualBasic
Public Module Log
Const MAX_LOG_FILE As Long = 1000000
Dim fs As FileStream
Dim szInternalFilename As String
Public Sub init(ByVal szLogFileName As String)
End Sub
Sub finish()
End Sub
Sub write(ByRef sz_arg As String)
End Sub
Sub write_and_messagebox(ByRef sz_arg As String, n_error As Integer)
End Sub
Private Sub ll_write(ByRef sz_arg As String)
End Sub
End Module
+126
View File
@@ -0,0 +1,126 @@
Module M_aspect
Const BUTTON_TOP As Integer = 380
Const BUTTON_WIDTH As Integer = 75
Const BUTTON_HEIGHT As Integer = 40
Sub init()
With FrmMain
' -------------- positions ----------------
Call Button_init()
' -------------- clear labels ----------------
.LblProgramName.Text = "---------"
' ------------ messages -------------------------
.LblCurrentProgram.Text = Message.msg(36) ' Currently machining :
.LblMachineStatus.Text = Message.msg(37) ' Machine Status :
' .LblNextProgram.Text = Message.msg(38) ' Next program :
Call button_text()
' -------------- visibilities ------------------
Call button_visibility()
.LblConnected.Visible = True
.LblProgramName.Visible = True
.LblMachineStatus.Visible = True
.LblMachState.Visible = True
.LblCurrentProgram.Visible = True
.LblNcStatus.Visible = True
If (IniRead.b_BarCodeInput_enabled Or IniRead.b_FileInputMode_enabled) And pRegistered Then
' Call M_serial_barcode.set_textbox(.TxtBarCode)
End If
' -------------- size -------------------------
' -------------- simulation ------------------
If IniRead.b_debug Then ' simulation stuff
.BtnSim0.Visible = True
.BtnSim1.Visible = True
.BtnSim2.Visible = True
.BtnSim3.Visible = True
.BtnSim4.Visible = True
.BtnSim5.Visible = True
.LblSimPrgSent1.Visible = True
.LblSimPrgSent2.Visible = True
End If
' ---------------- old osai
If (IniRead.b_force_S10WLK32 And IniRead.b_verbose) Or (IniRead.b_test_nc) Then
.BtnReadOldOsai.Visible = True
.BtnWrite1OldOsai.Visible = True
.BtnWrite2OldOsai.Visible = True
.BtnWrite3OldOsai.Visible = True
.BtnWrite4OldOsai.Visible = True
.BtnWrite5OldOsai.Visible = True
.LblReadOldOsai.Visible = True
.BtnReadOldOsai.Text = "R var " & IniRead.nVar_NC_state.ToString
.BtnWrite1OldOsai.Text = "W1"
.BtnWrite2OldOsai.Text = "W2"
.BtnWrite3OldOsai.Text = "W3"
.BtnWrite4OldOsai.Text = "W4"
.BtnWrite5OldOsai.Text = "W5"
End If
If (IniRead.b_win7 And IniRead.b_test_nc) Or (IniRead.b_send_file) Then
.Btn_test_file.Visible = True
End If
End With
End Sub
Private Sub Button_init()
With FrmMain
.BtnExit.Top = BUTTON_TOP
.BtnExit.Width = BUTTON_WIDTH
.BtnExit.Height = BUTTON_HEIGHT
.BtnExit.Left = 220
End With
End Sub
Private Sub button_visibility()
With FrmMain
.BtnExit.Visible = True
End With
End Sub
Private Sub button_text()
With FrmMain
.BtnExit.Text = Message.msg(21) ' Exit
End With
End Sub
End Module
+458
View File
@@ -0,0 +1,458 @@
Imports System.IO
Module M_cn_connection
#Region "ENUM States and Local Constants"
#End Region
#Region "Global Constants"
Public Const SLEEP_TIME As Integer = 150 ' attesa connessione CN
Public Const MAX_RETRY As Integer = 10 ' numero tentativi connessione CN
#End Region
#Region "Global Vars"
' oggetto Serie per connessione PC / CN
Public CnOsai As ComCNOsai
#End Region
#Region "local vars "
Private b_first_time As Boolean
Private nret As Int16
' Private send_mode As e_send_mode = e_send_mode.SM_SIMPLE
Private b_even As Boolean = False
Private n_prev_Value_NC_running As Byte
Private sz_NC_Program_Name As String
' Private Start_time As DateTime
' Private Stop_time As DateTime
#End Region
' ---------------------------------------------------------
' ---- Procedura per inizializzare connessione con CN -----
' ---------------------------------------------------------
' ---------------------------------------------------------
Sub StartConnection()
Dim szCmdLink As String = ""
Dim b_DotNet As Boolean
Dim b_ok As Boolean = False
FrmMain.Show()
' se non in debug
If (Not IniRead.b_debug) Then
FrmMain.LblConnected.Visible = True ' !!
FrmMain.LblConnected.Text = "Step 1....." ' !!
If IniRead.b_verbose Then
Log.write(FrmMain.LblConnected.Text & " " & IniRead.szNameNC)
FrmMain.LblConnected.Text = Message.msg(8) & IniRead.szNameNC
' MsgBox(Message.msg(8) & IniRead.szNameNC) ' connecting to
End If
' istanzio l'oggetto CN
If IniRead.b_force_S10WLK32 Or IniRead.b_open_control Or IniRead.b_no_WinNBI Then
b_ok = True
Else
b_ok = ComCNOsai.GetWinnbi(b_DotNet)
End If
If b_ok Then
If IniRead.b_open_control Then ' osai serie open ?
CnOsai = New Open_Series(IniRead.szNameNC, IniRead.b_debug)
Else
If IniRead.b_force_S10WLK32 Then ' vecchissimi cn serie 10 non winnbi ?
'CnOsai = New ComCNOSAI_S10WLK32(IniRead.szNameNC, False)
Else
If IniRead.b_no_WinNBI Then ' forzo versione non .NET
CnOsai = New ComCNOSAIVB6(IniRead.szNameNC, False)
Else
If b_DotNet Then ' win nbi con .Net
CnOsai = New ComCNOsai(IniRead.szNameNC, False)
Else
CnOsai = New ComCNOSAIVB6(IniRead.szNameNC, False)
End If ' win nbi con .Net
End If ' forzo versione non .NET
End If ' vecchissimi cn serie 10 non winnbi
End If ' osai serie open
If IniRead.b_verbose And Not IniRead.b_force_S10WLK32 And Not IniRead.b_open_control And Not IniRead.b_no_WinNBI Then
FrmMain.LblConnected.Text = "Win nbi v." & ComCNOsai.GetWinnbi_version() & "New : " & b_DotNet.ToString
Log.write("Win nbi v." & ComCNOsai.GetWinnbi_version() & "New : " & b_DotNet.ToString)
' MsgBox(ComCNOsai.GetWinnbi_version() & vbCrLf & "Nuova : " & b_DotNet.ToString, , "Win nbi version")
End If
b_ok = CnOsai.OpenSession()
FrmMain.LblConnected.Visible = True
' connessione non ok
If (CnOsai.Connected = False) Then
FrmMain.LblConnected.Text = Message.msg(11) ' "NOT CONNECTED"
FrmMain.LblConnected.ForeColor = Color.Red
MsgBox(CnOsai.ErrMsg, MsgBoxStyle.Critical, Message.msg(10)) ' Nc connection
Log.write(" Error connecting " & IniRead.szNameNC & " " & CnOsai.ErrMsg)
Else
FrmMain.LblConnected.Text = Message.msg(12) ' "NC connect ok "
FrmMain.LblConnected.ForeColor = Color.Blue
If IniRead.b_open_control Then ' if open control
Else
Do While Not CnOsai.Is_NC_running
System.Threading.Thread.Sleep(SLEEP_TIME)
Loop
End If ' if open control
End If ' connessione non ok
Log.write(FrmMain.LblConnected.Text)
Else
MsgBox("Missing Win NBI", MsgBoxStyle.Critical, "Missing Win NBI") ' Nc connection
End If
Else ' se in debug
FrmMain.LblConnected.Text = "DEBUG"
FrmMain.LblConnected.ForeColor = Color.Orange
End If
End Sub
Sub CheckConnection()
' un po' di letture per vedere se funziona
Dim b_timeout As Boolean = False
Dim n_retry As Integer
Dim n_temp As Integer
Dim Var_tmp As ComCNOsai.stVAR
' ' effetuo net use di sicurezza per evitare che il collegamento non sia stato ancora avvenuto
' szCmdLink = "net use " & Ini.DiskCn & " \\" & IniRead.szNameNc & "\PROGRA1"
' Shell(szCmdLink)
' System.Threading.Thread.Sleep(100)
n_retry = 0
Var_tmp.nAddress = nVar_NC_state
Var_tmp.nBit = 0 ' solo x evitare warning ...
Var_tmp.nNumCn = 1 ' solo x evitare warning ...
Var_tmp.szVarName = "" ' solo x evitare warning ...
If (Not IniRead.b_debug) Then
System.Threading.Thread.Sleep(SLEEP_TIME)
If IniRead.b_verbose Then Log.write(" Check NC connection 1") '
If IniRead.b_force_S10WLK32 Then ' vecchissimi cn serie 10 non winnbi ?
If IniRead.b_verbose Then Log.write("b_force_S10WLK32") '
Else
b_timeout = True
Do While n_retry < MAX_RETRY
System.Threading.Thread.Sleep(SLEEP_TIME)
Try
n_temp = CnOsai.ReadShortVar(Var_tmp)
Catch ex As Exception
MsgBox(ex.Message,, "check connection ")
End Try
If n_temp <> ComCNOsai.ERRORVALUE Then
b_timeout = False
Exit Do
End If
n_retry = n_retry + 1
If IniRead.b_verbose Then Log.write(" Check NC connection 2 : " & FrmMain.LblConnected.Text)
If Not (CnOsai Is Nothing) Then
CnOsai.CloseSession()
End If
FrmMain.LblConnected.Text = Str(n_retry)
If IniRead.b_verbose Then Log.write(" Check NC connection 3 : " & FrmMain.LblConnected.Text)
System.Threading.Thread.Sleep(SLEEP_TIME)
CnOsai.OpenSession()
If CnOsai.Connected Then
Else
FrmMain.LblConnected.Text = Str(n_retry) & " -- " & CnOsai.ErrMsg
If IniRead.b_verbose Then Log.write(" Check NC connection 4 ( bad ) : " & FrmMain.LblConnected.Text)
End If
Loop
End If
If b_timeout Then
FrmMain.LblConnected.Text = Message.msg(13) ' " CANNOT CONNECT (2)"
FrmMain.LblConnected.ForeColor = Color.OrangeRed
MsgBox(CnOsai.ErrMsg, MsgBoxStyle.Critical, Message.msg(13)) ' CANNOT CONNECT (2)
Log.write(Message.msg(13) & " - " & CnOsai.ErrMsg)
End
Else
' Imposto Label Connected con il nome del Channel utilizzato
FrmMain.LblConnected.Text = FrmMain.LblConnected.Text + " (" + IniRead.szNameNC + ")"
FrmMain.LblConnected.ForeColor = Color.DarkGreen
Log.write(FrmMain.LblConnected.Text)
End If
End If
End Sub
' -------------------------------------------------------------------------------
' ---- interfaccia con simulazione della scrittura variabili CN -----------------
' -------------------------------------------------------------------------------
Sub Write_NC_var(ByVal n_var As Integer, ByVal n_value As Integer)
Dim Var_tmp As ComCNOsai.stVAR
If Not IniRead.b_debug Then ' effettiva scrittura su CN
Var_tmp.nAddress = n_var
Var_tmp.nBit = 0 ' solo x evitare warning ...
Var_tmp.nNumCn = 1 ' solo x evitare warning ...
Var_tmp.szVarName = "" ' solo x evitare warning ...
Call CnOsai.WriteShortVar(Var_tmp, n_value)
Else ' simulation
If n_var = IniRead.nVar_prg_1_ok Then
If n_value = 0 Then
FrmMain.LblSimPrgSent1.BackColor = Color.Azure
Else
FrmMain.LblSimPrgSent1.BackColor = Color.LawnGreen
End If
End If
If n_var = IniRead.nVar_prg_2_ok Then
If n_value = 0 Then
FrmMain.LblSimPrgSent2.BackColor = Color.Azure
Else
FrmMain.LblSimPrgSent2.BackColor = Color.LawnGreen
End If
End If
End If
End Sub
' -------------------------------------------------------------------------------
' ---- interfaccia con simulazione della lettura variabili CN -------------------
' -------------------------------------------------------------------------------
Function Read_Nc_var(ByVal n_var As Integer) As Short
Dim Var_tmp As ComCNOsai.stVAR
Dim n_temp As Short
If Not IniRead.b_debug Then ' effettiva lettura da CN
Var_tmp.nAddress = n_var
Var_tmp.nBit = 0 ' solo x evitare warning ...
Var_tmp.nNumCn = 1 ' solo x evitare warning ...
Var_tmp.szVarName = "" ' solo x evitare warning ...
n_temp = CnOsai.ReadShortVar(Var_tmp)
Else ' simulation
n_temp = FrmMain.n_simulated_index ' read the state of the buttons ....
End If
Return n_temp
End Function
Sub Write_NC_L_var(ByVal n_var As Integer, ByVal d_value As Double)
Dim Var_tmp As ComCNOsai.stVAR
If Not IniRead.b_debug Then ' effettiva scrittura su CN
Var_tmp.nAddress = n_var
Var_tmp.nBit = 0 ' solo x evitare warning ...
Var_tmp.nNumCn = 1 ' solo x evitare warning ...
Var_tmp.szVarName = "" ' solo x evitare warning ...
Call CnOsai.WriteVarL(Var_tmp, d_value)
Else ' simulation
End If
End Sub
Function Read_Nc_L_var(ByVal n_var) As Double
Dim Var_tmp As ComCNOsai.stVAR
Dim d_temp As Double
If Not IniRead.b_debug Then ' effettiva lettura da CN
Var_tmp.nAddress = n_var
Var_tmp.nBit = 0 ' solo x evitare warning ...
Var_tmp.nNumCn = 1 ' solo x evitare warning ...
Var_tmp.szVarName = "" ' solo x evitare warning ...
d_temp = CnOsai.ReadVarL(Var_tmp)
Else ' simulation
d_temp = 0.1234
End If
Return d_temp
End Function
' -------------------------------------------------------------------------------
' ---- Controlla se CN è in RUN -------------------------------------------------
' -------------------------------------------------------------------------------
Function Check_NC_running() As Boolean
Dim info1 As CndexLinkDotNet.Cndex.GETINFO1DATA
Dim ProcStat As CndexLinkDotNet.Cndex.PROCDATA
Dim n_NC_status As Byte
' Dim n_NC_status_bis As Byte
info1.rap_feed_ov = 0 ' per placare i warning ma non sembra funzionare....
Check_NC_running = True
' If (CnOsai.NcInfo1(info1)) Then
' n_NC_status = info1.status
If (CnOsai.NcProcessStatus(ProcStat)) Then
n_NC_status = ProcStat.Status
Select Case n_NC_status
Case ComCNOsai.EMERG_
Check_NC_running = False
Case ComCNOsai.ERRO_
Check_NC_running = False
Case ComCNOsai.RESET_
Check_NC_running = False
Case ComCNOsai.IDLE_
Check_NC_running = False
Case ComCNOsai.CYCLE_
Check_NC_running = True
Case ComCNOsai.HOLDA_
Case ComCNOsai.RUNH_
Case ComCNOsai.HRUN_
End Select
End If
Return Check_NC_running
End Function
' -------------------------------------------------------------------------------
' ---- Get NC status -------------------------------------------------
' -------------------------------------------------------------------------------
Function Get_NC_status(ByRef n_NC_sub_status As Short) As Short
Dim info1 As CndexLinkDotNet.Cndex.GETINFO1DATA
Dim ProcStat As CndexLinkDotNet.Cndex.PROCDATA
Dim n_NC_status As Short
info1.rap_feed_ov = 0 ' per placare i warning ma non sembra funzionare....
If (CnOsai.NcProcessStatus(ProcStat)) Then
n_NC_status = ProcStat.Status
n_NC_sub_status = ProcStat.SubStatus
Else
MsgBox(CnOsai.ErrMsg)
End If
Return n_NC_status
End Function
Function CN_error_class() As Long
Return CnOsai.ErrClass
End Function
Function CN_error_num() As Long
Return CnOsai.ErrNum
End Function
End Module
+21
View File
@@ -0,0 +1,21 @@
Module M_machine
Sub get_machine_state()
machine_state = Read_Nc_var(IniRead.nVar_NC_state)
End Sub
Sub set_var_prg_1_ok(ByVal state As Integer)
Write_NC_var(IniRead.nVar_prg_1_ok, state)
End Sub
Sub set_var_prg_2_ok(ByVal state As Integer)
Write_NC_var(IniRead.nVar_prg_2_ok, state)
End Sub
End Module
+375
View File
@@ -0,0 +1,375 @@
Imports System.IO
Module M_state_machine
#Region "Global Constants"
Public Const ODD As Integer = 1
Public Const EVEN As Integer = 0 ' was 2 , changed to 0 for zero based arrays
Public Const ERR_RET As Short = 0
Public Const OK_RET As Short = 1
#End Region
#Region "ENUM States"
Public Enum mach_state_Type
T_RESET = 0
T_READY = 1
T_MACHINING_1 = 2
T_END_MACHINING_1 = 3
T_MACHINING_2 = 4
T_END_MACHINING_2 = 5
T_BAD_PART = 8
End Enum
#End Region
#Region "Global Vars"
Public machine_state As mach_state_Type
Public sim_machine_state As mach_state_Type
Public b_restarting As Boolean
Public sz_start_datetime(2) As String
Public b_running As Boolean
Public sz_next_program As String
#End Region
#Region "local variables "
Private prev_machine_state As mach_state_Type
Private entry_state As Boolean
Private b_check_new_program As Boolean
Private b_machining_odd_prog As Boolean
Private sz_dest As String
Private sz_source As String
Private sz_source_s(10) As String
#End Region
Sub init()
b_running = True
machine_state = mach_state_Type.T_RESET
prev_machine_state = mach_state_Type.T_RESET
b_restarting = False
entry_state = True
b_check_new_program = False
' set the fist machining to be ODD
Call set_b_machining_odd_prog(True)
End Sub
'
' the real main state machine
'
Sub go()
'If Not b_running Then Exit Sub
'' Call Display_machine_data()
'Call M_machine.get_machine_state()
'If entry_state Then FrmMain.LblMachState.Text = Message.msg(45) ' waiting machine to get ready......
Dim ncInfo As CndexLinkDotNet.Cndex.GETINFO1DATA
ncInfo = Nothing
Dim machineStatus As Byte
Dim modeSelected As Byte
' modi/stati vedere CncOSAI riga 85
machineStatus = CnOsai.GetMachineStatus()
modeSelected = CnOsai.GetModeSelected()
' valore bitmap dello statup IOB
Dim status As Short = 0
' power on
If CnOsai.Connected Then
status += 1
End If
' RUN mode
If (machineStatus = ComCNOsai.CYCLE_ And modeSelected = ComCNOsai.AUTO) Then
status += 2
End If
' Allarme
If (machineStatus = ComCNOsai.ERRO_) Then
status += 8
End If
' Manuale
If (modeSelected <> ComCNOsai.AUTO) Then
status += 16
End If
' Allarme
If (machineStatus = ComCNOsai.EMERG_) Then
status += 32
End If
' compongo i bit di status...
Dim IobBitmap As String
IobBitmap = "--------------" + vbCrLf
IobBitmap += "Bitmap IOB:" + vbCrLf
IobBitmap += status.ToString() + vbCrLf
IobBitmap += "--------------" + vbCrLf + vbCrLf
' per leggere variabili dichiaro la struttura
Dim temp As ComCNOsai.stVAR
temp.nAddress = nVar_NC_state ' da conf che vale 352 da
temp.nBit = 0
temp.nNumCn = 1
temp.szVarName = ""
Dim risultato As Short
risultato = CnOsai.ReadShortVar(temp)
IobBitmap += vbCrLf
IobBitmap += "Variabile " + nVar_NC_state.ToString() + ": " + risultato.ToString()
FrmMain.LblMapoIOB.Text = IobBitmap
'CnOsai.NcInfo1(ncInfo)
FrmMain.LblMachState.Text = "Status:" + machineStatus.ToString() + " / Mode: " + modeSelected.ToString()
'' wait for state 0 or 1 at beginning
'If entry_state And (machine_state = mach_state_Type.T_MACHINING_1) Then Exit Sub
'If entry_state And (machine_state = mach_state_Type.T_MACHINING_2) Then Exit Sub
'If entry_state And (machine_state = mach_state_Type.T_END_MACHINING_1) Then Exit Sub
'If entry_state And (machine_state = mach_state_Type.T_END_MACHINING_2) Then Exit Sub
'entry_state = False
'Select Case machine_state
' ' _______________________ T_RESET STATE ____________________
' Case mach_state_Type.T_RESET
' FrmMain.LblMachState.Text = Message.msg(46) ' Not Ready
' '_______________________ T_READY STATE ____________________
' Case mach_state_Type.T_READY
' FrmMain.LblMachState.Text = Message.msg(47) ' Ready
' FrmMain.LblProgramName.Text = "------"
' If prev_machine_state <> mach_state_Type.T_READY Then ' state change ??
' b_check_new_program = True ' enable 1 run only after state change
' End If ' cambio di stato
' If b_check_new_program Then '
' If get_next_item_no_qty() Then
' Call start_machining()
' b_check_new_program = False
' End If
' End If ' controllo programmi disponibili abilitato
' '_______________________ T_MACHINING_1 STATE ____________________
' Case mach_state_Type.T_MACHINING_1
' FrmMain.LblMachState.Text = Message.msg(49) ' machining
' If prev_machine_state <> mach_state_Type.T_MACHINING_1 Then ' state change ??
' If prev_machine_state = mach_state_Type.T_MACHINING_2 Then ' skipped end machining 2 ??
' End If ' skipped end machining 2
' b_check_new_program = True ' enable 1 run only after state change
' ' save start time
' sz_start_datetime(ODD) = Now.ToString
' Debug.Print(" Start time " & sz_start_datetime(ODD) & " odd/even " & Str(ODD))
' Call Log.write("Start time" & sz_start_datetime(ODD) & " odd/even " & Str(ODD))
' ' here change in queue display drawing if any
' ' here change in drawing if any
' ' Call M_wmf.picture_send(True)
' End If ' state change
' Call check_and_start()
' '_______________________ T_END_MACHINING_1 STATE ____________________
' Case mach_state_Type.T_END_MACHINING_1
' FrmMain.LblMachState.Text = Message.msg(48) ' end machining
' FrmMain.LblProgramName.Text = "------"
' If prev_machine_state <> mach_state_Type.T_END_MACHINING_1 Then ' state change ??
' ' here change in drawing if any
' End If ' state change
' Call check_and_start()
' '_______________________ T_MACHINING_2 STATE ____________________
' Case mach_state_Type.T_MACHINING_2
' FrmMain.LblMachState.Text = Message.msg(49) ' machining
' If prev_machine_state <> mach_state_Type.T_MACHINING_2 Then ' state change ??
' If prev_machine_state = mach_state_Type.T_MACHINING_1 Then ' skipped end machining 1 ??
' End If ' skipped end machining 1
' b_check_new_program = True ' enable 1 run only after state change
' ' save start time
' sz_start_datetime(EVEN) = Now.ToString
' Debug.Print(" Start time " & sz_start_datetime(EVEN) & " odd/even " & Str(EVEN))
' Call Log.write("Start time" & sz_start_datetime(EVEN) & " odd/even " & Str(EVEN))
' ' here change in queue display drawing if any
' ' here change in drawing if any
' ' Call M_wmf.picture_send(False)
' End If ' state change
' Call check_and_start()
' '_______________________ T_END_MACHINING_2 STATE ____________________
' Case mach_state_Type.T_END_MACHINING_2
' FrmMain.LblMachState.Text = Message.msg(48) ' end machining
' FrmMain.LblProgramName.Text = "------"
' If prev_machine_state <> mach_state_Type.T_END_MACHINING_2 Then ' state change ??
' ' here change in drawing if any
' End If ' state change
' Call check_and_start()
' '__________________________________________
'End Select
'prev_machine_state = machine_state
End Sub
' returns the next item from the queue ( if any )
Private Function get_next_item_no_qty() As Boolean
Dim b_ret As Boolean = False
Return b_ret
End Function
Private Sub check_and_start()
If b_check_new_program Then ' available programs check enabled ??
If get_next_item_no_qty() Then
Call start_machining()
b_check_new_program = False
End If
End If ' available programs check enabled
End Sub
' some serious processing here ....
Private Sub start_machining()
End Sub
Private Sub crea_programma()
End Sub
Private Sub set_dest_program_name()
End Sub
Private Sub set_b_machining_odd_prog(ByVal b As Boolean)
End Sub
'-------------------------------------------------------------
'-------------------------------------------------------------
#Region "my funny valentine"
'
' ritorna 1 ( OK_RET ) se ok ; 0 ( ERR_RET ) se in errore
'
Function my_f_____copy_file_to_nc(ByVal sz_Pc_file_name As String, ByVal sz_Nc_file_name As String) As Short
End Function
Sub my_f_____File_Delete(ByVal sz_to_delete As String)
End Sub
'
' ritorna 1 ( OK_RET ) se ok ; 0 ( ERR_RET ) se in errore
'
Function my_f_____copy_file_from_nc(ByVal sz_Nc_file_name As String, ByVal sz_Pc_file_name As String) As Short
End Function
#End Region
Private Sub Display_machine_data()
End Sub
End Module
+36
View File
@@ -0,0 +1,36 @@
'
' libreria : VBlib
' file : Message
'
' funzioni : gestione messaggi
'
' copyright 2008-2015 C.Viviani
'
Imports System
Imports System.IO
Imports System.IO.File
Public Module Message
Public msg() As String
Sub init()
Dim sz_filename As String
sz_filename = Application.StartupPath & "\messages\" & Application.ProductName & ".msg"
If File.Exists(sz_filename) Then '
Try
msg = System.IO.File.ReadAllLines(sz_filename)
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "Error !")
End
End Try
Else
MsgBox(" Missing message file :" & vbCrLf & sz_filename, MsgBoxStyle.Critical, "Error 3 :")
End
End If
End Sub
End Module