Пример #1
0
        /// <summary>
        /// Legacy funtion, to be deleted if the rest is stable
        /// </summary>
        /// <param name="location"></param>
        /// <param name="DownloadPath"></param>
        /// <param name="Connection"></param>
        public void DownloadAndSliceAndUploadAssociatedFile(string location, string DownloadPath, OctoprintConnection Connection)
        {
            JObject info         = Connection.Files.GetFileInfo(location, this.Path);
            JToken  refs         = info.Value <JToken>("refs");
            string  downloadLink = refs.Value <string>("download");

            this.Connection = Connection;

            using (WebClient myWebClient = new WebClient())
            {
                try
                {
                    //myWebClient.DownloadFileAsync(new Uri(downloadLink), DownloadPath);
                    myWebClient.DownloadFile(new Uri(downloadLink), DownloadPath + FileName);
                    LocalFilePath  = DownloadPath + FileName;
                    SlicedFilePath = DownloadPath + FileName;
                    SlicedFilePath = System.IO.Path.ChangeExtension(LocalFilePath, null);
                    FileReadyForSlicing?.Invoke(this, new FileReadyForSlicingArgs(LocalFilePath));
                    //SliceAndUpload(LocalFilePath, SlicedFilePath);
                }
                catch (Exception e)
                {
                    var msg = e.Message;
                }
            }
        }
Пример #2
0
        public static string GetFileDownloadURL(OctoprintConnection octoConnection, string filepath)
        {
            var    filemanager = octoConnection.Files;
            var    fileinfo    = filemanager.GetFileInfo("local", filepath);
            JToken refs        = fileinfo?.Value <JToken>("refs");

            return(refs?.Value <string>("download"));
        }
Пример #3
0
 public async Task <string> UploadToOctoprintAsync(string SlicedFilePath, OctoprintConnection Connection)
 {
     if (Connection == null)
     {
         return("");
     }
     return(await Connection.Files.UploadFileAsync(SlicedFilePath, SlicedFileName, ""));
 }
Пример #4
0
 /*private*/
 public async Task UploadToOctoprintAsync(string SlicedFilePath, OctoprintConnection Connection)
 {
     if (Connection == null)
     {
         return;
     }
     string uploadResponse = await Connection.Files.UploadFile(SlicedFilePath, SlicedFileName, "");
 }
Пример #5
0
 public override void _Ready()
 {
     octoprint   = new OctoprintConnection(address, key);
     xAxis       = GetNode("Mk3Z/Mk3X") as Spatial;
     yAxis       = GetNode("Mk3Y") as Spatial;
     zAxis       = GetNode("Mk3Z") as Spatial;
     printerData = GetNode("Viewport/PrinterData") as Control;
     //octoprint.Position.StartThread();
     //octoprint.Position.GetCurrentPosSync();
 }
Пример #6
0
        public static OctoFile CreateOctoFile(OctoprintConnection octoConnection, string filepath)
        {
            var filemanager = octoConnection.Files;
            var fileinfo    = filemanager.GetFileInfo("local", filepath);

            if (fileinfo == null)
            {
                return(null);
            }
            OctoFile octofile = new OctoFile(fileinfo);

            return(octofile);
        }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        Connected = false;
#if UNITY_WSA && !UNITY_EDITOR
        octoprintConnection = new OctoprintConnectionUWP(Ip, ApiKey);
        print("octoprintConnection");
#else
        octoprintConnection = new OctoprintConnectionEditor(Ip, ApiKey);
#endif
        Connected = true;
        print("Start octoprintConnector");
        octoprintConnection.Printer.TempHandlers         += Printers_TempHandlers;
        octoprintConnection.Printer.PrinterstateHandlers += Printers_PrinterstateHandlers;
        octoprintConnection.Printer.Homed            += Printer_Homed;
        octoprintConnection.Jobs.ProgressinfoHandler += Jobs_Progressinfo;
        octoprintConnection.Printer.StateChanged     += Printer_StateChanged;
        octoprintConnection.Printer.PrintFinished    += Printer_PrintFinished;
    }
Пример #8
0
 private static async Task StartOctoprintConnectionAsync()
 {
     octoconnection = new OctoprintConnection(ip, api);
     octoconnection.InitializeDefaultSlicer(prusaSlicerPath);
     await octoconnection.WebsocketStartAsync();
 }
Пример #9
0
 public OctoprintTracker(OctoprintConnection con)
 {
     Connection = con;
 }
Пример #10
0
        public void DownloadAssociatedOnlineFile(string location, string downloadPath, OctoprintConnection connection)
        {
            var currentFilePath = System.IO.Path.Combine(downloadPath, FileName);

            // if the file already exists in the download folder then just set its information
            if (File.Exists(currentFilePath))
            {
                SetDownloadedFileLocalInformation(downloadPath);
                return;
            }
            // else download the file from Octoprint then set its information

            JObject info         = connection.Files.GetFileInfo(location, this.Path);
            JToken  refs         = info.Value <JToken>("refs");
            string  downloadLink = refs.Value <string>("download");

            using (WebClient myWebClient = new WebClient())
            {
                try
                {
                    myWebClient.DownloadFile(new Uri(downloadLink), currentFilePath);
                    SetDownloadedFileLocalInformation(downloadPath);
                }
                catch (Exception e)
                {
                    var msg = e.Message;
                }
            }
        }