Beispiel #1
0
        private void UpdateAndSend(GrblCore Core)
        {
            //invia i dati solo almeno ad un giorno di distanza o al cambio version/grblversion
            Version current  = typeof(GitHub).Assembly.GetName().Version;
            bool    mustsend = DateTime.UtcNow.Subtract(LastSent).TotalDays > 1 || Version != current || (Core.Configuration.GrblVersion != null && GrblVersion != Core.Configuration.GrblVersion);

            Version     = current;
            GrblVersion = Core.Configuration.GrblVersion != null ? Core.Configuration.GrblVersion : GrblVersion;
            Locale      = System.Threading.Thread.CurrentThread.CurrentCulture.LCID;
            UiLang      = System.Threading.Thread.CurrentThread.CurrentUICulture.LCID;

            if (UsageTime < TimeSpan.Zero)
            {
                UsageTime = TimeSpan.Zero;                                     //fix wrong values
            }
            if (Tools.TimingBase.TimeFromApplicationStartup() > TimeSpan.Zero) //prevent wrong values
            {
                UsageTime = UsageTime.Add(Tools.TimingBase.TimeFromApplicationStartup());
            }

            Wrapper = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);

            LaserGRBL.Firmware fw = Settings.GetObject("Firmware Type", LaserGRBL.Firmware.Grbl);
            if (fw == LaserGRBL.Firmware.Grbl && Core.IsOrturBoard)
            {
                FirmwareString = "Ortur";
            }
            else
            {
                FirmwareString = fw.ToString();
            }

            if (Counters == null)
            {
                Counters = new UsageCounters();
            }
            Counters.Update(Core.UsageCounters);

            if (mustsend)
            {
                try
                {
                    if (TrueSend())
                    {
                        LastSent = DateTime.UtcNow;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
 private void ReturnItem(IPAddressHelper.ScanResult result)
 {
     if (result != null)
     {
         ComWrapper.WrapperType currentWrapper = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
         if (currentWrapper == ComWrapper.WrapperType.Telnet)
         {
             RV = $"{result.IP}:{result.Port}";
         }
         else if (currentWrapper == ComWrapper.WrapperType.LaserWebESP8266)
         {
             RV = $"ws://{result.IP}:{result.Port}/";
         }
         Close();
     }
 }
Beispiel #3
0
        public void Configure(ComWrapper.WrapperType wraptype, params object[] conf)
        {
            if (wraptype == ComWrapper.WrapperType.UsbSerial && (com == null || com.GetType() != typeof(ComWrapper.UsbSerial)))
            {
                com = new ComWrapper.UsbSerial();
            }
            else if (wraptype == ComWrapper.WrapperType.Telnet && (com == null || com.GetType() != typeof(ComWrapper.Telnet)))
            {
                com = new ComWrapper.Telnet();
            }
            else if (wraptype == ComWrapper.WrapperType.LaserWebESP8266 && (com == null || com.GetType() != typeof(ComWrapper.LaserWebESP8266)))
            {
                com = new ComWrapper.LaserWebESP8266();
            }

            com.Configure(conf);
        }
        public DiscoveryForm()
        {
            InitializeComponent();

            ComWrapper.WrapperType currentWrapper = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
            if (currentWrapper == ComWrapper.WrapperType.Telnet)
            {
                UdPort.Value = 23;
            }
            else if (currentWrapper == ComWrapper.WrapperType.LaserWebESP8266)
            {
                UdPort.Value = 81;
            }
            else
            {
                UdPort.Value = 666;
            }
        }
Beispiel #5
0
        private void UpdateAndSend(GrblCore Core)
        {
            //invia i dati solo almeno ad un giorno di distanza o al cambio version/grblversion
            Version current  = typeof(GitHub).Assembly.GetName().Version;
            bool    mustsend = DateTime.UtcNow.Subtract(LastSent).TotalDays > 1 || Version != current || (Core.Configuration.GrblVersion != null && GrblVersion != Core.Configuration.GrblVersion);

            Version     = current;
            GrblVersion = Core.Configuration.GrblVersion != null ? Core.Configuration.GrblVersion : GrblVersion;
            Locale      = System.Threading.Thread.CurrentThread.CurrentCulture.LCID;
            UiLang      = System.Threading.Thread.CurrentThread.CurrentUICulture.LCID;

            TimeSpan tfas  = Tools.TimingBase.TimeFromApplicationStartup();
            TimeSpan elaps = tfas - hUsageTime;

            hUsageTime = tfas;
            UsageTime  = UsageTime.Add(elaps);

            Wrapper = (ComWrapper.WrapperType)Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);

            if (Counters == null)
            {
                Counters = new UsageCounters();
            }
            Counters.Update(Core.UsageCounters);

            if (mustsend)
            {
                try
                {
                    if (TrueSend())
                    {
                        LastSent = DateTime.UtcNow;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #6
0
        void OnMachineStatus()
        {
            TimerUpdate();
            if (Core.MachineStatus == GrblCore.MacStatus.Disconnected && Core.FailedConnectionCount >= 3)
            {
                string url = null;
                ComWrapper.WrapperType wt = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);

                if (wt == ComWrapper.WrapperType.UsbSerial || wt == ComWrapper.WrapperType.UsbSerial2)
                {
                    url = "https://lasergrbl.com/usage/arduino-connection/";
                }
                else if (wt == ComWrapper.WrapperType.Telnet || wt == ComWrapper.WrapperType.LaserWebESP8266)
                {
                    url = "https://lasergrbl.com/usage/wifi-with-esp8266/";
                }

                if (url != null)
                {
                    MessageBox.Show(this, Strings.ProblemConnectingText, Strings.ProblemConnectingTitle, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0, url);
                }
            }
        }
Beispiel #7
0
        private void TimerUpdate()
        {
            SuspendLayout();
            TTTStatus.Text = GrblCore.TranslateEnum(Core.MachineStatus);

            if (Core.InProgram)
            {
                TTTEstimated.Text = Tools.Utils.TimeSpanToString(Core.ProjectedTime, Tools.Utils.TimePrecision.Minute, Tools.Utils.TimePrecision.Second, " ,", true);
            }
            else
            {
                TTTEstimated.Text = Tools.Utils.TimeSpanToString(Core.LoadedFile.EstimatedTime, Tools.Utils.TimePrecision.Minute, Tools.Utils.TimePrecision.Second, " ,", true);
            }

            if (Core.InProgram)
            {
                TTLEstimated.Text = Strings.MainFormProjectedTime;
            }
            else
            {
                TTLEstimated.Text = Strings.MainFormEstimatedTime;
            }

            MnFileOpen.Enabled          = Core.CanLoadNewFile;
            MnAdvancedSave.Enabled      = MnSaveProgram.Enabled = Core.HasProgram;
            MnFileSend.Enabled          = Core.CanSendFile;
            MnStartFromPosition.Enabled = Core.CanSendFile;
            MnRunMulti.Enabled          = Core.CanSendFile || Core.CanResumeHold || Core.CanFeedHold;
            MnGrblConfig.Enabled        = true;
            //MnExportConfig.Enabled = Core.CanImportExport;
            //MnImportConfig.Enabled = Core.CanImportExport;
            MnGrblReset.Enabled = Core.CanResetGrbl;

            MNEsp8266.Visible = (Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial)) == ComWrapper.WrapperType.LaserWebESP8266;

            MnConnect.Visible    = !Core.IsConnected;
            MnDisconnect.Visible = Core.IsConnected;

            MnGoHome.Visible = Core.Configuration.HomingEnabled;
            MnGoHome.Enabled = Core.CanDoHoming;
            MnUnlock.Enabled = Core.CanUnlock;

            TTOvG0.Visible = Core.SupportOverride;
            TTOvG1.Visible = Core.SupportOverride;
            TTOvS.Visible  = Core.SupportOverride;
            spacer.Visible = Core.SupportOverride;

            ComWrapper.WrapperType wt = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
            MnWiFiDiscovery.Visible = wt == ComWrapper.WrapperType.LaserWebESP8266 || wt == ComWrapper.WrapperType.Telnet;

            switch (Core.MachineStatus)
            {
            //Disconnected, Connecting, Idle, *Run, *Hold, *Door, Home, *Alarm, *Check, *Jog

            case GrblCore.MacStatus.Alarm:
                TTTStatus.BackColor = Color.Red;
                TTTStatus.ForeColor = Color.White;
                break;

            case GrblCore.MacStatus.Door:
            case GrblCore.MacStatus.Hold:
            case GrblCore.MacStatus.Cooling:
                TTTStatus.BackColor = Color.DarkOrange;
                TTTStatus.ForeColor = Color.Black;
                break;

            case GrblCore.MacStatus.Jog:
            case GrblCore.MacStatus.Run:
            case GrblCore.MacStatus.Check:
                TTTStatus.BackColor = Color.LightGreen;
                TTTStatus.ForeColor = Color.Black;
                break;

            default:
                TTTStatus.BackColor = ColorScheme.FormBackColor;
                TTTStatus.ForeColor = ColorScheme.FormForeColor;
                break;
            }

            PbBuffer.Maximum     = Core.BufferSize;
            PbBuffer.Value       = Core.UsedBuffer;
            PbBuffer.ToolTipText = $"Buffer: {Core.UsedBuffer}/{Core.BufferSize} Free:{Core.FreeBuffer}";
            MnOrtur.Visible      = Core.IsOrturBoard;

            ResumeLayout();
        }
Beispiel #8
0
 public ConnectLogForm()
 {
     currentWrapper = (ComWrapper.WrapperType)Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
     InitializeComponent();
 }
Beispiel #9
0
        public void TimerUpdate()
        {
            SuspendLayout();

            if (!Core.IsOpen && System.IO.Ports.SerialPort.GetPortNames().Length != CBPort.Items.Count)
            {
                InitPortCB();
            }

            PB.Maximum       = Core.ProgramTarget;
            PB.Bars[0].Value = Core.ProgramSent;
            PB.Bars[1].Value = Core.ProgramExecuted;

            string val = Tools.Utils.TimeSpanToString(Core.ProgramTime, Tools.Utils.TimePrecision.Minute, Tools.Utils.TimePrecision.Second, " ,", true);

            if (val != "now")
            {
                PB.PercString = val;
            }
            else if (Core.InProgram)
            {
                PB.PercString = "0 sec";
            }
            else
            {
                PB.PercString = "";
            }

            PB.Invalidate();



            /*
             * Idle: All systems are go, no motions queued, and it's ready for anything.
             * Run: Indicates a cycle is running.
             * Hold: A feed hold is in process of executing, or slowing down to a stop. After the hold is complete, Grbl will remain in Hold and wait for a cycle start to resume the program.
             * Door: (New in v0.9i) This compile-option causes Grbl to feed hold, shut-down the spindle and coolant, and wait until the door switch has been closed and the user has issued a cycle start. Useful for OEM that need safety doors.
             * Home: In the middle of a homing cycle. NOTE: Positions are not updated live during the homing cycle, but they'll be set to the home position once done.
             * Alarm: This indicates something has gone wrong or Grbl doesn't know its position. This state locks out all G-code commands, but allows you to interact with Grbl's settings if you need to. '$X' kill alarm lock releases this state and puts Grbl in the Idle state, which will let you move things again. As said before, be cautious of what you are doing after an alarm.
             * Check: Grbl is in check G-code mode. It will process and respond to all G-code commands, but not motion or turn on anything. Once toggled off with another '$C' command, Grbl will reset itself.
             */

            TT.SetToolTip(BtnConnectDisconnect, Core.IsOpen ? "Disconnect" : "Connect");

            BtnConnectDisconnect.UseAltImage = Core.IsOpen;
            BtnRunProgram.Enabled            = Core.CanSendFile;
            BtnRunProgram.Visible            = !Core.CanAbortProgram;
            BtnAbortProgram.Visible          = Core.CanAbortProgram;
            BtnOpen.Enabled = Core.CanLoadNewFile;

            bool old = TxtManualCommand.Enabled;

            TxtManualCommand.Enabled = Core.CanSendManualCommand;
            //if (old == false && TxtManualCommand.Enabled == true)
            //	TxtManualCommand.Focus();

            //CBProtocol.Enabled = !Core.IsOpen;
            CBPort.Enabled     = !Core.IsOpen;
            CBSpeed.Enabled    = !Core.IsOpen;
            TxtAddress.Enabled = !Core.IsOpen;

            CmdLog.TimerUpdate();

            if (!Core.IsOpen)
            {
                ComWrapper.WrapperType actualWrapper = (ComWrapper.WrapperType)Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
                if (actualWrapper != currentWrapper)
                {
                    currentWrapper = actualWrapper;
                    UpdateConf();
                }
            }

            ResumeLayout();
        }