I have had to remove a lot of code because of the 60000 character limit.
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_Thread = 0
CompilerError "Use Option Threadsafe!"
CompilerEndIf
#COMMaxPorts = 30
Enumeration #PB_Event_FirstCustomValue
#ComThread_Started
#ComThread_ByteReceived
#ComThread_LineReceived
#ComThread_Finished
EndEnumeration
Enumeration
#ComText
#Combo
#btn_connect
#SendText
#SendString
#SendButton
#ReceiveText
#ReceiveEdit
#status
EndEnumeration
Structure ThreadParameterStructure
Thread.i
Semaphore.i
Com$
Com.i
Receive$
Exit.i
EndStructure
Global NewList COMUsablePorts.s()
Global ThreadParameter.ThreadParameterStructure
Procedure COMGetAvailablePorts()
Protected NewList COMPortNameList.s()
Protected i.i, Directory.i, Com.i
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
For i = 1 To #COMMaxPorts
AddElement(COMPortNameList())
COMPortNameList() = "COM" + Str(i)
Next i
CompilerEndIf
ForEach COMPortNameList()
Com = OpenSerialPort(#PB_Any, COMPortNameList(), 115200, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1, 1)
If Com
AddElement(COMUsablePorts())
COMUsablePorts() = COMPortNameList()
CloseSerialPort(Com)
EndIf
Next
FreeList(COMPortNameList())
EndProcedure
;----------------------------------------------------
Procedure ComThread(*Parameter.ThreadParameterStructure)
Protected Byte.a, ReceivedBytes.i
PostEvent(#ComThread_Started)
*Parameter\Com = OpenSerialPort(#PB_Any, *Parameter\Com$, 115200, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)
If *Parameter\Com
WriteSerialPortString(*Parameter\Com, #CR$ + #CR$ + #CR$)
Repeat
If AvailableSerialPortInput(*Parameter\Com)
If ReadSerialPortData(*Parameter\Com, @Byte, 1) = 1
ReceivedBytes + 1
PostEvent(#ComThread_ByteReceived, 0, 0, 0, ReceivedBytes)
If Byte = #CR
PostEvent(#ComThread_LineReceived)
WaitSemaphore(*Parameter\Semaphore)
Else
*Parameter\Receive$ + Chr(Byte)
; Debug *Parameter\Receive$
EndIf
EndIf
Else
Delay(10)
EndIf
Until *Parameter\Exit
CloseSerialPort(*Parameter\Com)
EndIf
PostEvent(#ComThread_Finished)
EndProcedure
;-----------------enumerrations ---------------------------------------------
Enumeration
;----------------- main window ----------------------------
#main_window
#menu
#M_open:#M_edit:#M_save:#M_save_as:#M_close:#M_notepad:#M_exit:#M_setup:#M_about
#M_CSS:#M_help
#file_info:#btn_redraw
#list1
;------ homing ---------------------------
#cont_home
#btn_homeX:#btn_homeY:#btn_homeZ:#btn_homeA
#txt_home:#txt_homeX:#txt_homeY:#txt_homeZ:#txt_homeA
#txt_homeX_LED:#txt_homeY_LED:#txt_homeZ_LED:#txt_homeA_LED
;------ port ---------------------------
#cont_port
#txt_com
#txt_status
;----------- zeroing ----------------------------------
#cont_zero
#txt_zero:#txt_X:#txt_Z
#str_zeroX:#str_zeroZ
;----------- auto ----------------------
#cont_auto:
#btn_start:#btn_stop:#btn_rewind:#btn_single: #btn_pauze
#txt_auto:#txt_pauze_led:#txt_single_led: #txt_go:#txt_stop_led:#txt_run_led
#str_go
;--------- stepsize ---------------------------
#cont_stepsize
#txt_size:#txt_size1
#stepsize
#jog_x_plus :#jog_x_min:#jog_y_plus:#jog_y_min:#jog_Z_min:#jog_Z_plus:#jog_A_min:#jog_A_plus
;--------- spindel --------------
#scroll_spindel
#cont_spindel
#txt_spindel
#txt_spindel_on_LED
#txt_riem
#txt_rpm
#btn_spindel_on:#btn_spindel_off
;------------ DRO ------------------
#btn_coord
#cont_DRO
#txt_dro:#txt_dro_x: #txt_dro_xw:#str_dro_xw
#txt_dro_Y: #txt_dro_yw:#str_dro_yw
#txt_dro_z: #txt_dro_zw:#str_dro_zw
#txt_dro_a: #txt_dro_aw:#str_dro_aw
;----------- Machine DRO ---------------------------
#cont_mDRO
#txt_mdro
#txt_mdro_x:#txt_mdro_xm
#txt_mdro_y:#txt_mdro_ym
#txt_mdro_z:#txt_mdro_zm
#txt_mdro_a:#txt_mdro_am
;------ voeding --------------------------------
#cont_feed:#btn_reset_feed
#cont_feed_toer
#txt_feed_toer:#txt_feed_toer1:#txt_feed:#txt_feed1
#scroll_feed_toer:#scroll_feed
;------ MDI ------------
#edit_mdi:#cont_mdi
#txt_mdi
#str_mdi
#btn_mdi_preview
#btn_mdi_go
#btn_mdi_clear
;--------------- screen move zoom ------------------------
#btn_zoom_plus:#btn_zoom_min
#cont_screen
#btn_left:#btn_right:#btn_up:#btn_down
;------------ allerlei toetsen ----------------------------
#F1
#setting_file
#canvas:#canvas1:#canvas_work
#file:#dummy
EndEnumeration
; -------------end enumerations ------------------
Global x_step_mm.d=800 ,Z_step_mm.d=800
Global X_accel=2000,X_Deccel=50, Z_accel=2000,Z_deccel=50
Global X_spel.d=0.01 , Z_spel.d=0.01
Global X_min.d=0, X_MAx.d=400
Global Z_min.d =0,Z_max.d=300
Global y_min.d=0,y_max.d=300
Global xw_new.d,yw_new.d,zw_new.d,aw_new.d
Global Xw_old.d,yw_old.d,zw_old.d,aw_old.d
Global xm_new.d,ym_new.d,zm_new.d,am_new.d
Global xm_old.d,ym_old.d,zm_old.d,am_old.d
Global xrad_old.d,xrad_new.d
Global Dim Stap.d(4)
Global metric.d=1
Global x_steps,z_steps
Global n,teller
Global enter=0
Global lijn$
Global temp$
Global mm_inch$="mm"
Global temp,teller
;-------------------------------------------------------
Global Flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
Global win_color.l=$3B2B22
Global win_setup_color.l=$8F807E
Global Con_color=$513B2F
Global text_vgcol=$B5F8F5
Global text_agcol= $77EDE90
Global cont_backcolor=$513B2F
Global off_color=$72975E
Global on_color=$031BF6
Global work_zone_color=0
Global font6,font8,font10,font12,font18,font24,font34
Global result_x,result_Y
Global xa,xextra,yextra
Global coord=1
;-----------------------------------------
Global aantal_lijnen
Global lengte, kar_positie=0, einde_lijn=0
Global k$="",g_code$=""
Global mode=0
Global redraw=0
Global tool$,m_code$,opmerking$
Global appquit=0
Global file$
Global voeding=50
Global V_max.i,ijlgang,voeding
Global voeding$,feed$,I_mm$,V_max$,feed
Global rpm_max,rpm
Global stepsize.d=0.01
Global spindle_Status=0
Global single_line=0
Global start=0
Global i_code$,J_code$,K_code$,x_new$,y_new$,z_new$,a_new$,code$,waarde$
Global i_code.d,j_code.d,k_code.d
Global temp$
Global gcode_bepaald=0 ;
Global mdi_preview=0,mdi_go=0
Global preview=0
Global straal.d
Global angle.d
Global starthoek.d,eindhoek.d
#Epsilon=0.0001
#Draw100=$FF000000
;---------------screen canvas --------------------------------
Global x_canvas.d=800 ,y_canvas.d=400
Global x_off.d=400,y_off.D=200
Global zoom.d=1
Global g_color.q=$ffFFFAFF
Global G0_color.q=$ff7E7E80
Global G1_color.q=$ff60EAE9
Global G2_color.q=$ffFF31FF
Global G3_color.q=$ff00EAE1
Global x_canvas_old.d,X_canvas_new.d,y_canvas_old.d,y_canvas_new.d
Global redraw=0
Global ma.d,mb.d,wa.d,wb.d,xcenter.d,ycenter.d,i2.d,j2.d,oops.d
Global i.d,k.d,j.d
Declare auto()
Declare checkFloatInput(gadget, bNegativeOK.b = #True, bNegativeIntegers.b = #False)
Declare css_window()
Declare clear_canvas()
Declare do_arc_move()
Declare do_move()
Declare draw_arc()
Declare draw_grid()
Declare dro();
Declare file_frame()
Declare feed_setting()
Declare gcode_uitvoeren()
Declare home()
Declare init_vars()
Declare load_data()
Declare load_file()
Declare load_fonts()
Declare main_window()
Declare mdi_input()
Declare M_DRO()
Declare menu()
Declare opmerking()
Declare opmerking1()
Declare OnGadgetEvent()
;Declare onchangeevent()
Declare ontrafel()
Declare ontrafel_old()
Declare onwindowEvent()
Declare port()
Declare redraw()
Declare setup_button();
Declare save_data()
Declare save_file()
Declare save_as_file()
Declare save_tooltabel()
Declare SetButtonColor(Id, text$,text_color, back_color)
Declare set_machine_coord_active()
Declare set_work_coord_active()
Declare screen_pos()
Declare spindel()
Declare spindel_ON_OFF()
Declare sneltoets()
Declare stapgrootte()
Declare stepsize()
Declare test_limieten()
Declare tool_setup_window()
Declare uncheck_rpm()
Declare update_canvas()
;Declare update_draw_arc()
Declare update_DRO_X()
Declare update_DRO_Z()
Declare update_positie()
Declare update_screen()
Declare vind_waarde()
Declare voeding()
Declare zero()
COMGetAvailablePorts()
main_window()
sneltoets()
BindEvent(#PB_Event_Gadget, @OnGadgetEvent())
init_vars()
#MenuEvent_ReturnKey = 1000
;---------------------------------------------------------------
Procedure DoEventGadgetType()
Protected gadget = EventGadget()
If IsGadget(gadget)
Select GadgetType(gadget)
Case #PB_GadgetType_String
Select EventType()
Case #PB_EventType_Focus
SetGadgetText(gadget,"0.0") ;set predefined text
AddKeyboardShortcut(#main_window, #PB_Shortcut_Return, #MenuEvent_ReturnKey)
SetGadgetColor(gadget, #PB_Gadget_BackColor,$E0E292);set color blue
Case #PB_EventType_LostFocus
RemoveKeyboardShortcut(#main_window, #PB_Shortcut_Return)
SetGadgetColor(gadget, #PB_Gadget_BackColor, $C7F5F6 );reset to color
EndSelect
EndSelect
EndIf
EndProcedure
;----------------------------------------------------------------------------------------------
Procedure DoEventReturnKey()
PostEvent(#PB_Event_Gadget, GetActiveWindow(), GetActiveGadget(), #PB_EventType_ReturnKey)
EndProcedure
;----------------------------------------------------------------
Define event
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case #main_Window
Select Event
Case #ComThread_Started
SetGadgetText(#btn_Connect, "DISCONNECT")
DisableGadget(#Combo, #True)
SetGadgetText(#txt_status,"CONNECTED"):SetGadgetColor(#txt_status,#PB_Gadget_BackColor,$49F31E)
Case #ComThread_LineReceived
; AddGadgetItem(#ReceiveEdit, -1, ThreadParameter\Receive$)
; Debug ThreadParameter\Receive$
ThreadParameter\Receive$ = ""
SignalSemaphore(ThreadParameter\Semaphore)
Case #ComThread_Finished
SetGadgetText(#btn_Connect, "CONNECT")
DisableGadget(#Combo, #False)
SetGadgetText(#txt_status,"DISCONNECTED"):SetGadgetColor(#txt_status,#PB_Gadget_BackColor,$491EF3)
Case #PB_Event_CloseWindow
appquit=1
Case #PB_Event_Gadget
Select EventGadget()
Case #btn_reset_feed
SetGadgetState(#scroll_feed,100) : feed_setting()
Case #scroll_feed
feed_setting()
Case #btn_redraw
zoom=1:
redraw()
update_screen()
Case #btn_zoom_plus
zoom=zoom*2
redraw():update_screen()
Case #btn_zoom_min
zoom=zoom/2
redraw():update_screen()
Case #btn_left
x_off=x_off-50
redraw():update_screen()
Case #btn_right
x_off=x_off+50
redraw():update_screen()
Case #btn_down
y_off=y_off+50
redraw():update_screen()
Case #btn_up
y_off=y_off-50
redraw():update_screen()
Case #str_dro_xw
If coord=1
Select EventType()
Case #PB_EventType_ReturnKey
SetActiveGadget(#dummy)
EndSelect
EndIf
Case #str_dro_yw
If coord=1
Select EventType()
Case #PB_EventType_ReturnKey
SetActiveGadget(#dummy)
EndSelect
EndIf
Case #str_dro_zw
Select EventType()
Case #PB_EventType_ReturnKey
SetActiveGadget(#dummy)
EndSelect
Case #str_dro_aw
If coord=1
Select EventType()
Case #PB_EventType_ReturnKey
SetActiveGadget(#dummy)
EndSelect
EndIf
Case #btn_spindel_on
spindel_ON_OFF()
Case #btn_Connect
If GetGadgetText(#btn_Connect) = "CONNECT"
ThreadParameter\Com$ = GetGadgetText(#Combo)
ThreadParameter\Exit = #False
ThreadParameter\Thread = CreateThread(@ComThread(), @ThreadParameter)
Else
ThreadParameter\Exit = #True
EndIf
Case #btn_homeX
SetGadgetColor(#txt_homex_led, #PB_Gadget_BackColor,($0CFD00))
xM_new=x_min: update_screen()
Case #btn_homey
SetGadgetColor(#txt_homey_led, #PB_Gadget_BackColor,($0CFD00))
xm_new=y_min: update_screen()
Case #btn_homeZ
SetGadgetColor(#txt_homeZ_led, #PB_Gadget_BackColor,($0CFD00))
zM_new=z_max: update_screen()
EndSelect
;*****************************************
Case #PB_Event_Menu
Select EventMenu()
Case #btn_left
x_off=x_off-20:update_screen()
Case #btn_right
x_off=x_off+20:update_screen()
Case #jog_x_plus
xw_new=xw_old+stepsize : xM_new=xm_old+stepsize
mode=1:update_screen()
Case #jog_x_min
xw_new=xw_old-stepsize : xM_new=xm_old-stepsize
mode=1:update_screen()
Case #jog_y_plus
yw_new=yw_old+stepsize : yM_new=ym_old+stepsize
mode=1:update_screen()
Case #jog_y_min
yw_new=yw_old-stepsize : yM_new=xm_old-stepsize
mode=1:update_screen()
Case #jog_Z_min
zw_new=zw_old-stepsize : zM_new=zm_old-stepsize
mode=1:update_screen()
Case #jog_Z_plus
zw_new=zw_old+stepsize : zM_new=zm_old+stepsize
mode=1:update_screen()
Case #jog_a_min
aw_new=aw_old-stepsize : aM_new=am_old-stepsize
mode=1:update_screen()
Case #jog_a_plus
aw_new=aw_old+stepsize : aM_new=am_old+stepsize
mode=1:update_screen()
Case #M_open
load_file()
Case #M_edit
Case #M_save
save_file()
Case #M_save_as
save_as_file()
Case #M_close
If ReadFile(#file, file$) :CloseFile(#file)
file$="":SetGadgetText(#file_info,file$)
ClearGadgetItems(#list1)
redraw() :EndIf
Case #M_exit ;einde
appquit=1
Case #M_notepad ;open notepad
RunProgram("notepad.exe")
Case #stepsize
stapgrootte()
EndSelect
EndSelect
EndSelect
Until appquit=1
;--------------------------------------------------------
If IsThread(ThreadParameter\Thread)
ThreadParameter\Exit = #True
If WaitThread(ThreadParameter\Thread, 3000) = 0
KillThread(ThreadParameter\Thread)
EndIf
EndIf
FreeSemaphore(ThreadParameter\Semaphore)
End
;-----------------------schermopbouw --------------------------------------------
Procedure main_window()
result_x=1366:result_y=768
load_fonts()
OpenWindow (#main_window,0,0,result_x,result_y, "LUDO CNC" ,flags )
SetWindowColor(#main_window,win_color):SetGadgetFont(#PB_Any,FontID(font10))
If CreateMenu(#menu, WindowID(#main_window))
MenuTitle("FILE")
MenuItem(#M_open, "OPEN" )
MenuItem(#M_edit, "EDIT")
MenuItem(#M_close,"CLOSE")
MenuItem(#M_save,"SAVE")
MenuItem(#M_save_as,"SAVE AS")
MenuItem(#M_exit, "EXIT" )
MenuItem(#M_notepad,"NOTEPAD")
MenuItem(#M_about,"ABOUT")
MenuTitle("SETUP")
EndIf
menu()
TextGadget(#file_info,950,440,400,20,"GEEN FILE")
ListViewGadget(#list1,950,460,400,120)
TextGadget(#dummy,0,600,1,1,"")
ButtonGadget(#btn_coord,850,180,170,25,"WORK / MACH") :coord=1
CanvasGadget(#canvas,20,20,800,400)
clear_canvas()
init_vars()
port()
home()
dro():m_dro(): HideGadget(#cont_mDRO, 1)
auto()
screen_pos()
spindel()
stepsize()
voeding()
mdi_input()
CreateMenu(#main_window, WindowID(#main_window))
BindEvent(#PB_Event_Gadget, @DoEventGadgetType())
BindMenuEvent(#main_window, #MenuEvent_ReturnKey, @DoEventReturnKey())
EndProcedure
;---------------------------------------------------------------------
Procedure mdi_input()
ContainerGadget(#cont_mdi,950,590,400,150,#PB_Container_Raised ): SetGadgetColor(#cont_home, #PB_Gadget_BackColor, Con_color)
SetGadgetFont(#PB_Default, FontID(font10))
TextGadget(#txt_mdi,5,5,80,15,"MDI INPUT")
ButtonGadget(#btn_mdi_preview,300,25,90,30,"PREVIEW")
ButtonGadget(#btn_mdi_go,300,65,90,30,"RUN MDI")
ButtonGadget(#btn_mdi_clear,300,105,90,30,"MDI CLEAR")
EditorGadget(#edit_mdi, 1, 25, 285, 115)
EndProcedure
;------------------------------------------------------------------------
Procedure auto()
Define xk.i=10 ,yk.i=40
Define xb.i=100 , yh=30,yt=50 ,xt=120
ContainerGadget(#cont_auto,185,530,265,210,#PB_Container_Raised)
SetGadgetColor(#cont_auto, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget(#txt_auto,40,10,190,20,"AUTO (ctrl+key)")
SetGadgetColor(#txt_auto, #PB_Gadget_FrontColor,text_vgcol):SetGadgetColor(#txt_auto, #PB_Gadget_BackColor, Con_color )
ButtonGadget(#btn_start,xk,yk,90,yh ,"RUN",#PB_Button_Toggle )
TextGadget(#txt_run_led,105,yk,15,yh," "):SetGadgetColor(#txt_run_led, #PB_Gadget_BackColor, off_color)
ButtonGadget(#btn_pauze,xk+xt,yk,xb,yh ,"(P)AUZE",#PB_Button_Toggle )
TextGadget(#txt_pauze_led,xk+xt+xb+5,yk,15,yh," "):SetGadgetColor(#txt_pauze_led, #PB_Gadget_BackColor, off_color)
ButtonGadget(#btn_rewind,xk,yk+yt,xb,yh ,"RE(W)IND")
ButtonGadget(#btn_single,xk+xt,yk+yt,xb,yh,"SING(L)E",#PB_Button_Toggle )
TextGadget(#txt_single_led,xk+xt+xb+5,yk+yt,15,yh," "):SetGadgetColor(#txt_single_led, #PB_Gadget_BackColor, $6565A6)
TextGadget(#txt_go,xk,yk+2*yt,xb,20,"GO(T)O LINE", #PB_Text_Center )
StringGadget(#str_go,xk+xt,yk+2*yt,xb,yh ,"")
CloseGadgetList()
EndProcedure
;-------------------------------------------------------------------------------------
Procedure DRO()
ContainerGadget(#cont_DRO,850,20,170,150, #PB_Container_Raised )
SetGadgetColor(#cont_DRO, #PB_Gadget_BackColor, Con_color )
TextGadget(#txt_dro,15,5,190,20,"WORK COORDINATE "+ mm_inch$)
SetGadgetFont(#txt_dro, FontID(font8))
SetGadgetColor(#txt_dro, #PB_Gadget_BackColor,0):SetGadgetColor(#txt_dro, #PB_Gadget_FrontColor, $C7F5F6)
SetGadgetFont(#PB_Default, FontID(font18))
TextGadget(#txt_dro_x,10,25,36,26," X "):SetGadgetColor(#txt_dro_X, #PB_Gadget_BackColor, $C7F5F6 )
StringGadget(#str_dro_xw,55,25,100,26,"0.00") :SetGadgetColor(#str_dro_xw, #PB_Gadget_BackColor, $C7F5F6 )
TextGadget(#txt_dro_y,10,55,36,26," Y "):SetGadgetColor(#txt_dro_y, #PB_Gadget_BackColor, $C7F5F6 )
StringGadget(#str_dro_yw,55,55,100,26,"0.00") :SetGadgetColor(#str_dro_yw, #PB_Gadget_BackColor, $C7F5F6)
TextGadget(#txt_dro_z,10,85,36,26," Z ") :SetGadgetColor(#txt_dro_z, #PB_Gadget_BackColor, $C7F5F6)
StringGadget(#str_dro_zw,55,85,100,26,"0.00") :SetGadgetColor(#str_dro_zw, #PB_Gadget_BackColor, $C7F5F6 )
TextGadget(#txt_dro_a,10,115,36,26," A ") :SetGadgetColor(#txt_dro_a, #PB_Gadget_BackColor, $C7F5F6)
StringGadget(#str_dro_aw,55,115,100,26,"0.00") :SetGadgetColor(#str_dro_aw, #PB_Gadget_BackColor, $C7F5F6 )
CloseGadgetList()
EndProcedure
;---------------------------------------------------------------------
Procedure M_DRO()
coord=0
ContainerGadget(#cont_mDRO,850,20,170,150, #PB_Container_Double )
SetGadgetColor(#cont_mDRO, #PB_Gadget_BackColor, Con_color )
TextGadget(#txt_mdro,15,5,190,20,"MACH COORDINATE "+ mm_inch$)
SetGadgetFont(#txt_mdro, FontID(font8))
SetGadgetColor(#txt_mdro, #PB_Gadget_BackColor,0):SetGadgetColor(#txt_mdro, #PB_Gadget_FrontColor, $E2EA00)
SetGadgetFont(#PB_Default, FontID(font18))
TextGadget(#txt_mdro_x,10,25,36,26," X "):SetGadgetColor(#txt_mdro_X, #PB_Gadget_BackColor, $E2EA00 )
TextGadget(#txt_mdro_xm,55,25,100,26,"0.00") :SetGadgetColor(#txt_mdro_xm, #PB_Gadget_BackColor, $E2EA00 )
TextGadget(#txt_mdro_y,10,55,36,26," Y "):SetGadgetColor(#txt_mdro_y, #PB_Gadget_BackColor, $E2EA00 )
TextGadget(#txt_mdro_ym,55,55,100,26,"0.00") :SetGadgetColor(#txt_mdro_ym, #PB_Gadget_BackColor, $E2EA00)
TextGadget(#txt_mdro_z,10,85,36,26," Z ") :SetGadgetColor(#txt_mdro_z, #PB_Gadget_BackColor, $E2EA00)
TextGadget(#txt_mdro_zm,55,85,100,26,"0.00") :SetGadgetColor(#txt_mdro_zm, #PB_Gadget_BackColor, $E2EA00 )
TextGadget(#txt_mdro_a,10,115,36,26," A ") :SetGadgetColor(#txt_mdro_a, #PB_Gadget_BackColor, $E2EA00)
TextGadget(#txt_mdro_am,55,115,100,26,"0.00") :SetGadgetColor(#txt_mdro_am, #PB_Gadget_BackColor, $E2EA00 )
CloseGadgetList()
EndProcedure
;---------------------------------------------------------------------
Procedure menu()
If CreateMenu(#menu, WindowID(#main_window))
MenuTitle("FILE")
MenuItem(#M_open, "OPEN" )
MenuItem(#M_edit, "EDIT")
MenuItem(#M_save,"SAVE")
MenuItem(#M_save_as,"SAVE AS")
MenuItem(#M_exit, "EXIT" )
MenuItem(#m_close,"CLOSE FILE")
MenuItem(#M_notepad,"NOTEPAD")
MenuItem(#M_about,"ABOUT")
MenuTitle("SETUP")
MenuItem( #M_setup, "SETUP")
EndIf
EndProcedure
;----------------------------------------------------------------
Procedure home()
Define xk.i=35 ,yk.i=40
Define cx.i=20,cy.i=530,cb.i=150,ch.i=210
Define xb.i=100 , yh.i=30,yt.i=40
ContainerGadget(#cont_home,cx,cy,cb,ch,#PB_Container_Raised )
SetGadgetColor(#cont_home, #PB_Gadget_BackColor, Con_color)
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget(#txt_home,15,5,120,15,"HOME ctrl+axis")
SetGadgetColor(#txt_home, #PB_Gadget_FrontColor,text_vgcol)
SetGadgetColor(#txt_home, #PB_Gadget_BackColor,Con_color)
; SetGadgetFont(#txt_home_titel,FontID(1))
SetGadgetFont(#PB_Default, FontID(font12))
ButtonGadget(#btn_homeX,xk,yk, xb,yh," HOME X")
ButtonGadget(#btn_homey,xk,(yk+yt), xb,yh," HOME Y")
ButtonGadget(#btn_homeZ,xk,(yk+(2*yt)), xb,yh, " HOME Z")
ButtonGadget(#btn_homeA,xk,(yk+(3*yt)), xb,yh," HOME A", #PB_Button_Left )
TextGadget(#txt_homeX_LED,10,yk,20,yh,"") : SetGadgetColor(#txt_homeX_LED, #PB_Gadget_BackColor,$0000FD )
TextGadget(#txt_homeY_LED,10,(yk +yt),20,yh,"") : SetGadgetColor(#txt_homeY_LED, #PB_Gadget_BackColor,$0000FD )
TextGadget(#txt_homeZ_LED,10,(yk+(2*yt)),20,yh,"") : SetGadgetColor(#txt_homeZ_LED, #PB_Gadget_BackColor,$0000FD )
TextGadget(#txt_homeA_LED,10,(yk+(3*yt)),20,yh,""):SetGadgetColor(#txt_homeA_LED, #PB_Gadget_BackColor,$0000FD)
; SetGadgetFont(#PB_Default, FontID(font18))
CloseGadgetList()
EndProcedure
;-----------------------------------------------------------------------------------------
Procedure port()
ContainerGadget(#cont_port,20,480,320,40, #PB_Container_Double )
SetGadgetColor(#cont_port, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font10))
ComboBoxGadget(#Combo, 110, 6, 70, 22)
ForEach COMUsablePorts()
AddGadgetItem(#COMbo, -1, COMUsablePorts())
Next
SetGadgetState(#Combo, 0)
ThreadParameter\Semaphore = CreateSemaphore()
ButtonGadget(#btn_connect, 5, 4, 95, 25, "CONNECT")
TextGadget(#txt_status,190,8,110,20,"DISCONNECTED", #PB_Text_Center ):SetGadgetColor(#txt_status,#PB_Gadget_BackColor,$491EF3)
CloseGadgetList()
EndProcedure
;---------------------------------------------------------------------------
Procedure spindel()
Define xk.i=10 ,yk.i=40 ;positie knop
Define xb.i=100 , yh=30,yt=50 ,xt=120
ContainerGadget(#cont_spindel,465,530,170,210,#PB_Container_Raised )
SetGadgetColor(#cont_spindel, #PB_Gadget_BackColor,Con_color )
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget (#txt_spindel,25,10,150,20," SPINDLE ")
SetGadgetColor(#txt_spindel, #PB_Gadget_FrontColor,text_vgcol):SetGadgetColor(#txt_spindel, #PB_Gadget_BackColor,Con_color )
ButtonGadget( #btn_spindel_on,xk,yk,95,yh,"OFF " ,#PB_Button_Toggle)
TextGadget(#txt_spindel_on_led,xk+100,yk,15,30," "):SetGadgetColor(#txt_spindel_on_led, #PB_Gadget_BackColor,off_color)
ScrollBarGadget(#scroll_spindel,xt+10,yk,15,150, 0,rpm_max/4, 1,#PB_ScrollBar_Vertical)
SetGadgetState(#scroll_spindel,0)
TextGadget(#txt_riem,xk,yk+YT,xb,yh+10," MAX RPM = "+Str(rpm_max))
TextGadget(#txt_rpm,xk,yk+2*yt,xb,yh," RPM "+Str(rpm), #PB_Text_Center)
CloseGadgetList()
EndProcedure
;----------------------------------------------------------
Procedure stepsize()
Define xk.i=10 ,yk.i=30
Define xb.i=100 , yh=30,yt=50 ,xt=120
stap(0)=0.001:stap(1)=0.01:stap(2)=0.1:stap(3)=1:stap(4)=10
stepsize=Stap(2)
ContainerGadget(#cont_stepsize,785,530,115,70,#PB_Container_Raised )
SetGadgetColor(#cont_stepsize, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget (#txt_size,5,7,110,15,"V=STEPSIZE")
SetGadgetColor(#txt_size, #PB_Gadget_BackColor, Con_color ) : SetGadgetColor(#txt_size, #PB_Gadget_FrontColor,text_vgcol)
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget (#txt_size1,30,30,50,20,StrD(stap(1)), #PB_Text_Center)
CloseGadgetList()
EndProcedure
;----------------------------------------------------------
Procedure screen_pos()
ContainerGadget(#cont_screen,360,445,350,75,#PB_Container_Raised )
ButtonGadget(#btn_redraw,5,7,80,20,"REDRAW")
ButtonGadget (#btn_up,95,7,70,20,"(U)p")
ButtonGadget(#btn_down,95,40,70,20,"(D)own")
ButtonGadget(#btn_left,180,7,70,20,"(L)eft")
ButtonGadget(#btn_right,180,40,70,20,"(R)ight")
ButtonGadget(#btn_zoom_min,265,7,70,20,"ZOOM(-)")
ButtonGadget(#btn_zoom_plus,265,40,70,20,"ZOOM(+)")
SetGadgetColor(#cont_screen, #PB_Gadget_BackColor, Con_color)
CloseGadgetList()
EndProcedure
;--------------------------------------------------------------------------------
Procedure zero()
Define xs.i=44 ,ys.i=40
Define xb.i=100,yh=30,yt=50
ContainerGadget(#cont_zero,185,550,165,130,#PB_Container_Raised )
SetGadgetColor(#cont_zero, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget(#txt_zero,5,10,180,15,"SET WORK alt+axis")
SetGadgetColor(#txt_zero, #PB_Gadget_FrontColor,text_vgcol): SetGadgetColor(#txt_zero, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font18))
StringGadget(#str_zeroZ,xs,ys,xb,yh,"0")
StringGadget(#str_zeroX,xs,ys+yt,xb,yh,"0")
TextGadget(#txt_z,10,ys,25,30,"Z", #PB_Text_Center )
SetGadgetColor(#txt_Z, #PB_Gadget_BackColor, $8AF392 )
TextGadget(#txt_x,10,ys+yt,25,30,"X", #PB_Text_Center ) : SetGadgetColor(#txt_x, #PB_Gadget_BackColor, $8AF392 )
CloseGadgetList()
EndProcedure
;---------------------------------------------------------------------
Procedure checkFloatInput(gadget, bNegativeOK.b = #True, bNegativeIntegers.b = #False)
Protected start, count, pointcount, new$
SendMessage_(GadgetID(gadget), #EM_GETSEL, @start, 0)
Protected txt$ = GetGadgetText(gadget)
Protected *p.Character = @txt$
While *p\c ; <> 0
If *p\c = '.'
pointcount+1
If pointcount < 2 And Not bNegativeIntegers
new$ + Chr(*p\c)
Else
If start>count : start-1 : EndIf
EndIf
ElseIf count = 0 And *p\c = '-' And bNegativeOK
new$ + Chr('-')
ElseIf *p\c >= '0' And *p\c <= '9'
new$ + Chr(*p\c)
Else
start - 1
EndIf
*p + SizeOf(Character)
count + 1
Wend
If bNegativeIntegers
If Len(new$) = 0 Or new$ = "-" Or ValD(new$) >= 0
new$ = "-1"
EndIf
EndIf
SetGadgetText(gadget, new$)
SendMessage_(GadgetID(gadget), #EM_SETSEL, start, start)
EndProcedure
;------------------------------------------------------------------------
Procedure clear_canvas()
StartDrawing(CanvasOutput(#canvas))
Box( 0,0,800,400,$0)
StopDrawing()
draw_grid()
EndProcedure
;------------------------------------------------------------
Procedure do_move()
xw_new=ValD(x_new$):zw_new=ValD(Z_new$)
x_steps=xw_old-xw_new:z_steps=zw_old-zw_new
update_screen()
xw_old=xw_new:zw_old=zw_new
EndProcedure
;-------------------------------------------------------------------------------
Procedure do_arc_move()
EndProcedure
;--------------------------------------------------------
Procedure draw_grid()
Define text$
StartVectorDrawing(CanvasVectorOutput(#canvas))
VectorSourceColor($60ffffff)
MovePathCursor(400,10)
AddPathLine(400,390)
MovePathCursor(10,200)
AddPathLine(790,200)
AddPathBox(5,5,790,390)
StrokePath(1)
AddPathBox(8,350,80,40)
VectorSourceColor(RGBA(148,164,193, 50))
FillPath()
VectorFont(FontID(font18), 25)
VectorSourceColor(RGBA(255, 255, 0, 250))
Text$ = "TEST"
MovePathCursor(10,360)
DrawVectorText(Text$)
StopVectorDrawing()
EndProcedure
;---------------------------------------------------------------------------
Procedure feed_setting()
Define percent
percent=GetGadgetState(#scroll_feed)
feed$=Str(feed*percent/100)
SetGadgetText (#txt_feed,"FEED "+mm_inch$+ " /min ")
SetGadgetText(#txt_feed1,feed$)
EndProcedure
;------------------------------------------------------------------------
Procedure gcode_uitvoeren()
Select g_code$
Case "0","00"
feed=v_max:feed_setting():mode=0
Case "1","01"
feed=voeding:feed_setting():mode=1
Case "2","02"
feed=voeding:feed_setting():mode=2
Case "3","03"
feed=voeding:feed_setting():mode=3
Case "4"
Case "17"
Case "18"
Case "19"
Case "20"
mm_inch$="inch"
SetGadgetText(#txt_dro,"WORK COORDINATE "+ mm_inch$ )
SetGadgetText (#txt_feed,"FEED "+mm_inch$+ " /min ")
metric=0
Case "21"
mm_inch$="mm": SetGadgetText(#txt_dro,"WORK COORDINATE "+ mm_inch$)
SetGadgetText (#txt_feed,"FEED "+mm_inch$+ " /min ")
metric=1
Case "28"
Case "30"
Case "G40" ,"G41"
Case "43"
Case "49"
Case "54"
Case "64"
Case "G80"
Case "81"
Case "82"
Case "83"
Case "84";
Case "89"
Case "90"
Case "91"
Case "G92"
Case "92.1";
EndSelect
EndProcedure
;----------------------------------------------------------------------
Procedure init_vars()
load_data()
mm_inch$="mm"
metric=1
feed=50:feed$=Str(feed):v_max=1500
x_min=-20:x_max=400
y_min=-20:y_max=200
z_min=0:z_max=300
xw_new=0:xw_old=0:yw_new=0:yw_old=0:zw_old=0:zw_new=0:aw_old=0:aw_new=0
coord=1
EndProcedure
;--------------------------------------------------------
Procedure load_data()
If ReadFile(#setting_file, "settings.dat")
While Eof( #setting_file) = 0
X_step_mm=ValD(ReadString(#setting_file))
Z_step_mm=ValD(ReadString(#setting_file))
X_accel=Val(ReadString(#setting_file))
X_deccel=Val(ReadString(#setting_file))
Z_accel=Val(ReadString(#setting_file))
z_deccel=Val(ReadString(#setting_file))
X_spel=ValD(ReadString(#setting_file))
Z_spel=ValD(ReadString(#setting_file))
X_min=ValD(ReadString(#setting_file))
X_max=ValD(ReadString(#setting_file))
Z_min=ValD(ReadString(#setting_file))
Z_max=ValD(ReadString(#setting_file))
Wend
CloseFile( #setting_file)
Else
MessageRequester("","Settings not found ,use default!")
EndIf
EndProcedure
;--------------------------------------------------------------
Procedure load_file()
Define StandardFile$,keuze
Define Pattern$
Define Pattern
Define length.l,*MemoryID , bytes
aantal_lijnen=1
StandardFile$ = "C:\*.*"
Pattern$ ="All files (*.*)|*.*;file(*.tap)|*.cnc"
Pattern = 0
File$ = OpenFileRequester("Please choose file to load", StandardFile$, Pattern$, Pattern)
ClearGadgetItems(#list1)
If ReadFile(#file, file$)
length = Lof(#file)
*MemoryID = AllocateMemory(length)
If *MemoryID
bytes = ReadData(#file, *MemoryID, length)
EndIf
CloseFile(#file)
EndIf
If File$
If OpenFile( #file, file$)
ReadFile( #file, file$)
While Eof( #file) = 0
AddGadgetItem (#list1, -1, Str(aantal_lijnen)+" "+ReadString(#file))
aantal_lijnen=aantal_lijnen+1
Wend
CloseFile( #file)
EndIf
aantal_lijnen=aantal_lijnen-1
Else
MessageRequester("Information", "FILE OPEN was canceled.", 0)
EndIf
keuze=0;
SetGadgetText(#file_info,file$)
redraw()
EndProcedure
;----------------------------------------------------------------------------------------
Procedure load_fonts()
font6=LoadFont(#PB_Any,"arial",6, #PB_Font_Italic|#PB_Font_Bold)
font8=LoadFont(#PB_Any,"arial",8, #PB_Font_Italic|#PB_Font_Bold)
font10=LoadFont(#PB_Any,"arial",10, #PB_Font_Italic|#PB_Font_Bold)
font12=LoadFont(#PB_Any,"arial",12, #PB_Font_Italic|#PB_Font_Bold)
font18=LoadFont(#PB_Any,"arial",18, #PB_Font_Italic|#PB_Font_Bold)
font24=LoadFont(#PB_Any,"arial",24, #PB_Font_Italic|#PB_Font_Bold)
font34=LoadFont(#PB_Any,"arial",34, #PB_Font_Italic|#PB_Font_Bold)
EndProcedure
;----------------------------------------------------------------------------------------
Procedure OnGadgetEvent()
Select EventGadget()
Case #str_dro_xw
If EventType() = #PB_EventType_LostFocus
checkFloatInput(EventGadget(), #True)
x_new$=GetGadgetText(#str_dro_Xw) : xw_new =ValD(x_new$)
mode=1:update_screen():update_DRO_X()
xw_old=xw_new
EndIf
Case #str_dro_zw
If EventType() = #PB_EventType_LostFocus
checkFloatInput(EventGadget(), #True)
zw_new=ValD(GetGadgetText(#str_dro_zw))
mode=1: update_screen():update_DRO_Z()
zw_old=zw_new
EndIf
Case #btn_mdi_preview
mdi_preview=1
n= CountGadgetItems(#edit_mdi)
For teller=0 To n
lijn$ = GetGadgetItemText(#edit_mdi, teller)
ontrafel()
update_screen()
Next
mdi_preview=0
Case #btn_mdi_go
mdi_go=1
Case #btn_mdi_clear
ClearGadgetItems(#edit_mdi)
ontrafel() :update_screen()
Case #scroll_spindel
rpm=GetGadgetState(#scroll_spindel)
rpm=rpm*4
SetGadgetText(#txt_rpm,"RPM="+Str(rpm))
Case #btn_single
If single_line=1
single_line=0
SetGadgetColor(#txt_single_led, #PB_Gadget_BackColor,off_color)
Else
single_line=1
SetGadgetColor(#txt_single_led, #PB_Gadget_BackColor,on_color)
EndIf
Case #btn_start
If start=1
start=0
SetGadgetColor(#txt_run_led, #PB_Gadget_BackColor,off_color)
Else
start=1
SetGadgetColor(#txt_run_led, #PB_Gadget_BackColor, on_color)
SetGadgetColor(#txt_pauze_led, #PB_Gadget_BackColor,off_color)
EndIf
Case #btn_pauze
If start=1
start=0
SetGadgetColor(#txt_run_led, #PB_Gadget_BackColor,off_color)
SetGadgetColor(#txt_pauze_led, #PB_Gadget_BackColor,on_color)
EndIf
Case #btn_coord
If coord=1: coord=0 :set_machine_coord_active()
Else
coord=1:set_work_coord_active()
EndIf
EndSelect
EndProcedure
;--------------------------------------------------------------
Procedure opmerking()
k$="":opmerking$="("
Repeat
If kar_positie<lengte
kar_positie= kar_positie+1
k$= Mid(lijn$, kar_positie ,1)
opmerking$=opmerking$+k$ :k$=""
Else
k$="q"
EndIf
Until k$= "q"
EndProcedure
;----------------------------------------------------------------------------------------
Procedure ontrafel()
lengte=Len(lijn$)
kar_positie=1:k$="":g_code$="": einde_lijn=0
While kar_positie<lengte
k$= Mid(lijn$, kar_positie ,1) :code$=""
If k$ > "A" And k$ < "{"
Select k$
Case "G","g"
vind_waarde():g_code$=waarde$:gcode_uitvoeren()
Case "T"
vind_waarde():tool$=waarde$
If redraw=1: MessageRequester("TOOLCHANGE","TOOL :"+tool$):EndIf
Case "M"
vind_waarde():m_code$=waarde$
Case "X","x"
vind_waarde():x_new$=waarde$:xw_new=ValD(x_new$)
Case "Y","y"
vind_waarde():y_new$=waarde$:yw_new=ValD(y_new$)
Case "Z","z"
vind_waarde():z_new$=waarde$:zw_new=ValD(z_new$)
Case "A","a"
vind_waarde():a_new$=waarde$:aw_new=ValD(a_new$)
Case "F","f"
vind_waarde():voeding$=waarde$: feed=Val(voeding$):feed_setting()
Case "I","i"
vind_Waarde():i_code$=waarde$
Case "J","j"
vind_Waarde():j_code$=waarde$
Case "K","k"
vind_Waarde():k_code$=waarde$
EndSelect
EndIf
kar_positie = kar_positie+1
Wend
EndProcedure
;----------------------------------------------------------------
Procedure save_file()
Define fo,tmp$
If file$=""
MessageRequester("INFO","GEEN FILENAAM")
Else
fo = OpenFile(#file,File$)
If fo
For n=0 To CountGadgetItems(#list1)
tmp$ = GetGadgetItemText(#list1,n)
WriteStringN(#file, tmp$)
Next
CloseFile(#file)
MessageRequester("","File created successfully.")
Else
MessageRequester("","Cannot create file.",#MB_ICONERROR)
EndIf
EndIf
EndProcedure
;----------------------------------------------------------------------
Procedure save_as_file()
Define pattern$,tmp$
Define pattern,kk,ii
Pattern$ = "Text (*.nc)"
Pattern = 0
File$ = SaveFileRequester("Please choose file name", "", Pattern$, Pattern)
If File$
If ReadFile(#file,File$)
CloseFile(#file)
i=MessageRequester("Warning","File already exists. Overwrite ?",#PB_MessageRequester_YesNo)
If i= #PB_MessageRequester_No
ProcedureReturn
EndIf
EndIf
If GetExtensionPart(File$) = ""
File$ + ".nc"
EndIf
ii = OpenFile(#file,File$)
If ii
For kk=0 To CountGadgetItems(#list1)
tmp$ = GetGadgetItemText(#list1,i)
WriteStringN(#file, tmp$)
Next
CloseFile(#file)
MessageRequester("","File created successfully.")
Else
MessageRequester("","Cannot create file.",#MB_ICONERROR)
EndIf
EndIf
EndProcedure
;------------------------------------------------------------------------------------------
Procedure set_machine_coord_active()
HideGadget(#cont_DRO,1)
HideGadget(#cont_mDRO, 0)
SetGadgetText(#txt_dro,"MACH COORDINATE "+ mm_inch$)
SetGadgetColor(#txt_dro, #PB_Gadget_FrontColor, $E2EA00)
update_screen()
EndProcedure
;--------------------------------------------------------------
Procedure set_work_coord_active()
HideGadget(#cont_DRO,0)
HideGadget(#cont_mDRO, 1)
SetGadgetText(#txt_dro,"WORK COORDINATE "+ mm_inch$)
SetGadgetColor(#txt_dro, #PB_Gadget_FrontColor, $C7F5F6)
update_screen()
EndProcedure
Procedure spindel_on_off()
If spindle_Status =1
spindle_status=0
SetGadgetText( #btn_spindel_on,"OFF")
SetGadgetColor(#txt_spindel_on_LED, #PB_Gadget_BackColor,off_color)
Else
spindle_Status=1
SetGadgetText( #btn_spindel_on,"ON")
SetGadgetColor(#txt_spindel_on_LED, #PB_Gadget_BackColor,on_color)
EndIf
EndProcedure
;----------------------------------------------------------
Procedure sneltoets() ;sneltoetsen voor keybord events
AddKeyboardShortcut(#main_window, #PB_Shortcut_F1,#F1)
AddKeyboardShortcut(#main_window, #PB_Shortcut_V,#stepsize);stepsize
AddKeyboardShortcut(#main_window,#PB_Shortcut_Left,#jog_x_MIN)
AddKeyboardShortcut(#main_window,#PB_Shortcut_Right,#jog_x_plus)
AddKeyboardShortcut(#main_window,#PB_Shortcut_Up,#jog_y_plus)
AddKeyboardShortcut(#main_window,#PB_Shortcut_Down,#jog_y_min)
AddKeyboardShortcut(#main_window,#PB_Shortcut_PageDown,#jog_Z_MIN)
AddKeyboardShortcut(#main_window,#PB_Shortcut_PageUp,#jog_Z_plus)
AddKeyboardShortcut(#main_window,#PB_Shortcut_End,#jog_a_MIN)
AddKeyboardShortcut(#main_window,#PB_Shortcut_Home,#jog_a_plus)
EndProcedure
;--------------------------------------------------------------------
Procedure stapgrootte()
stepsize=stepsize*10
If stepsize>10
stepsize=0.01
EndIf
SetGadgetText(#txt_size1,StrD(stepsize))
EndProcedure
;-----------------------------------------------------------------------
Procedure redraw()
clear_canvas()
For n=0 To aantal_lijnen
lijn$=GetGadgetItemText (#list1,n)
ontrafel()
update_screen()
Next
EndProcedure
;------------------------------------------------------------------------------
Procedure update_DRO_X() ;
Static w$
If coord=1
w$=FormatNumber(xw_new.d,3,".","")
SetGadgetText(#str_dro_xw,w$)
Else
w$=FormatNumber(xm_new.d,2,".","")
SetGadgetText(#txt_mdro_xm,w$)
EndIf
EndProcedure
;----------------------------------------------------------
Procedure update_DRO_y()
Static w$
If coord=1
w$=FormatNumber(yw_new.d,3,".","") ;work
SetGadgetText(#str_dro_yw,w$)
Else
w$=FormatNumber(ym_new.d,2,".","");machine
SetGadgetText(#txt_mdro_ym,w$)
EndIf
EndProcedure
;--------------------------------------------------------
Procedure update_DRO_Z()
Static w$
If coord=1
w$=FormatNumber(zw_new.d,3,".","") ;work
SetGadgetText(#str_dro_zw,w$)
Else
w$=FormatNumber(zm_new.d,2,".","");machine
SetGadgetText(#txt_mdro_zm,w$)
EndIf
EndProcedure
;--------------------------------------------------------
Procedure update_DRO_a()
Static w$
If coord=1
w$=FormatNumber(aw_new.d,3,".","") ;work
SetGadgetText(#str_dro_aw,w$)
Else
w$=FormatNumber(am_new.d,2,".","");machine
SetGadgetText(#txt_mdro_am,w$)
EndIf
EndProcedure
;--------------------------------------------------------
Procedure update_screen()
If mode=2:g_color=G2_color: draw_arc():EndIf
If mode=3:g_color=G3_color: draw_arc():EndIf
StartVectorDrawing(CanvasVectorOutput(#canvas))
FlipCoordinatesY(y_off)
ScaleCoordinates(zoom,zoom)
If mode=0 :g_color=G0_color : VectorSourceColor(g_color)
MovePathCursor(x_off+xw_old,y_off+yw_old)
AddPathLine(x_off+xw_new,y_off+yw_new)
StrokePath(1)
EndIf
If mode=1:g_color=g1_color
VectorSourceColor(g_color)
MovePathCursor(x_off+xw_old,y_off+yw_old)
AddPathLine(x_off+xw_new,y_off+yw_new)
StrokePath(1) :EndIf
VectorSourceColor(g_color)
If mode=2
TranslateCoordinates(x_off,y_off)
AddPathCircle(xcenter,ycenter,ma,wb,wa) : StrokePath(1)
EndIf
If mode=3
TranslateCoordinates(x_off,y_off)
AddPathCircle(xcenter,ycenter,ma,wa,wb): StrokePath(1)
EndIf
StopVectorDrawing()
update_positie()
EndProcedure
;------------------------------------------------------------------------------
Procedure update_positie()
update_DRO_X():update_DRO_y():update_DRO_Z():update_DRO_A()
xw_old=xw_new :xm_old=xm_new
yw_old=yw_new :ym_old=ym_new
zw_old=zw_new: zm_old=zm_new
aw_old=aw_new :am_old=am_new
EndProcedure
;------------------------------------------------------------------------------
Procedure draw_Arc()
i=ValD(i_code$):j=ValD(J_code$)
i=-i:j=-j
ma=Sqr(Pow(i,2)+Pow(j,2))
xcenter=xw_old-i
ycenter=yw_old-j
i2=xw_new-xcenter
j2=yw_new-ycenter
mb=Sqr(Pow(i2,2)+Pow(j2,2))
If Abs(ma-mb)>#Epsilon
EndIf
wa=ATan2(i,j)
wa=Degree(wa)
wb=ATan2(i2,j2)
wb=Degree(wb)
EndProcedure
;----------------------------------------------------------
Procedure vind_waarde()
Define eind=0
waarde$=""
kar_positie = kar_positie+1
Repeat
k$= Mid(lijn$, kar_positie ,1)
; Debug "k$="+k$
Select k$
Case "0" ,"1","2","3","4","5","6","7","8","9","." ,"-"
waarde$=waarde$+k$
kar_positie= kar_positie+1
Default
eind=1
EndSelect
Until eind=1
EndProcedure
;----------------------------------------------------------
Procedure voeding()
Define xk.i=10 ,yk.i=40
Define xb.i=120 , yh=30,yt=50 ,xt=120
ContainerGadget(#cont_feed,645,530,130,210,#PB_Container_Raised )
SetGadgetColor(#cont_feed, #PB_Gadget_BackColor, Con_color )
SetGadgetFont(#PB_Default, FontID(font12))
TextGadget (#txt_feed,5,10,180,20,"FEED "+mm_inch$+ " /min ")
SetGadgetColor(#txt_feed, #PB_Gadget_BackColor, Con_color ) : SetGadgetColor(#txt_feed, #PB_Gadget_FrontColor,text_vgcol):
ScrollBarGadget(#scroll_feed,100,40,15,150,25,300, 1,#PB_ScrollBar_Vertical) ;2
SetGadgetState(#scroll_feed,100)
ButtonGadget(#btn_reset_feed,10,40,80,30,"RESET")
feed$=Str(voeding)
TextGadget (#txt_feed1,10,90,60,20,feed$)
CloseGadgetList()
HideGadget(#cont_feed,0)
EndProcedure