OmagCUT :

- Aggiunta comunicazione con il Flexium e classe astratta da cui eredita anche comunicazione Axium.
This commit is contained in:
Emmanuele Sassi
2015-11-06 10:59:21 +00:00
parent 875000091e
commit 5b647b0cde
11 changed files with 1185 additions and 232 deletions
+132
View File
@@ -0,0 +1,132 @@
Public MustInherit Class CN_generico
#Region " Constants"
Public Const MAX_AXES As Short = 10
Public Const MAX_VAR As Short = 100
Public Const MAX_VALUES As Short = 9 ' Max. index to read the data from the FXServer array
Public Const MAX_TOOLS As Short = 100
#End Region
#Region " Struct"
Public Structure ToolStructure
Public type As Char
Public lenght As Double
Public radius As Double
Public tip As Double
Public D_lenght As Double
Public D_radius As Double
Public nose_dir As String
Public comp_num As Short
End Structure
#End Region
#Region " Interface"
Public IsFlexiumPlus As Boolean = False
Public sz_CncFxIdentifier As String = ""
Public d_LinearAxisPrecision As Double
Public sz_ServerInitStatus As String
Public sz_ServerReinitStatus As String
Public sz_ManualDataInput As String
Public sz_versionRTS As String
Public sz_ConnectionAddress As String
Public sz_AffaireNumber As String
Public n_state As Short = 0
Public n_validaxes As Short
'
Public b_axis_events_enable As Boolean = False
Public d_axis_position(MAX_AXES) As Double
Public d_axis_delta(MAX_AXES) As Double
Public b_axis_valid(MAX_AXES) As Boolean
Public d_DReadELS_value As Double
Public n_DReadELS_handle As Short
Public d_Dvariable_values(MAX_VAR) As Double
Public b_Dvariable_changed As Boolean = False
Public d_DInterpo_values(MAX_AXES) As Double
Public d_DInterpo_Prog_Feed As Double
Public d_DInterpo_Feed_override As Double
Public n_activate_error_code As Short
Public l_channel_override(MAX_VALUES) As Long
Public b_feed_override_changed As Boolean = False
Public d_spindle_prog(MAX_VALUES) As Double
Public d_spindle_eff(MAX_VALUES) As Double
Public n_spindle_override(MAX_VALUES) As Short
Public b_spindle_data_changed As Boolean = False
Public Tools(MAX_TOOLS) As ToolStructure
Public b_Tool_data_changed As Boolean = False
Public Event NewPositionData(ByVal sender As Object)
Public Event NewPosDeltaData(ByVal sender As Object)
Public Event NewVarChanged(ByVal sender As Object)
Protected Overridable Sub OnNewPositionData()
RaiseEvent NewPositionData(0)
End Sub
Protected Overridable Sub OnNewPosDeltaData()
RaiseEvent NewPosDeltaData(0)
End Sub
Protected Overridable Sub OnNewVarChanged()
RaiseEvent NewVarChanged(0)
End Sub
#End Region
#Region " Metodi pubblici"
Public MustOverride Sub ReadEls_Add_Parameter(sz_var As String, n_par As Short)
Public MustOverride Sub DVariables_WriteVariables(sz_parameters As String, sz_values As String)
Public MustOverride Sub DVariables_WriteVariables2(sz_parameters As String, sz_values As String)
Public MustOverride Sub MDI_command()
Public MustOverride Function ActivateProgram(n_part_program As Integer) As Int16
Public MustOverride Sub set_OP_OM(n As Short)
Public MustOverride Function DPOsition_ReadOnce() As Short
Public MustOverride Function DGeneralFunctions_CycleStart() As Int16
Public MustOverride Function DGeneralFunctions_FeedHold() As Int16
Public MustOverride Function DGeneralFunctions_Reset() As Int16
Public MustOverride Function DGeneralFunctions_WriteCncMode(nmode As Short) As Int16
Public MustOverride Function Write_var_1(sz_par As String, lvalue As Long) As Int16
Public MustOverride Function Download_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Public MustOverride Function Upload_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Public MustOverride Function Delete_NC_prog(sz_NC_filename As String) As Int16
Public MustOverride Function Start_Transfer_NC_prog() As Int16
Public MustOverride Function DTool_set_read_range(n_start As Short, n_stop As Short) As Short
Public MustOverride Function DTool_write_tool(n_tool_number As Short, Length_X As Double, Radius As Double, TipRadius_Z As Double, _
DLength_X As Double, DTipRadius_Z As Double, _
nDirection As Short, nType As Short, nH As Integer) As Short
#End Region
End Class
+86 -91
View File
@@ -13,112 +13,107 @@
Module ConstIni
Public Const INI_FILE_NAME As String = "OmagCUT.ini"
Public Const INI_FILE_NAME As String = "OmagCUT.ini"
Public Const S_GENERAL As String = "General"
Public Const K_DEBUG As String = "Debug"
Public Const K_LICENCE As String = "Licence"
Public Const K_MESSAGESDIR As String = "MessagesDir"
Public Const K_MESSAGES As String = "Messages"
Public Const K_WINPLACE As String = "WinPlace"
Public Const K_MAXPROJ As String = "MaxProj"
Public Const K_LASTPROJ As String = "LastProj"
Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj"
Public Const K_SAVEDIR As String = "SaveDir"
Public Const K_IMAGEDIR As String = "ImageDir"
Public Const K_CAMERALINK As String = "CameraLink"
Public Const K_CNLINK As String = "CNLink"
Public Const S_GENERAL As String = "General"
Public Const K_DEBUG As String = "Debug"
Public Const K_LICENCE As String = "Licence"
Public Const K_MESSAGESDIR As String = "MessagesDir"
Public Const K_MESSAGES As String = "Messages"
Public Const K_WINPLACE As String = "WinPlace"
Public Const K_MAXPROJ As String = "MaxProj"
Public Const K_LASTPROJ As String = "LastProj"
Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj"
Public Const K_SAVEDIR As String = "SaveDir"
Public Const K_IMAGEDIR As String = "ImageDir"
Public Const K_CAMERALINK As String = "CameraLink"
Public Const K_CNLINK As String = "CNLink"
Public Const S_LUA As String = "Lua"
Public Const K_LIBSDIR As String = "LibsDir"
Public Const K_BASELIB As String = "BaseLib"
Public Const S_LUA As String = "Lua"
Public Const K_LIBSDIR As String = "LibsDir"
Public Const K_BASELIB As String = "BaseLib"
Public Const S_GEOMDB As String = "GeomDB"
Public Const K_DEFAULTFONT As String = "DefaultFont"
Public Const K_NFEFONTDIR As String = "NfeFontDir"
Public Const K_DEFAULTCOLOR As String = "DefaultColor"
Public Const K_SAVETYPE As String = "SaveType"
Public Const S_GEOMDB As String = "GeomDB"
Public Const K_DEFAULTFONT As String = "DefaultFont"
Public Const K_NFEFONTDIR As String = "NfeFontDir"
Public Const K_DEFAULTCOLOR As String = "DefaultColor"
Public Const K_SAVETYPE As String = "SaveType"
Public Const S_OPENGL As String = "OpenGL"
Public Const K_DOUBLEBUFFER As String = "DoubleBuffer"
Public Const K_COLORBITS As String = "ColorBits"
Public Const K_DEPTHBITS As String = "DepthBits"
Public Const K_DRIVER As String = "Driver"
Public Const S_OPENGL As String = "OpenGL"
Public Const K_DOUBLEBUFFER As String = "DoubleBuffer"
Public Const K_COLORBITS As String = "ColorBits"
Public Const K_DEPTHBITS As String = "DepthBits"
Public Const K_DRIVER As String = "Driver"
Public Const S_SCENE As String = "Scene"
Public Const K_BACKTOP As String = "BackTop"
Public Const K_BACKBOTTOM As String = "BackBottom"
Public Const K_SHOWGFRAME As String = "ShowGFrame"
Public Const K_MARK As String = "Mark"
Public Const K_SELSURF As String = "SelSurf"
Public Const K_SHOWMODE As String = "ShowMode"
Public Const K_CURVEDIR As String = "CurveDir"
Public Const K_SHOWTRIAADV As String = "ShowTriaAdv"
Public Const K_ZOOMWIN As String = "ZoomWin"
Public Const K_DISTLINE As String = "DistLine"
Public Const K_MMUNITS As String = "MmUnits"
Public Const S_SCENE As String = "Scene"
Public Const K_BACKTOP As String = "BackTop"
Public Const K_BACKBOTTOM As String = "BackBottom"
Public Const K_SHOWGFRAME As String = "ShowGFrame"
Public Const K_MARK As String = "Mark"
Public Const K_SELSURF As String = "SelSurf"
Public Const K_SHOWMODE As String = "ShowMode"
Public Const K_CURVEDIR As String = "CurveDir"
Public Const K_SHOWTRIAADV As String = "ShowTriaAdv"
Public Const K_ZOOMWIN As String = "ZoomWin"
Public Const K_DISTLINE As String = "DistLine"
Public Const K_MMUNITS As String = "MmUnits"
Public Const S_GRID As String = "Grid"
Public Const K_SHOWGRID As String = "ShowGrid"
Public Const K_SHOWFRAME As String = "ShowFrame"
Public Const K_SNAPSTEP As String = "SnapStep"
Public Const K_SNAPSTEPINCH As String = "SnapStepInch"
Public Const K_MINLINESSTEP As String = "MinLineSStep"
Public Const K_MAJLINESSTEP As String = "MajLineSStep"
Public Const K_EXTSSTEP As String = "ExtSStep"
Public Const K_MINLNCOLOR As String = "MinLnColor"
Public Const K_MAJLNCOLOR As String = "MajLnColor"
Public Const S_GRID As String = "Grid"
Public Const K_SHOWGRID As String = "ShowGrid"
Public Const K_SHOWFRAME As String = "ShowFrame"
Public Const K_SNAPSTEP As String = "SnapStep"
Public Const K_SNAPSTEPINCH As String = "SnapStepInch"
Public Const K_MINLINESSTEP As String = "MinLineSStep"
Public Const K_MAJLINESSTEP As String = "MajLineSStep"
Public Const K_EXTSSTEP As String = "ExtSStep"
Public Const K_MINLNCOLOR As String = "MinLnColor"
Public Const K_MAJLNCOLOR As String = "MajLnColor"
Public Const S_TABSPECIAL As String = "TabSpecial"
Public Const K_TSSHOW As String = "Show"
Public Const S_TABSPECIAL As String = "TabSpecial"
Public Const K_TSSHOW As String = "Show"
Public Const S_COMPO As String = "Compo"
Public Const K_CMPWINPLACE As String = "WinPlace"
Public Const K_COMPODIR As String = "CompoDir"
Public Const S_COMPO As String = "Compo"
Public Const K_CMPWINPLACE As String = "WinPlace"
Public Const K_COMPODIR As String = "CompoDir"
Public Const S_FLATPARTS As String = "FlatParts"
Public Const K_FLPWINPLACE As String = "WinPlace"
Public Const K_FLPCURRDIR As String = "CurrDir"
Public Const S_FLATPARTS As String = "FlatParts"
Public Const K_FLPWINPLACE As String = "WinPlace"
Public Const K_FLPCURRDIR As String = "CurrDir"
Public Const S_NEST As String = "Nest"
Public Const K_DIRECT As String = "Direct"
Public Const K_STEP As String = "Step"
Public Const S_NEST As String = "Nest"
Public Const K_DIRECT As String = "Direct"
Public Const K_STEP As String = "Step"
Public Const S_RAWPART As String = "RawPart"
Public Const K_RAWCOLOR As String = "RawColor"
Public Const K_KERFCOLOR As String = "KerfColor"
Public Const K_RAWLENGTH As String = "Length"
Public Const K_RAWWIDTH As String = "Width"
Public Const K_RAWHEIGHT As String = "Height"
Public Const K_RAWOFFSX As String = "OffsX"
Public Const K_RAWOFFSY As String = "OffsY"
Public Const K_RAWKERF As String = "Kerf"
Public Const S_RAWPART As String = "RawPart"
Public Const K_RAWCOLOR As String = "RawColor"
Public Const K_KERFCOLOR As String = "KerfColor"
Public Const K_RAWLENGTH As String = "Length"
Public Const K_RAWWIDTH As String = "Width"
Public Const K_RAWHEIGHT As String = "Height"
Public Const K_RAWOFFSX As String = "OffsX"
Public Const K_RAWOFFSY As String = "OffsY"
Public Const K_RAWKERF As String = "Kerf"
Public Const S_CAMERA As String = "Camera"
Public Const K_CAM_EXEPATH As String = "ExePath"
Public Const K_CAM_IMAGE As String = "Image"
Public Const K_CAM_INFO As String = "Info"
Public Const K_CAM_RESULT As String = "Result"
Public Const K_CAM_TIMEOUT As String = "Timeout"
Public Const S_CAMERA As String = "Camera"
Public Const K_CAM_EXEPATH As String = "ExePath"
Public Const K_CAM_IMAGE As String = "Image"
Public Const K_CAM_INFO As String = "Info"
Public Const K_CAM_RESULT As String = "Result"
Public Const K_CAM_TIMEOUT As String = "Timeout"
Public Const S_MACH As String = "Mach"
Public Const K_MACHINESDIR As String = "MachinesDir"
Public Const K_CURRMACH As String = "CurrMach"
Public Const S_MACH As String = "Mach"
Public Const K_MACHINESDIR As String = "MachinesDir"
Public Const K_CURRMACH As String = "CurrMach"
Public Const S_TOOLS As String = "Tools"
Public Const K_DRILLBIT As String = "Drillbit"
Public Const K_SAWBLADE As String = "Sawblade"
Public Const K_MILL As String = "Mill"
Public Const S_MATERIALS As String = "Materials"
Public Const K_CURRMATERIAL As String = "CurrMaterial"
Public Const K_MATERIAL As String = "Material"
Public Const K_CURRSAW As String = "CurrSaw"
Public Const S_MATERIALS As String = "Materials"
Public Const K_CURRMATERIAL As String = "CurrMaterial"
Public Const K_MATERIAL As String = "Material"
Public Const K_CURRSAW As String = "CurrSaw"
Public Const S_MRUFILES As String = "MruFiles"
Public Const S_MRUSCRIPTS As String = "MruScripts"
Public Const K_FILE As String = "File"
Public Const S_MRUFILES As String = "MruFiles"
Public Const S_MRUSCRIPTS As String = "MruScripts"
Public Const K_FILE As String = "File"
Public Const S_FILEOPEN As String = "FileOpen"
Public Const S_FILEOPEN As String = "FileOpen"
End Module
+13
View File
@@ -0,0 +1,13 @@
Module ConstMachIni
Public Const S_NUMERICALCONTROL As String = "NumericalControl"
Public Const K_TYPE As String = "Type"
Public Const S_TOOLS As String = "Tools"
Public Const K_DRILLBIT As String = "Drillbit"
Public Const K_SAWBLADE As String = "Sawblade"
Public Const K_MILL As String = "Mill"
Public Const K_SHOWTOOLCHANGER As String = "ShowToolChanger"
Public Const K_SHOWHEADEXIT As String = "ShowHeadExit"
End Module
+35 -113
View File
@@ -1,3 +1,4 @@
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
@@ -5,10 +6,11 @@ Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Windows.Threading
Namespace Num
Partial Public Class NumNC
Public Class NumNC
Inherits CN_generico
#Region " Classes"
#End Region
@@ -40,33 +42,6 @@ Namespace Num
#End Region
#Region " Constants"
Const MAX_AXES As Short = 10
Const MAX_VAR As Short = 100
Const MAX_VALUES As Short = 9 ' Max. index to read the data from the FXServer array
Const MAX_TOOLS As Short = 100
#End Region
#Region " Struct"
Public Structure ToolStructure
Public type As Char
Public lenght As Double
Public radius As Double
Public tip As Double
Public D_lenght As Double
Public D_radius As Double
Public nose_dir As String
Public comp_num As Short
End Structure
#End Region
#Region " Num objects"
' Instance the FXServer object variables
@@ -106,61 +81,6 @@ Namespace Num
#End Region
#Region " Interface"
Public Event NewPositionData(ByVal sender As Object)
Public Event NewPosDeltaData(ByVal sender As Object)
Public Event NewVarChanged(ByVal sender As Object)
Public IsFlexiumPlus As Boolean = False
Public sz_CncFxIdentifier As String = ""
Public d_LinearAxisPrecision As Double
Public sz_ServerInitStatus As String
Public sz_ServerReinitStatus As String
Public sz_ManualDataInput As String
Public sz_versionRTS As String
Public sz_ConnectionAddress As String
Public sz_AffaireNumber As String
Public n_state As Short = 0
Public n_validaxes As Short
'
Public b_axis_events_enable As Boolean = False
Public d_axis_position(MAX_AXES) As Double
Public d_axis_delta(MAX_AXES) As Double
Public b_axis_valid(MAX_AXES) As Boolean
Public d_DReadELS_value As Double
Public n_DReadELS_handle As Short
Public d_Dvariable_values(MAX_VAR) As Double
Public b_Dvariable_changed As Boolean = False
Public d_DInterpo_values(MAX_AXES) As Double
Public d_DInterpo_Prog_Feed As Double
Public d_DInterpo_Feed_override As Double
Public n_activate_error_code As Short
Public l_channel_override(MAX_VALUES) As Long
Public b_feed_override_changed As Boolean = False
Public d_spindle_prog(MAX_VALUES) As Double
Public d_spindle_eff(MAX_VALUES) As Double
Public n_spindle_override(MAX_VALUES) As Short
Public b_spindle_data_changed As Boolean = False
Public Tools(MAX_TOOLS) As ToolStructure
Public b_Tool_data_changed As Boolean = False
#End Region
#Region " local var"
Private n_dTool_range_start As Short = 1
@@ -435,6 +355,7 @@ Namespace Num
#End Region
#Region " Events"
#Region "-- FXServer -- DRunTimeSystem EVENTS"
@@ -618,7 +539,7 @@ Namespace Num
d_axis_position(ni) = CDbl(CLng(values(n))) / d_LinearAxisPrecision
Next
If b_axis_events_enable Then RaiseEvent NewPositionData(0)
If b_axis_events_enable Then MyBase.OnNewPositionData()
End Sub
@@ -638,7 +559,7 @@ Namespace Num
d_axis_delta(ni) = CDbl(CLng(values(n))) / d_LinearAxisPrecision
Next
If b_axis_events_enable Then RaiseEvent NewPosDeltaData(0)
If b_axis_events_enable Then MyBase.OnNewPosDeltaData()
End Sub
@@ -833,7 +754,7 @@ Namespace Num
d_Dvariable_values(ni) = CDbl(CLng(values(n)))
Next
If b_axis_events_enable Then RaiseEvent NewVarChanged(0)
If b_axis_events_enable Then MyBase.OnNewVarChanged()
End Sub
@@ -1117,7 +1038,7 @@ Namespace Num
#Region " Metodi pubblici"
Public Sub ReadEls_Add_Parameter(sz_var As String, n_par As Short)
Public Overrides Sub ReadEls_Add_Parameter(sz_var As String, n_par As Short)
Call objDReadELS.AddParameter(sz_var, n_par)
@@ -1126,7 +1047,7 @@ Namespace Num
'
' call DVariables_WriteVariables("E80000;E80001" , "1;2" )
Public Sub DVariables_WriteVariables(sz_parameters As String, sz_values As String)
Public Overrides Sub DVariables_WriteVariables(sz_parameters As String, sz_values As String)
Dim Valus As Object = sz_values
@@ -1136,7 +1057,7 @@ Namespace Num
End Sub
Public Sub DVariables_WriteVariables2(sz_parameters As String, sz_values As String)
Public Overrides Sub DVariables_WriteVariables2(sz_parameters As String, sz_values As String)
Dim Valus As Object = sz_values
@@ -1144,13 +1065,13 @@ Namespace Num
End Sub
Public Sub MDI_command()
Public Overrides Sub MDI_command()
Dim _FxReturn As Int16 = objDMdiCommand.ExecuteCommand(sz_ManualDataInput)
Dim n_ret As Int16 = objDMdiCommand.ExecuteCommand(sz_ManualDataInput)
If _FxReturn <> 0 Then
If n_ret <> 0 Then
MessageBox.Show("Error Execute MDI Command :" + " " + _FxReturn.ToString())
MessageBox.Show("Error Execute MDI Command :" + " " + n_ret.ToString())
End If
@@ -1159,7 +1080,7 @@ Namespace Num
' Activate program
' returns 0 = OK ; > 0 error
'
Public Function DGeneralFunctions_ActivateProgram(n_part_program As Short) As Short
Public Overrides Function ActivateProgram(n_part_program As Integer) As Int16
Dim l_glbPartProgramNumber As Long, n_ret As Short
@@ -1174,14 +1095,14 @@ Namespace Num
'
' Set DPOsition Mode OP/OM
'
Public Sub DPOsition_set_OP_OM(n As Short)
Public Overrides Sub set_OP_OM(n As Short)
objDPosition.ModeOP = n
End Sub
'
' Read Once position
' returns 0 = OK ; > 0 error
'
Public Function DPOsition_ReadOnce() As Short
Public Overrides Function DPOsition_ReadOnce() As Int16
Return objDPosition.ReadOnce(1, objDGroupManager.Handle, objDPosition.ModeOP)
@@ -1189,31 +1110,31 @@ Namespace Num
'
' Set Cycle Start
'
Public Sub DGeneralFunctions_CycleStart()
Public Overrides Function DGeneralFunctions_CycleStart() As Int16
objDGeneralFunctions.CncStart()
End Sub
End Function
'
' Set Feed Hold
'
Public Sub DGeneralFunctions_FeedHold()
Public Overrides Function DGeneralFunctions_FeedHold() As Int16
objDGeneralFunctions.CncStop()
End Sub
End Function
'
' Set NC Reset
'
Public Sub DGeneralFunctions_Reset()
Public Overrides Function DGeneralFunctions_Reset() As Int16
objDGeneralFunctions.CncReset()
End Sub
End Function
Public Sub DGeneralFunctions_WriteCncMode(nmode As Short)
Public Overrides Function DGeneralFunctions_WriteCncMode(nmode As Short) As Int16
Dim ngroup0 As Short = 0
Call objDGeneralFunctions.WriteCncMode(nmode, ngroup0)
End Sub
End Function
Public Sub DGeneralFunctions_Writevar1(sz_par As String, lvalue As Long)
Public Overrides Function Write_var_1(sz_par As String, lvalue As Long) As Int16
Dim n_ret As Short
@@ -1221,11 +1142,11 @@ Namespace Num
If n_ret <> 0 Then MsgBox("error from objDGeneralFunctions.WriteVariable" & n_ret.ToString)
End Sub
End Function
'
' da PC a CN
'
Public Function Download_NC_prog(sz_PC_filename As String, sz_NC_filename As String)
Public Overrides Function Download_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Dim n_ret As Short
Dim n_FileDelete As Short = 1, n_IgnoreMsgZone As Short = 0
@@ -1241,7 +1162,7 @@ Namespace Num
'
' da CN a pc
'
Public Function Upload_NC_prog(sz_PC_filename As String, sz_NC_filename As String)
Public Overrides Function Upload_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Dim n_ret As Short
Dim lHandle As Long = 20 ' ??
@@ -1253,7 +1174,7 @@ Namespace Num
End Function
Public Function Delete_NC_prog(sz_NC_filename As String)
Public Overrides Function Delete_NC_prog(sz_NC_filename As String) As Int16
Dim n_ret As Short
Dim lHandle As Long = 20 ' ??
@@ -1265,7 +1186,7 @@ Namespace Num
End Function
Public Function Start_Transfer_NC_prog()
Public Overrides Function Start_Transfer_NC_prog() As Int16
Dim n_ret As Short
@@ -1276,7 +1197,7 @@ Namespace Num
End Function
Public Function DTool_set_read_range(n_start As Short, n_stop As Short) As Short
Public Overrides Function DTool_set_read_range(n_start As Short, n_stop As Short) As Short
Dim n_ret As Short
@@ -1290,7 +1211,7 @@ Namespace Num
End Function
Public Function DTool_write_tool(n_tool_number As Short, Length_X As Double, Radius As Double, TipRadius_Z As Double, _
Public Overrides Function DTool_write_tool(n_tool_number As Short, Length_X As Double, Radius As Double, TipRadius_Z As Double, _
DLength_X As Double, DTipRadius_Z As Double, _
nDirection As Short, nType As Short, nH As Integer) As Short
@@ -1308,6 +1229,7 @@ Namespace Num
#End Region
End Class
End Namespace
+817
View File
@@ -0,0 +1,817 @@
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Namespace Num
Public Class NumNCOld
Inherits CN_generico
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
#Region " Classes"
#End Region
#Region " Enum"
Enum eStatetype As Int16
NOT_INIT = -999
READY = 0
BUSY = -998
End Enum
#End Region
#Region " Constants"
Const A_AXIS As Short = 6
Const RET_OK As Int16 = 0
' modi NUM Axium
Const AUTO_M = 0, SINGLE_M = 1, MDI_M = 2, DRYRUN_M = 3, SEARCH_M = 4, EDIT_M = 5, TEST_M = 6
Const MANUAL_M = 7, MOS_M = 8, SHIFTS_M = 9, TLCOMP_M = 10, LOAD_M = 13, UPLOAD_M = 15
Const V0 = &HA000, V1 = &HA001, V2 = &HA002, V3 = &HA003, V4 = &HA004, V5 = &HA005, V6 = &HA006, V7 = &HA007
Const VBY = &HA040, VW = &HA041, VL = &HA042 'VB4 doesn't accepte VB (-->VBY )
Const M0 = &HA100, M1 = &HA101, M2 = &HA102, M3 = &HA103, M4 = &HA104, M5 = &HA105, M6 = &HA106, M7 = &HA107
Const MB = &HA140, MW = &HA141, ML = &HA142
'Global Const C0=*0xA200
'C1,C2,C3,C4,C5,C6,C7,
Const CB = &HA240, CW = &HA241, CL = &HA242
Const R0 = &HA400, R1 = &HA401, R2 = &HA402, R3 = &HA403, R4 = &HA404, R5 = &HA405, R6 = &HA406, R7 = &HA407
Const RB = &HA440, RW = &HA441, RL = &HA442
Const W0 = &HA500, W1 = &HA501, W2 = &HA502, W3 = &HA503, W4 = &HA504, W5 = &HA505, W6 = &HA506, W7 = &HA507
Const WB = &HA540, WW = &HA541, WL = &HA542
Const I0 = &HA800, I1 = &HA801, I2 = &HA802, I3 = &HA803, I4 = &HA804, I5 = &HA805, I6 = &HA806, I7 = &HA807
Const IB = &HA840, IW = &HA841, IL = &HA842
Const Q0 = &HA900, Q1 = &HA901, Q2 = &HA902, Q3 = &HA903, Q4 = &HA904, Q5 = &HA905, Q6 = &HA906, Q7 = &HA907
Const QB = &HA940, QW = &HA941, QL = &HA942
Const SYN = 0 ' /* synchrone */
Const ASS = 1 ' /* assynchrone send request */
Const ASR = 2 ' /* assynchrone read response */
Const CTRL_AXES = 143
Const SPINDLE_SPEED = 144
Const SPINDLE_POS = 145, H_VAR = 147, MOS_OK = 149
Const E80000 = 150, E81000 = 151, E82000 = 152, E30000 = 166, E40000 = 167, M_DECOD = 168, DATA_PROG = 226
Const Mode = 180, ACTIVE_PROG = 181
Const REF = 128, MES = 129, DAT1 = 130, DAT2 = 131, DAT3 = 132, MIN_LIM = 133, MAX_LIM = 134, VARH = 147
Const TILT = 135, MACH_ORIGIN = 136, P17_MIN = 137, P17_MAX = 138, REF_COR = 139, REF_POS = 140, MES_POS = 141
Const TMACRO1 = &H31, TMACRO2 = &H32, TMACRO3 = &H33
Const TUT6 = 6, TLAD = 7, TIHM = 8, TNC = 12, TPAR = 5, TCALIBR = 2, TMACRO = 11, TUTIL = 13, TPASSANT = 12
Const TSi = 1, TFi = 2, SPi = 3, THi = 4, INI = 5, TABSYMB = 10, ALLMODULE = 16, CMODULE = 65, TXTFILE = 97
Const IHMFNT = 98, IHMBMP = 99, IHMRSC = 100, IHMINI = 101, IHMTXT = 102, IHMICO = 103, IHMCOD = 104
#End Region
#Region " Structures"
Structure tDNC20_Position_OPOM
Dim Valid As Byte
Dim Position As Long
Dim ToGo As Long
Dim offset As Long
End Structure
Structure tDNC20_Axes
' Dim axe(0 To 8) As tDNC20_Position_OPOM
Dim axe() As tDNC20_Position_OPOM
End Structure
Structure tDNC20_Spindle_i
Dim Valid As Byte
Dim Spindle As Long
End Structure
Structure tDNC20_Spindle
' Dim Data(0 To 3) As tDNC20_Spindle_i
Dim Data() As tDNC20_Spindle_i
End Structure
Structure tCorOutil
Dim L_X As Long
Dim RTore_Z As Long
Dim R_Radus As Long
Dim DL_DX As Long
Dim DR_DZ As Long
Dim Direc As Long
Dim Type As Long
End Structure
Public Structure My_data_struct
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> _
Public data As Byte()
End Structure
#End Region
#Region " Variabili "
Public Var600A As Byte
Public Var600B As Byte
Public Var600C As Byte
Public Var600D As Byte
Public Var600E As Byte
Public Var600F As Byte
Public var6010L As Long
Public var6014L As Long
Public var6018L As Long
Public var601CL As Long
Public var6020L As Long
Public var6024L As Long
Public var6028L As Long
Public var602CL As Long
Private iFirstVar As Integer
Private n_portNC As Integer
Private Vmminch As Long = 1000
Private NumCifreDecP4 As Long = 1000
Private aTimer As System.Timers.Timer
Private b_busy As Boolean = False
Private b_OM_pos As Boolean = True
Private global_state As eStatetype = eStatetype.NOT_INIT
Private MyData As My_data_struct
#End Region
#Region " DLL import"
Declare Function SetPLCTool Lib "LIB_UNIT2.DLL" (ByVal chinit As String) As Int16
Declare Function Get_Port Lib "LIB_UNIT2.DLL" (ByRef Port As Int16) As Int16
Declare Function Free_Port Lib "LIB_UNIT2.DLL" (ByVal Port As Int16) As Int16
Declare Function Close_Unite Lib "LIB_UNIT2.DLL" () As Int16
Declare Function WriteObjectVarious2 Lib "dnc2.DLL" (ByVal Port As Int16, ByVal qui As UInt16, ByRef pData As Int32) As Int16
Declare Function ReadObjectVarious2 Lib "dnc2.DLL" (ByVal Port As Int16, ByVal qui As UInt16, ByRef pData As Int32, ByVal Mode As UInt16) As Int16
' Declare Function WriteLadderVar Lib "dnc2.DLL" (ByVal Port As Int16, ByVal qui As UInt16, ByVal num As Int16, ByVal Nb As Int16, ByRef pData As Int32) As Int16
Declare Function StartNC Lib "dnc2.dll" (ByVal Port As Int16) As Int16
Declare Function StopNC Lib "dnc2.dll" (ByVal Port As Int16) As Int16
Declare Function InitNC Lib "dnc2.dll" (ByVal Port As Int16) As Int16
Declare Function WriteTool Lib "dnc2.dll" (ByVal Port As Int16, ByVal number As Integer, ByVal Quantity As Integer, AdrData As tCorOutil) As Int16
Declare Function ReadTool Lib "dnc2.dll" (ByVal Port As Int16, ByVal number As Integer, ByVal Quantity As Integer, ByRef d As My_data_struct, ByVal Mode As UInt16) As Int16
Declare Function DNC20_DialWithModes_2 Lib "dnc20_2.dll" (ByVal Port As Int16, ByVal pstring As String, ByVal Mode As UInt16) As Int16
Declare Function DNC20_Spindle Lib "dnc20_2.dll" (ByVal Port As Int16, ByVal Group As Int16, ByRef pData As tDNC20_Spindle, ByVal Mode As UInt16) As Int16
Declare Function ReadLadderVar Lib "dnc2.DLL" (ByVal Port As Int16, ByVal qui As UInt16, ByVal num As UInt16, ByVal Nb As UInt16, ByRef d As My_data_struct, ByVal Mode As UInt16) As Int16
Declare Function UpLoadFile Lib "dnc2.dll" (ByVal Port As Int16, ByVal prog As Int32, ByVal filename As String) As Int16
Declare Function DownLoadFile Lib "dnc2.dll" (ByVal Port As Int16, ByVal prog As Int32, ByVal filename As String) As Int16
Declare Function DncDeleteFile Lib "dnc2.dll" (ByVal Port As Int16, ByVal prog As Int32) As Int16
Declare Function DNC20_Position_OM Lib "dnc20_2.dll" (ByVal Port As Int16, ByVal Groupe As Int16, ByRef d As My_data_struct, ByVal Mode As UInt16) As Int16
Declare Function DNC20_Position_OP Lib "dnc20_2.dll" (ByVal Port As Int16, ByVal Groupe As Int16, ByRef d As My_data_struct, ByVal Mode As UInt16) As Int16
Declare Function ReadObjectVarious4 Lib "dnc2.dll" (ByVal Port As Int16, ByVal qui As UInt16, ByVal Prem As UInt16, ByVal Quantity As UInt16, ByRef d As My_data_struct, ByVal Mode As UInt16) As Int16
Declare Function WriteObjectVarious4 Lib "dnc2.dll" (ByVal Port As Int16, ByVal qui As UInt16, ByVal Prem As UInt16, ByVal Quantity As UInt16, ByRef d As My_data_struct) As Int16
#End Region
#Region " Constructor"
Sub New()
Dim nret As Integer
' !!!!!!!!!!!!!!!!!!!!!!!!!1 da leggere da file di configurazione !!!!!!!
'nret = NC_connect("COM")
nret = NC_connect("XIP01, 0, 10, 0, 0, 0")
' Create a timer and set an half second interval.
aTimer = New System.Timers.Timer()
aTimer.Interval = 500 ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Hook up the Elapsed event for the timer.
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.AutoReset = True ' Have the timer fire repeated events (true is the default)
aTimer.Enabled = True ' Start the timer
End Sub
Private Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
If Not b_busy Then
aTimer.Enabled = False
b_busy = True
Call timer_read_var() ' leggo un mucchio di variabili in un colpo solo
Call Read_machine_pos() ' leggo posizioni assi
b_busy = False
aTimer.Enabled = True
End If
End Sub
Function NC_connect(sz_connect_string As String)
Dim nret As Integer
Dim msga As String
'nret = SetPLCTool("XIP01, 0, 10, 0, 0, 0")
'nret = SetPLCTool("COM")
nret = SetPLCTool(sz_connect_string)
If nret <> 0 Then
msga = " Communication not availabe - ret = " & nret.ToString & " - " & sz_connect_string
MsgBox(msga, vbExclamation, "SetPLCTool")
End
End If
'Richiedo porta comunicazione PC-CN 2
' iport2 = 1
nret = Get_Port(n_portNC)
If nret <> 0 Then
Beep()
msga = " Gate 2 not available "
MsgBox(msga, vbOKOnly, "Get_Port - ret = " & nret.ToString)
End
End If
' eventualmente aggiungere apertura porta per PPP
'iport3 = 3
'nret = Get_Port(iport3)
global_state = eStatetype.READY
Return nret
End Function
Function NC_disconnect()
Dim nret As Integer
nret = Free_Port(n_portNC)
'nret = Close_Unite()
' eventualmente pchidere porta per PPP
' Free_Port(iport3)
Return nret
End Function
#End Region
Function timer_read_var()
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
'lettura variabili da %V600A.B a %V600D.B tramite un solo accesso in memoria per %V600A.B e lettura di 4 in serie
iFirstVar = &H600A
nret = ReadLadderVar(n_portNC, VBY, iFirstVar, 5, MyData, SYN)
If nret = 0 Then
Var600A = MyData.data(0) ' Feed_override
Var600B = MyData.data(1) ' spindle_override
Var600C = MyData.data(2)
Var600D = MyData.data(3) ' active_mode
Var600E = MyData.data(4)
b_feed_override_changed = True
d_DInterpo_Feed_override = Math.Round(Var600A * 120.0 / 255, 0)
m_MainWindow.m_MachineStatusUC.cn.b_spindle_data_changed = True
n_spindle_override(0) = Var600B
End If
'Fine lettura %V600D.B
'lettura variabili da %V6010.L a %V601C.L
iFirstVar = &H6010
nret = ReadLadderVar(n_portNC, VL, iFirstVar, 4, MyData, SYN)
If nret = 0 Then
var6010L = BitConverter.ToInt32(MyData.data, 0) ' progr. Feed
var6014L = BitConverter.ToInt32(MyData.data, 4) ' progr. speed
var6018L = BitConverter.ToInt32(MyData.data, 8)
var601CL = BitConverter.ToInt32(MyData.data, 12)
End If
d_DInterpo_Prog_Feed = var6010L
d_spindle_prog(0) = var6014L
'lettura variabili da %V6020.L a %V602C.L
iFirstVar = &H6020
nret = ReadLadderVar(n_portNC, VL, iFirstVar, 4, MyData, SYN)
If nret = 0 Then
var6020L = BitConverter.ToInt32(MyData.data, 0)
var6024L = BitConverter.ToInt32(MyData.data, 4) ' potenziometro tablet
var6028L = BitConverter.ToInt32(MyData.data, 8) ' disponibile
var602CL = BitConverter.ToInt32(MyData.data, 12) ' disponibile
End If
global_state = eStatetype.READY
Return nret
End Function
Private Function set_NC_mode(n_mode As Integer) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = WriteObjectVarious2(n_portNC, Mode, n_mode) ' 0 AUTO 1 SEQUENZIALE 2 IMD 7 MANUALE
global_state = eStatetype.READY
Return nret
End Function
Private Function set_MDI_command(sz_command As String) As Int16
Dim nret As Int16 = -1
Dim nret2 As Int16 = -1
Dim nret3 As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = WriteObjectVarious2(n_portNC, Mode, MDI_M) ' SELEZIONE MODO IMD
If nret = 0 Then
nret2 = DNC20_DialWithModes_2(n_portNC, sz_command, SYN) ' PASSO IL COMANDO SU UN BUFFER
If nret2 = 0 Then
nret3 = StartNC(n_portNC) ' DO IL CICLO
If nret3 = 0 Then
nret = WriteObjectVarious2(n_portNC, Mode, MANUAL_M) ' ' SELEZIONO MODO MANUALE
Else
nret = nret3 + 3000 ' codice di errore della StartNC
End If ' If nret3 = 0
Else
nret = nret2 + 2000 ' codice di errore della DNC20_DialWithModes_2
End If ' If nret2 = 0
End If ' If nret = 0
global_state = eStatetype.READY
Return nret
End Function
Function read_active_mode() As Int16
Return (Var600D) ' es 0 = auto, ecc.
End Function
Function Read_machine_pos()
Dim nret As Int16
Dim i As Short, n As Short
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
If (b_OM_pos) Then ' quote rispetto a 0 Macchina
nret = DNC20_Position_OM(n_portNC, 0, MyData, SYN)
Else ' quote rispetto A 0 Pezzo
nret = DNC20_Position_OP(n_portNC, 0, MyData, SYN)
End If
For i = 0 To MAX_AXES - 2 ' la costante è 10 per cui per fare da 0 a 8....
n = i * 16
b_axis_valid(i) = (MyData.data(n) <> 0)
If (i < A_AXIS) Then
d_axis_position(i) = (BitConverter.ToInt32(MyData.data, n + 4)) / Vmminch ' X
d_axis_delta(i) = (BitConverter.ToInt32(MyData.data, n + 8)) / Vmminch
Else
d_axis_position(i) = (BitConverter.ToInt32(MyData.data, n + 4)) / NumCifreDecP4 ' A
d_axis_delta(i) = (BitConverter.ToInt32(MyData.data, n + 8)) / NumCifreDecP4
End If
Next
If b_axis_events_enable Then
MyBase.OnNewPositionData()
MyBase.OnNewPosDeltaData()
End If
global_state = eStatetype.READY
Return nret
End Function
#Region " Metodi pubblici"
Public Overrides Sub ReadEls_Add_Parameter(sz_var As String, n_par As Short)
End Sub
'
' call DVariables_WriteVariables("E80000;E80001" , "1;2" )
'
Public Overrides Sub DVariables_WriteVariables(sz_parameters As String, sz_values As String)
End Sub
Public Overrides Sub DVariables_WriteVariables2(sz_parameters As String, sz_values As String)
End Sub
Public Overrides Sub MDI_command()
Dim nret As Int16 = set_MDI_command(sz_ManualDataInput)
If nret <> 0 Then
MessageBox.Show("Error Execute MDI Command :" + " " + nret.ToString())
End If
End Sub
'
' Activate program
' returns 0 = OK ; > 0 error
'
Public Overrides Function ActivateProgram(n_part_program As Integer) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = WriteObjectVarious2(n_portNC, Mode, AUTO_M) ' potrebbe essere anche modo 11 !
If nret = 0 Then
nret = WriteObjectVarious2(n_portNC, ACTIVE_PROG, n_part_program) ' notare : numero non moltiplicato * 10
End If
If nret <> 0 Then
MessageBox.Show("Error in Activate program :" + " " + nret.ToString())
End If
global_state = eStatetype.READY
Return nret
End Function
'
' Set DPOsition Mode OP/OM
'
Public Overrides Sub set_OP_OM(n As Short)
End Sub
'
' Read Once position
' returns 0 = OK ; > 0 error
'
Public Overrides Function DPOsition_ReadOnce() As Int16
End Function
'
' Set Cycle Start
'
Public Overrides Function DGeneralFunctions_CycleStart() As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = StartNC(n_portNC)
global_state = eStatetype.READY
Return nret
End Function
'
' Set Feed Hold
'
Public Overrides Function DGeneralFunctions_FeedHold() As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = StopNC(n_portNC)
global_state = eStatetype.READY
Return nret
End Function
'
' Set NC Reset
'
Public Overrides Function DGeneralFunctions_Reset() As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = InitNC(n_portNC)
global_state = eStatetype.READY
Return nret
End Function
Public Overrides Function DGeneralFunctions_WriteCncMode(nmode As Short) As Int16
Dim nret As Int16 = -1
nret = set_NC_mode(nmode)
Return nret
End Function
Public Overrides Function Write_var_1(sz_par As String, lvalue As Long) As Int16
Dim nret As Int16 = -1
Dim n_what As UInt16
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
If sz_par = "E80000" Then ' !!! da sistemare per beccare anche gli altri indirizzi
n_what = E80000
MyData.data = BitConverter.GetBytes(lvalue)
nret = WriteObjectVarious4(n_portNC, n_what, 0, 1, MyData)
Else
nret = -997
End If
global_state = eStatetype.READY
Return nret
End Function
'
' da PC a CN
'
Public Overrides Function Download_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
Dim l As Long = get_Num_prog_number(sz_NC_filename)
' nret = DncDeleteFile(iport2, l)
nret = DownLoadFile(n_portNC, l, sz_PC_filename)
global_state = eStatetype.READY
Return nret
End Function
'
' da CN a pc
'
Public Overrides Function Upload_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
Dim l As Long = get_Num_prog_number(sz_NC_filename)
nret = UpLoadFile(n_portNC, l, sz_PC_filename)
global_state = eStatetype.READY
Return nret
End Function
Private Function get_Num_prog_number(sz_in As String) As Long
Dim sz_n As String = sz_in
Dim l_prog_num As Long
If InStr(sz_n, "%") Then sz_n = sz_n.Replace("%", "")
If InStr(sz_n, ".") Then
sz_n = sz_n.Replace(".", "")
l_prog_num = CLng(sz_n)
Else
l_prog_num = CLng(sz_n) * 10
End If
Return l_prog_num
End Function
Public Overrides Function Delete_NC_prog(sz_NC_filename As String) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
Dim l As Long = get_Num_prog_number(sz_NC_filename)
nret = DncDeleteFile(n_portNC, l)
global_state = eStatetype.READY
Return nret
End Function
Public Overrides Function Start_Transfer_NC_prog() As Int16
Return 0
End Function
Public Overrides Function DTool_set_read_range(n_start As Short, n_stop As Short) As Int16
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = ReadTool(n_portNC, n_start, 1, MyData, SYN)
If nret = RET_OK Then
Tools(0).lenght = 0 ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Tools(0).radius = 0
Tools(0).comp_num = 0
b_Tool_data_changed = True
End If
global_state = eStatetype.READY
Return nret
End Function
Public Overrides Function DTool_write_tool(n_tool_number As Short, Length_X As Double, Radius As Double, TipRadius_Z As Double,
DLength_X As Double, DTipRadius_Z As Double,
nDirection As Short, nType As Short, nH As Integer) As Int16
Dim Tool As tCorOutil
Dim nret As Int16 = -1
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
' da rifare !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Tool.L_X = CLng(Length_X * 1000)
Tool.R_Radus = CLng(Radius * 1000)
Tool.RTore_Z = CLng(TipRadius_Z * 1000)
Tool.DL_DX = 0
Tool.DR_DZ = 0
Tool.Direc = 0
Tool.Type = 0
nret = WriteTool(n_portNC, n_tool_number, 1, Tool)
global_state = eStatetype.READY
Return nret
End Function
Public Function readE80000() As Int16 ' temporanea di prova .....
Dim nret As Int16 = -1
Dim ldata As Int32
If global_state <> eStatetype.READY Then
Return global_state
Exit Function
Else
global_state = eStatetype.BUSY
End If
nret = ReadObjectVarious4(n_portNC, E80000, 0, 1, MyData, SYN)
If nret = 0 Then
ldata = BitConverter.ToInt32(MyData.data, 0)
End If
global_state = eStatetype.READY
Return nret
End Function
#End Region
End Class
End Namespace
+7 -12
View File
@@ -10,9 +10,6 @@ Public Class MachinePageUC
Friend m_AlarmsPageUC As AlarmsPageUC
Friend m_ToolsDbUC As ToolsDbPageUC
'Dichiarazione variabili direttori
Friend m_sMachIniFile As String = String.Empty
Private Sub MachinePage_Initialized(sender As Object, e As EventArgs)
'Creazione delle Page UserControl
@@ -25,13 +22,6 @@ Public Class MachinePageUC
m_ToolsDbUC.SetValue(Grid.RowProperty, 1)
m_ToolsDbUC.SetValue(Grid.RowSpanProperty, 2)
' Impostazione path Ini file
Dim sTemp As String = String.Empty
GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", sTemp, m_MainWindow.GetIniFile())
m_sMachIniFile = sTemp
GetPrivateProfileString(S_MACH, K_CURRMACH, "", sTemp, m_MainWindow.GetIniFile())
m_sMachIniFile = m_sMachIniFile & "\" & sTemp & "\" & sTemp & ".ini"
End Sub
Private Sub MachinePage_Loaded(sender As Object, e As RoutedEventArgs)
@@ -46,7 +36,12 @@ Public Class MachinePageUC
End Sub
Private Sub ToolsDBBtn_Click(sender As Object, e As RoutedEventArgs) Handles ToolsDBBtn.Click
MachinePageGrid.Children.Add(m_ToolsDbUC)
For Each Page In MachinePageGrid.Children
If TypeOf Page Is ToolsDbPageUC Then
Exit Sub
End If
Next
MachinePageGrid.Children.Add(m_ToolsDbUC)
End Sub
Private Sub StartBtn_Click(sender As Object, e As RoutedEventArgs) Handles StartBtn.Click
@@ -102,7 +97,7 @@ Public Class MachinePageUC
End Sub
Private Sub ActivateBtn_Click(sender As Object, e As RoutedEventArgs) Handles ActivateBtn.Click
cn.DGeneralFunctions_ActivateProgram(900)
cn.ActivateProgram(900)
End Sub
End Class
+21 -8
View File
@@ -11,13 +11,16 @@ Public Class MachineStatusUC
Private m_MainWindow As MainWindow = Application.Current.MainWindow
'Variabile per presenza collegamento al CN
Dim m_bNCLink As Integer
Private m_bNCLink As Integer
'Variabile per tipologia CN
Private m_iNCType As Integer
'Variabile per stato CN
Private b_Nc_simulation As Boolean = False
'Classe del CN
Public WithEvents cn As Num.NumNC
Public WithEvents cn As CN_generico
Private b_new_pos_data As Boolean = False
Private b_new_delta_data As Boolean = False
@@ -31,6 +34,8 @@ Public Class MachineStatusUC
'Verifico presenza del collegamento al CN
m_bNCLink = GetPrivateProfileInt(S_GENERAL, K_CNLINK, 0, m_MainWindow.GetIniFile())
'Verifico tipologia del CN
m_iNCType = GetPrivateProfileInt(S_NUMERICALCONTROL, K_TYPE, 0, m_MainWindow.m_sMachIniFile)
If m_bNCLink Then
AddHandler RefreshTimer.Tick, AddressOf RefreshTimer_tick
RefreshTimer.Interval = TimeSpan.FromMilliseconds(100)
@@ -58,23 +63,31 @@ Public Class MachineStatusUC
Private Sub InitCn()
If (Not b_Nc_simulation) Then
If m_bNCLink = 1 Then
MachineStatusGrid.Background = Brushes.Tomato
' istanzio l'oggetto CN
Try
cn = New Num.NumNC()
Select Case m_iNCType
Case 1
cn = New Num.NumNCOld
Case Else
cn = New Num.NumNC
End Select
Catch ex As Exception
' set status to statusbar
MsgBox(ex.Message)
End Try
Select Case m_iNCType
Case 1
Case Else
While cn.n_state < 2
System.Threading.Thread.Sleep(500) ' 0.5 sec wait!!!!!!!!
End While
End Select
While cn.n_state < 2
System.Threading.Thread.Sleep(500) ' 0.5 sec wait!!!!!!!!
End While
cn.b_axis_events_enable = True
MachineStatusGrid.Background = Brushes.Gray
+7
View File
@@ -39,6 +39,7 @@ Class MainWindow
Private m_sSaveDir As String = String.Empty
Private m_sMachinesRoot As String = String.Empty
Private Shared m_sIniFile As String = String.Empty
Friend m_sMachIniFile As String = String.Empty
Private m_nDebug As Integer = 0
' Dichiarazione lista per ListBox della ImportPage
@@ -104,6 +105,12 @@ Class MainWindow
m_sTempDir = m_sDataRoot & "\" & TEMP_DIR
' Impostazione path Ini file
m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
' Impostazione path MachIni file
Dim sTemp As String = String.Empty
GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", sTemp, m_sIniFile)
m_sMachIniFile = sTemp
GetPrivateProfileString(S_MACH, K_CURRMACH, "", sTemp, m_sIniFile)
m_sMachIniFile = m_sMachIniFile & "\" & sTemp & "\" & sTemp & ".ini"
' Impostazione direttorio di salvataggio
If GetPrivateProfileString(S_GENERAL, K_SAVEDIR, "", m_sSaveDir, m_sIniFile) = 0 Then
m_sSaveDir = m_sDataRoot & "\" & SAVE_DFL_DIR
+3
View File
@@ -125,6 +125,8 @@
<DependentUpon>CadCutPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="Camera.vb" />
<Compile Include="CN_generico.vb" />
<Compile Include="ConstMachIni.vb" />
<Compile Include="ConstMsg.vb" />
<Compile Include="CurrentProjectPageUC.xaml.vb">
<DependentUpon>CurrentProjectPageUC.xaml</DependentUpon>
@@ -139,6 +141,7 @@
<DependentUpon>FrameCutPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="M_Num.vb" />
<Compile Include="M_Num_old.vb" />
<Compile Include="NestPageUC.xaml.vb">
<DependentUpon>NestPageUC.xaml</DependentUpon>
</Compile>
+1 -1
View File
@@ -15,7 +15,7 @@
<!-- Definizione della ImportPage -->
<Border Style="{StaticResource CustomBorder}" >
<Grid Name="ImportPageGrid" >
<Grid Name="ToolsDbPageGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="8*"/>
+63 -7
View File
@@ -15,11 +15,21 @@ Public Class ToolsDbPageUC
Private m_bFirst As Boolean = True
Private m_Annulla As Boolean = False
Private m_NewItem As Object
'Variabile che conserva l'utensile precedentemente selezionato usata nel caso si selezioni annulla quando si cambia utensile selezionato
Private m_OldItem As Object
' Dichiarazione Scene
Friend WithEvents ToolScene As New Scene
Dim ToolSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost
Private Sub ToolsDbPage_Initialized(sender As Object, e As EventArgs)
'Assegnazione scena all'host e posizionamento nella ToolsDbPageGrid
ToolSceneHost.Child = ToolScene
ToolSceneHost.SetValue(Grid.ColumnProperty, 2)
ToolSceneHost.SetValue(Grid.RowProperty, 0)
Me.ToolsDbPageGrid.Children.Add(ToolSceneHost)
' Assegno la lista degli utensili come sorgente del treeview
ToolTreeView.ItemsSource = ToolsList
@@ -46,13 +56,54 @@ Public Class ToolsDbPageUC
Private Sub ToolsDbPage_Loaded(sender As Object, e As RoutedEventArgs)
If m_bFirst Then
' imposto colore di default
Dim DefColor As New Color3d(0, 0, 0)
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor, m_MainWindow.GetIniFile())
ToolScene.SetDefaultMaterial(DefColor)
' imposto colori sfondo
Dim BackTopColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor, m_MainWindow.GetIniFile())
Dim BackBotColor As New Color3d(BackTopColor)
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor, m_MainWindow.GetIniFile())
ToolScene.SetViewBackground(BackTopColor, BackBotColor)
' imposto colore di evidenziazione
Dim MarkColor As New Color3d(255, 255, 0)
GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor, m_MainWindow.GetIniFile())
ToolScene.SetMarkMaterial(MarkColor)
' imposto colore per superfici selezionate
Dim SelSurfColor As New Color3d(255, 255, 192)
GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor, m_MainWindow.GetIniFile())
ToolScene.SetSelSurfMaterial(SelSurfColor)
' imposto tipo e colore del rettangolo di zoom
Dim bOutline As Boolean = True
Dim ZwColor As New Color3d(0, 0, 0)
GetPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor, m_MainWindow.GetIniFile())
ToolScene.SetZoomWinAttribs(bOutline, ZwColor)
' imposto colore della linea di distanza
Dim DstLnColor As New Color3d(255, 0, 0)
GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor, m_MainWindow.GetIniFile())
ToolScene.SetDistLineMaterial(DstLnColor)
' imposto parametri OpenGL
Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3, m_MainWindow.GetIniFile())
Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1, m_MainWindow.GetIniFile()) <> 0)
Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32, m_MainWindow.GetIniFile())
Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32, m_MainWindow.GetIniFile())
ToolScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
' inizializzo la scena (DB geometrico + visualizzazione)
ToolScene.Init()
' leggo direttorio componenti
'GetPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir, m_MainWindow.GetIniFile())
'Inizializzo le famiglie di utensili nell'albero
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
InitializeToolFamily(K_SAWBLADE, MCH_TF.SAWBLADE, EgtMsg(MSG_TOOLSDBPAGEUC + 31))
InitializeToolFamily(K_DRILLBIT, MCH_TF.DRILLBIT, EgtMsg(MSG_TOOLSDBPAGEUC + 32))
InitializeToolFamily(K_MILL, MCH_TF.MILL, EgtMsg(MSG_TOOLSDBPAGEUC + 33))
m_bFirst = False
Else
EgtSetCurrentContext(ToolScene.GetCtx())
End If
If GetPrivateProfileInt("General", "ToolChanger", 0, m_MainWindow.m_MachinePageUC.m_sMachIniFile) <> 0 Then
If GetPrivateProfileInt(S_TOOLS, K_SHOWTOOLCHANGER, 0, m_MainWindow.m_sMachIniFile) <> 0 Then
TCPosTxBl.Visibility = Windows.Visibility.Visible
TCPosTxBx.Visibility = Windows.Visibility.Visible
Else
@@ -60,7 +111,7 @@ Public Class ToolsDbPageUC
TCPosTxBx.Visibility = Windows.Visibility.Hidden
End If
If GetPrivateProfileInt("General", "Head", 0, m_MainWindow.m_MachinePageUC.m_sMachIniFile) <> 0 Then
If GetPrivateProfileInt(S_TOOLS, K_SHOWHEADEXIT, 0, m_MainWindow.m_sMachIniFile) <> 0 Then
HeadTxBl.Visibility = Windows.Visibility.Visible
HeadTxBx.Visibility = Windows.Visibility.Visible
ExitTxBl.Visibility = Windows.Visibility.Visible
@@ -129,10 +180,15 @@ Public Class ToolsDbPageUC
Private Sub RemoveBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemoveBtn.Click
If TypeOf ToolTreeView.SelectedItem Is ToolItem Then
Dim SelectedCathegory As ToolItem = ToolTreeView.SelectedItem
EgtTdbRemoveTool(SelectedCathegory.Title)
Dim SelectedItem As ToolItem = ToolTreeView.SelectedItem
EgtTdbRemoveTool(SelectedItem.Title)
For Each ToolFamily In ToolsList
If (ToolFamily.nFType And SelectedItem.nType) <> 0 Then
ToolFamily.Items.Remove(SelectedItem)
End If
Next
End If
RefreshToolTree()
'RefreshToolTree()
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
@@ -145,7 +201,7 @@ Public Class ToolsDbPageUC
End Sub
Private Sub InitializeToolFamily(sFIniConst As String, nFType As Integer, sFName As String)
If GetPrivateProfileInt(S_TOOLS, sFIniConst, 0, m_MainWindow.GetIniFile()) = 1 Then
If GetPrivateProfileInt(S_TOOLS, sFIniConst, 0, m_MainWindow.m_sMachIniFile) = 1 Then
Dim ToolCathegory As New CathegoryItem(sFName, nFType)
Dim nType As Integer = 0
Dim ToolName As String = String.Empty