Loading a File

Make your own CNC Control Apps

Moderator: cnckeith

Post Reply
Ryan Patterson
Posts: 50
Joined: Wed Oct 16, 2024 3:30 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Loading a File

Post by Ryan Patterson »

Solved another task. The below example will write the contents of a text box to a file then send load a job, ready for a cycle start to be hit. More error protection is needed but the basic function works well.

Code: Select all

    Private Sub btnSendMDI_Click(sender As Object, e As EventArgs) Handles btnSendMDI.Click
        Dim folderPath As String = "C:/cncm"
        Dim filePath As String = System.IO.Path.Combine(folderPath, "MDI.txt")
        System.IO.File.WriteAllText(filePath, txtMDI.Text)
        SendJob(filePath)
    End Sub

Code: Select all

   Function SendJob(WhatFile As String)
       ' check that pipe is initialized
       If CNCPipeManager.Pipe IsNot Nothing Then
           If CNCPipeManager.Pipe.IsConstructed Then
               Dim cmd As New CentroidAPI.CNCPipe.Job(CNCPipeManager.Pipe)
               Return cmd.Load(WhatFile, "C:/cncm")
           End If
       End If
       ' if we failed, send back an unknown error
       Return CentroidAPI.CNCPipe.ReturnCode.ERROR_UNKNOWN
   End Function


Post Reply