コード例 #1
0
ファイル: Canvas.cs プロジェクト: vip00112/GTLauncher
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            switch (Mode)
            {
            case DrawMode.Pen:
            case DrawMode.Highlighter:
                if (_drawLine != null)
                {
                    var loc = e.Location;
                    if (IsPressedShiftKey && _holdMode == HoldMode.None)
                    {
                        _holdMode = CalcHoldMode(e.Location);
                    }

                    if (_holdMode == HoldMode.Horizontal)
                    {
                        loc.Y = _startLoc.Y;
                    }
                    else if (_holdMode == HoldMode.Vertical)
                    {
                        loc.X = _startLoc.X;
                    }

                    _drawLine.AddLocation(loc);
                }
                break;
            }
            Invalidate();
        }
コード例 #2
0
            public void ChangeHoldMode(HoldMode newHold)
            {
                var transSet  = new MazakWriteData();
                var newSchRow = _schRow.Clone();

                newSchRow.Command  = MazakWriteCommand.ScheduleSafeEdit;
                newSchRow.HoldMode = (int)newHold;
                transSet.Schedules.Add(newSchRow);

                _parent.database.Save(transSet, "Hold Mode");
            }
コード例 #3
0
ファイル: Canvas.cs プロジェクト: vip00112/GTLauncher
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            _startLoc = e.Location;
            _holdMode = HoldMode.None;

            switch (Mode)
            {
            case DrawMode.Pen:
                _drawLine = new DrawLineMemento(Color, LineSize);
                break;

            case DrawMode.Highlighter:
                _drawLine = new DrawLineMemento(HighlightColor, LineSize);
                break;
            }
        }
コード例 #4
0
ファイル: Canvas.cs プロジェクト: vip00112/GTLauncher
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            _holdMode = HoldMode.None;

            switch (Mode)
            {
            case DrawMode.Pen:
            case DrawMode.Highlighter:
                if (_drawLine != null && _drawLine.CanDraw())
                {
                    AddMemento(_drawLine);
                    _drawLine = null;
                }
                break;
            }
            Invalidate();
        }
コード例 #5
0
        private TimeSpan CheckForTransition()
        {
            try
            {
                if (!OpenDatabaseKitDB.MazakTransactionLock.WaitOne(TimeSpan.FromMinutes(3), true))
                {
                    //Downloads usually take a long time and they hold the db lock,
                    //so we will probably hit this timeout during the download.
                    //For this reason, we wait 3 minutes for the db lock and retry again after only 20 seconds.
                    //Thus during the download most of the waiting will be here for the db lock.

                    Log.Debug("Unable to obtain mazak db lock, trying again in 20 seconds.");
                    return(TimeSpan.FromSeconds(20));
                }

                try
                {
                    //Store the current time, this is the time we use to calculate the hold pattern.
                    //It is important that this time be fixed for all schedule calculations, otherwise
                    //we might miss a transition if it occurs while we are running this function.
                    var nowUTC = DateTime.UtcNow;

                    var mazakSch = LoadMazakSchedules();

                    Log.Debug("Checking for hold transitions at {time} ", nowUTC);

                    var nextTimeUTC = DateTime.MaxValue;

                    foreach (var pair in mazakSch)
                    {
                        bool     allHold  = false;
                        DateTime allNext  = DateTime.MaxValue;
                        bool     machHold = false;
                        DateTime machNext = DateTime.MaxValue;

                        if (pair.Value.HoldEntireJob != null)
                        {
                            pair.Value.HoldEntireJob.HoldInformation(nowUTC, out allHold, out allNext);
                        }
                        if (pair.Value.HoldMachining != null)
                        {
                            pair.Value.HoldMachining.HoldInformation(nowUTC, out machHold, out machNext);
                        }

                        HoldMode currentHoldMode = CalculateHoldMode(allHold, machHold);

                        Log.Debug("Checking schedule {sch}, mode {mode}, target {targetMode}, next {allNext}, mach {machNext}",
                                  pair.Key, pair.Value.Hold, currentHoldMode, allNext, machNext
                                  );

                        if (currentHoldMode != pair.Value.Hold)
                        {
                            pair.Value.ChangeHoldMode(currentHoldMode);
                        }

                        if (allNext < nextTimeUTC)
                        {
                            nextTimeUTC = allNext;
                        }
                        if (machNext < nextTimeUTC)
                        {
                            nextTimeUTC = machNext;
                        }
                    }

                    Log.Debug("Next hold transition {next}", nextTimeUTC);

                    if (nextTimeUTC == DateTime.MaxValue)
                    {
                        return(TimeSpan.MaxValue);
                    }
                    else
                    {
                        return(nextTimeUTC.Subtract(DateTime.UtcNow));
                    }
                }
                finally
                {
                    OpenDatabaseKitDB.MazakTransactionLock.ReleaseMutex();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unhanlded error checking for hold transition");

                //Try again in three minutes.
                return(TimeSpan.FromMinutes(3));
            }
        }
コード例 #6
0
 public Message(string message, HoldMode mode)
 {
     this.message  = message;
     this.duration = 2f;
     this.mode     = mode;
 }
コード例 #7
0
 public Message(string message, float duration, HoldMode mode)
 {
     this.message  = message;
     this.duration = duration;
     this.mode     = mode;
 }
コード例 #8
0
 public async Task SetHoldMode(string icd, HoldMode mode) => await _hubProxy.Invoke("SetHoldMode", icd, mode.ToString());