Exemple #1
0
        public SnapVM()
        {
            try
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading SnapVM"
                };
                MonitorLog.LogToMonitor(monitorItem);

                SkyServer.StaticPropertyChanged += PropertyChangedSkyServer;

                SnapEnabled = false;
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Interface,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                OpenDialog(ex.Message, $"{Application.Current.Resources["exError"]}");
            }
        }
Exemple #2
0
        public Model3DVM()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading Model3D"
            };

            MonitorLog.LogToMonitor(monitorItem);

            SkyServer.StaticPropertyChanged         += PropertyChangedSkyServer;
            Settings.Settings.StaticPropertyChanged += PropertyChangedSettings;

            LookDirection = Settings.Settings.ModelLookDirection1;
            UpDirection   = Settings.Settings.ModelUpDirection1;
            Position      = Settings.Settings.ModelPosition1;

            LoadTopBar();
            LoadGEM();
            Rotate();

            ActualAxisX        = "--.--";
            ActualAxisY        = "--.--";
            CameraVis          = false;
            RaAxisVis          = false;
            DecAxisVis         = false;
            RaVis              = true;
            DecVis             = true;
            AzVis              = true;
            AltVis             = true;
            TopVis             = true;
            ScreenEnabled      = SkyServer.IsMountRunning;
            ModelWinVisibility = true;
            ModelType          = Settings.Settings.ModelType;
        }
Exemple #3
0
        /// <summary>
        /// Get axes in degrees
        /// </summary>
        /// <returns></returns>
        internal double[] AxesDegrees()
        {
            var x = Convert.ToDouble(_ioSerial.Send($"degrees,{Axis.Axis1}"));

            //put in for capture tracking in charts
            var stepsx      = _ioSerial.Send($"steps,{Axis.Axis1}");
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Data, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"steps1,{null},{stepsx}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            var y = Convert.ToDouble(_ioSerial.Send($"degrees,{Axis.Axis2}"));

            //put in for capture tracking in charts
            var stepsy = _ioSerial.Send($"steps,{Axis.Axis2}");

            monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Data, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"steps2,{null},{stepsy}"
            };
            MonitorLog.LogToMonitor(monitorItem);


            var d = new[] { x, y };

            return(d);
        }
Exemple #4
0
        /// <summary>
        /// Process command queue
        /// </summary>
        /// <param name="command"></param>
        private static void ProcessCommandQueue(ISkyCommand command)
        {
            try
            {
                if (!IsRunning || _cts.IsCancellationRequested || !_skyWatcher.IsConnected)
                {
                    return;
                }
                command.Execute(_skyWatcher);
                if (command.Id <= 0)
                {
                    return;
                }
                if (_resultsDictionary.TryAdd(command.Id, command) == false)
                {
                    throw new MountControlException(ErrorCode.ErrQueueFailed, $"Unable to post results {command.Id}, {command}");
                }
            }
            catch (Exception e)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{command.Id},{e.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                command.Exception  = e;
                command.Successful = false;
            }
        }
Exemple #5
0
        public HandControlVM()
        {
            try
            {
                using (new WaitCursor())
                {
                    var monitorItem = new MonitorEntry
                    {
                        Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "Opening Hand Control Window"
                    };
                    MonitorLog.LogToMonitor(monitorItem);

                    _skyTelescopeVM = SkyTelescopeVM._skyTelescopeVM;
                    SkyServer.StaticPropertyChanged   += PropertyChangedSkyServer;
                    SkySettings.StaticPropertyChanged += PropertyChangedSkySettings;

                    SetHCFlipsVisibility();

                    Title           = Application.Current.Resources["hcHc"].ToString();
                    ScreenEnabled   = SkyServer.IsMountRunning;
                    HcWinVisibility = false;
                    TopMost         = true;
                }
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Error, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                throw;
            }
        }
Exemple #6
0
        /// <summary>
        /// Property changes from the monitor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PropertyChangedMonitor(object sender, PropertyChangedEventArgs e)
        {
            try
            {
                ThreadContext.InvokeOnUiThread(
                    delegate
                {
                    switch (e.PropertyName)
                    {
                    case "CmdjSentEntry":
                        ProcessValues1(MonitorQueue.CmdjSentEntry);
                        break;

                    case "Cmdj2SentEntry":
                        ProcessValues2(MonitorQueue.Cmdj2SentEntry);
                        break;
                    }
                }, _ct);
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Error, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $" {ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                OpenDialog(ex.Message);
            }
        }
Exemple #7
0
        /// <summary>
        /// Property changes from option settings
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PropertyChangedSettings(object sender, PropertyChangedEventArgs e)
        {
            try
            {
                ThreadContext.BeginInvokeOnUiThread(
                    delegate
                {
                    switch (e.PropertyName)
                    {
                    case "AccentColor":
                    case "ModelType":
                        ModelType = Settings.Settings.ModelType;
                        LoadGEM();
                        break;
                    }
                });
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Interface,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                SkyServer.AlertState = true;
                OpenDialog(ex.Message);
            }
        }
        ///// <summary>
        ///// get current step count
        ///// </summary>
        ///// <param name="axis"></param>
        ///// <returns></returns>
        //private int GetEncoderCount(AxisId axis)
        //{
        //    var stepsSky = new SkyGetEncoderCount(SkyQueue.NewId, axis);
        //    var steps = (int[])SkyQueue.GetCommandResult(stepsSky).Result;
        //    if (!stepsSky.Successful && stepsSky.Exception != null) throw stepsSky.Exception;
        //    switch (axis)
        //    {
        //        case AxisId.Axis1:
        //            return steps[0];
        //        case AxisId.Axis2:
        //            return steps[1];
        //        default:
        //            throw new ArgumentOutOfRangeException(nameof(axis), axis, null);
        //    }
        //}

        /// <summary>
        /// Gets the direction to home sensor or if null then TripPosition was set
        /// </summary>
        /// <param name="axis"></param>
        /// <returns></returns>
        private bool?GetHomeSensorStatus(AxisId axis)
        {
            var sensorStatusSky = new SkyGetHomePosition(SkyQueue.NewId, axis);
            var sensorStatus    = (long)SkyQueue.GetCommandResult(sensorStatusSky).Result;

            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow,
                Device   = MonitorDevice.Telescope,
                Category = MonitorCategory.Server,
                Type     = MonitorType.Information,
                Method   = MethodBase.GetCurrentMethod().Name,
                Thread   = Thread.CurrentThread.ManagedThreadId,
                Message  = $"{sensorStatus}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            switch (sensorStatus)
            {
            case 16777215:
                return(false);

            case 0:
                return(true);

            default:
                TripPosition = Convert.ToInt32(sensorStatus);
                return(null);
            }
        }
Exemple #9
0
        /// <summary>
        /// convert a decimal Alt/Az positions to an axes positions.
        /// </summary>
        /// <param name="altAz"></param>
        /// <returns></returns>
        internal static double[] AltAzToAxesYX(double[] altAz)
        {
            var    axes = new[] { altAz[0], altAz[1] };
            double lst;

            switch (SkySettings.AlignmentMode)
            {
            case AlignmentModes.algAltAz:
                break;

            case AlignmentModes.algGermanPolar:
                lst  = SkyServer.SiderealTime;
                axes = Coordinate.AltAz2RaDec(axes[0], axes[1], SkySettings.Latitude, lst);

                axes[0] = Coordinate.Ra2Ha12(axes[0], lst) * 15.0;     // ha in degrees

                if (SkyServer.SouthernHemisphere)
                {
                    axes[1] = -axes[1];
                }

                axes = Range.RangeAzAlt(axes);

                if (axes[0] > 180.0 || axes[0] < 0)
                {
                    // adjust the targets to be through the pole
                    axes[0] += 180;
                    axes[1]  = 180 - axes[1];
                }
                break;

            case AlignmentModes.algPolar:
                lst  = SkyServer.SiderealTime;
                axes = Coordinate.AltAz2RaDec(axes[0], axes[1], SkySettings.Latitude, lst);

                axes[0] = Coordinate.Ra2Ha12(axes[0], lst) * 15.0;     // ha in degrees

                if (SkyServer.SouthernHemisphere)
                {
                    axes[1] = -axes[1];
                }

                axes = Range.RangeAzAlt(axes);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            axes = Range.RangeAxesXY(axes);

            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Server, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"Range:{axes[0]},{axes[1]}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            return(new[] { axes[1], axes[0] });
        }
Exemple #10
0
        public NotesVM()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading NotesVM"
            };

            MonitorLog.LogToMonitor(monitorItem);
        }
Exemple #11
0
        protected ObjectBase()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Server, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "CountObject"
            };

            MonitorLog.LogToMonitor(monitorItem);

            // We increment the global count of objects.
            GSServer.CountObject();
        }
Exemple #12
0
        public PlotVM()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading PlotVM"
            };

            MonitorLog.LogToMonitor(monitorItem);

            // setup property events to monitor
            MonitorQueue.StaticPropertyChanged += PropertyChangedMonitor;

            LoadDefaults();
        }
Exemple #13
0
        internal string Send(string command)
        {
            //if (Queues.Serial.Connected) return null;
            var received = _controllers.Command(command.ToLower().Trim());

            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Data, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{command}={received}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            return(received);
        }
Exemple #14
0
        public TestVM()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading FocuserVM"
            };

            MonitorLog.LogToMonitor(monitorItem);

            if (_skyTelescopeVM == null)
            {
                _skyTelescopeVM = SkyTelescopeVM._skyTelescopeVM;
            }
        }
Exemple #15
0
        public PoleLocatorVM()
        {
            try
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = " Loading PoleLocatorVM"
                };
                MonitorLog.LogToMonitor(monitorItem);

                // setup property events to monitor
                SkySettings.StaticPropertyChanged += PropertyChangedSkySettings;

                MirrorFlip = true;
                CenterX    = 200;
                CenterY    = 200;
                GridAngle  = 0;
                StarCenter = $"{CenterX},{30 + YearPosition()}";

                //ConvertRaDec();
                MainVM();
                Update();
                SetHemisphere();
                SetLst();
                SetDegrees();

                _timer = new DispatcherTimer {
                    Interval = TimeSpan.FromSeconds(1)
                };
                _timer.Tick += Timer_Tick;
                _timer.Start();
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Interface,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                OpenDialog(ex.Message, $"{Application.Current.Resources["exError"]}");
            }
        }
Exemple #16
0
        /// <summary>
        /// adds a pulse wait item to a blocking queue for processing
        /// </summary>
        /// <param name="entry"></param>
        public static void AddPulseStatusEntry(PulseStatusEntry entry)
        {
            var add = _pulseBlockingCollection.TryAdd(entry);

            if (add)
            {
                return;
            }
            ResetGuiding(entry.Axis, false);
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Warning, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"Add Failed: {entry.Axis},{entry.Duration}"
            };

            MonitorLog.LogToMonitor(monitorItem);
        }
        /// <summary>
        /// auto home for the simulator
        /// </summary>
        public AutoHomeSky()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow,
                Device   = MonitorDevice.Telescope,
                Category = MonitorCategory.Server,
                Type     = MonitorType.Information,
                Method   = MethodBase.GetCurrentMethod().Name,
                Thread   = Thread.CurrentThread.ManagedThreadId,
                Message  = "Start"
            };

            MonitorLog.LogToMonitor(monitorItem);

            Initialize();
        }
Exemple #18
0
        /// <summary>
        /// Query the joystick for all items
        /// </summary>
        public void Poll()
        {
            try
            {
                if (!IsAvailable)
                {
                    return;
                }
                // joystick.Acquire();
                // joystick.Poll();
                State   = null;
                State   = joystick.GetCurrentState();
                Buttons = State.Buttons;
                Povs    = State.PointOfViewControllers;
                Xaxis   = State.X;
                Yaxis   = State.Y;
                Zaxis   = State.Z;
                // Datas = joystick.GetBufferedData();
            }
            catch (Exception ex)
            {
                IsAvailable = false;
                var monitorItem = new MonitorEntry
                {
                    Datetime = Principles.HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Server,
                    Category = MonitorCategory.Server,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                switch (ex.HResult)
                {
                case unchecked ((int)0x8007001E):
                case unchecked ((int)0x80040154):
                    return;

                default:
                    throw;
                }
            }
        }
        /// <summary>
        /// Reset home sensor :Wx080000[0D]
        /// </summary>
        /// <param name="axis"></param>
        private void ResetHomeSensor(AxisId axis)
        {
            var reset = new SkySetHomePositionIndex(SkyQueue.NewId, axis);
            //var _ = (long)SkyQueue.GetCommandResult(reset).Result;

            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow,
                Device   = MonitorDevice.Telescope,
                Category = MonitorCategory.Server,
                Type     = MonitorType.Information,
                Method   = MethodBase.GetCurrentMethod().Name,
                Thread   = Thread.CurrentThread.ManagedThreadId,
                Message  = $"{reset.Successful},{axis}"
            };

            MonitorLog.LogToMonitor(monitorItem);
        }
Exemple #20
0
        public static void SetConnected(long id, bool value)
        {
            // add or remove the instance, this is done once regardless of the number of calls
            if (value)
            {
                var notAlreadyPresent = ConnectStates.TryAdd(id, true);

                if (Connected)
                {
                    if (!SkyServer.IsMountRunning)
                    {
                        SkyServer.IsMountRunning = true;
                    }
                }

                var monitorItem = new MonitorEntry
                {
                    Datetime = Principles.HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Server,
                    Type     = MonitorType.Information,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"Add:{id},{notAlreadyPresent}"
                };
                MonitorLog.LogToMonitor(monitorItem);
            }
            else
            {
                var successfullyRemoved = ConnectStates.TryRemove(id, out _);

                var monitorItem = new MonitorEntry
                {
                    Datetime = Principles.HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Server,
                    Type     = MonitorType.Information,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"Remove:{id},{successfullyRemoved}"
                };
                MonitorLog.LogToMonitor(monitorItem);
            }
        }
Exemple #21
0
        /// <summary>
        /// Builds the command string
        /// </summary>
        /// <param name="axis">AxisId.Axis1 or AxisId.Axis2</param>
        /// <param name="command"></param>
        /// <param name="cmdDataStr"></param>
        private string SendRequest(AxisId axis, char command, string cmdDataStr)
        {
            const char startCharOut = ':';

            if (cmdDataStr == null)
            {
                cmdDataStr = "";
            }
            const int bufferSize = 20;
            var       commandStr = new StringBuilder(bufferSize);

            commandStr.Append(startCharOut);                     // 0: Leading char
            commandStr.Append(command);                          // 1: Length of command( Source, destination, command char, data )
            // Target Device
            commandStr.Append(axis == AxisId.Axis1 ? '1' : '2'); // 2: Target Axis
            // Copy command data to buffer
            commandStr.Append(cmdDataStr);
            commandStr.Append(_endChar);                         // CR Character

            var monitorItem = new MonitorEntry
            {
                Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Mount, Type = MonitorType.Data, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{commandStr.ToString().Trim()}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            switch (command)
            {
            // store time for any measurements
            case 'J' when axis == AxisId.Axis2:
                LastJ2RunTime = Principles.HiResDateTime.UtcNow;
                break;

            case 'I' when axis == AxisId.Axis1:
                LastI1RunTime = Principles.HiResDateTime.UtcNow;
                break;
            }

            //Serial.Transmit(commandStr.ToString());
            Serial.Write(commandStr.ToString());

            return($"{commandStr.ToString().Trim()}");
        }
Exemple #22
0
        /// <summary>
        /// Converts axes positions from Local to Mount
        /// </summary>
        /// <param name="axes"></param>
        /// <returns></returns>
        internal static double[] AxesAppToMount(double[] axes)
        {
            var a = new[] { axes[0], axes[1] };

            switch (SkySettings.Mount)
            {
            case MountType.Simulator:
                if (SkyServer.SouthernHemisphere)
                {
                    a[0] = 180 - a[0];
                    a[1] = a[1];
                }
                else
                {
                    a[0] = a[0];
                    a[1] = a[1];
                }
                break;

            case MountType.SkyWatcher:
                if (SkyServer.SouthernHemisphere)
                {
                    a[0] = 180 - a[0];
                    a[1] = a[1];
                }
                else
                {
                    a[0] = a[0];
                    a[1] = 180 - a[1];
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Server, Type = MonitorType.Data, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{axes[0]},{axes[1]},{a[0]},{a[1]}"
            };

            MonitorLog.LogToMonitor(monitorItem);
            return(a);
        }
Exemple #23
0
        public override void Poll(float vibrateLeft, float vibrateRight)
        {
            try
            {
                gamePadState = XInputDotNetPure.GamePad.GetState(PlayerIndex.One, DeadZone);
                if (gamePadState.IsConnected)
                {
                    bool changed = false;

                    if (gamePadState.PacketNumber != lastPacketNumber)
                    {
                        lastPacketNumber = gamePadState.PacketNumber;
                        changed          = true;
                    }

                    XInputDotNetPure.GamePad.SetVibration(PlayerIndex.One, vibrateLeft, vibrateRight);
                    if (changed)
                    {
                        UpdateState();
                    }
                    _IsAvailable = true;
                }
                else
                {
                    _IsAvailable = false;
                }
            }
            catch (Exception ex)
            {
                _IsAvailable = false;
                var monitorItem = new MonitorEntry
                {
                    Datetime = Principles.HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Server,
                    Category = MonitorCategory.Server,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);
            }
        }
Exemple #24
0
        static PulseStatusQueue()
        {
            try
            {
                _pulseBlockingCollection = new BlockingCollection <PulseStatusEntry>();
                Task.Factory.StartNew(() =>
                {
                    foreach (var PulseWaitEntry in _pulseBlockingCollection.GetConsumingEnumerable())
                    {
                        ProcessPulseStatusQueue(PulseWaitEntry);
                    }
                });
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Mount,
                    Type     = MonitorType.Data,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = "Started"
                };
                MonitorLog.LogToMonitor(monitorItem);
            }
            catch (Exception ex)
            {
                ResetGuiding(0, false);
                ResetGuiding(1, false);

                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Server,
                    Category = MonitorCategory.Server,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message},{ex.StackTrace}"
                };
                MonitorLog.LogToMonitor(monitorItem);
            }
        }
Exemple #25
0
        public ModelVM()
        {
            try
            {
                using (new WaitCursor())
                {
                    var monitorItem = new MonitorEntry
                    {
                        Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "Opening Model Window"
                    };
                    MonitorLog.LogToMonitor(monitorItem);

                    SkyServer.StaticPropertyChanged         += PropertyChangedSkyServer;
                    Settings.Settings.StaticPropertyChanged += PropertyChangedSettings;

                    Title              = Application.Current.Resources["3dModel"].ToString();
                    ScreenEnabled      = SkyServer.IsMountRunning;
                    ModelWinVisibility = false;
                    TopMost            = true;
                    _modelVM           = this;

                    LoadImages();
                    Rotate();
                    LoadGEM();

                    RightAscension = _util.HoursToHMS(SkyServer.RightAscensionXForm, "h ", ":", "", 2);
                    Declination    = _util.DegreesToDMS(SkyServer.DeclinationXForm, "° ", ":", "", 2);
                }
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Error, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                throw;
            }
        }
Exemple #26
0
        /// <summary>
        /// Dispatch timer to update screen every second
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Timer_Tick(object sender, EventArgs e)
        {
            try
            {
                // don't run if on a different viewmodel
                if (_mainWindowVM == null)
                {
                    return;
                }
                if (_mainWindowVM.CurrentPageViewModel.Uid != 5)
                {
                    return;
                }

                Update();
                SetHemisphere();
                SetLst();
                SetDegrees();
            }
            catch (Exception ex)
            {
                _timer.Tick -= Timer_Tick;

                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow,
                    Device   = MonitorDevice.Telescope,
                    Category = MonitorCategory.Interface,
                    Type     = MonitorType.Error,
                    Method   = MethodBase.GetCurrentMethod().Name,
                    Thread   = Thread.CurrentThread.ManagedThreadId,
                    Message  = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                OpenDialog(ex.Message, $"{Application.Current.Resources["exError"]}");
            }
        }
Exemple #27
0
 public override void Find()
 {
     try
     {
         gamePadState = XInputDotNetPure.GamePad.GetState(PlayerIndex.One, DeadZone);
         _IsAvailable = gamePadState.IsConnected;
     }
     catch (Exception ex)
     {
         _IsAvailable = false;
         var monitorItem = new MonitorEntry
         {
             Datetime = Principles.HiResDateTime.UtcNow,
             Device   = MonitorDevice.Server,
             Category = MonitorCategory.Server,
             Type     = MonitorType.Error,
             Method   = MethodBase.GetCurrentMethod().Name,
             Thread   = Thread.CurrentThread.ManagedThreadId,
             Message  = $"{ex.Message}"
         };
         MonitorLog.LogToMonitor(monitorItem);
     }
 }
Exemple #28
0
        public AlignmentVM()
        {
            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow,
                Device   = MonitorDevice.Server,
                Category = MonitorCategory.Interface,
                Type     = MonitorType.Information,
                Method   = MethodBase.GetCurrentMethod()
                           .Name,
                Thread  = Thread.CurrentThread.ManagedThreadId,
                Message = " Loading AlignmentVM"
            };

            MonitorLog.LogToMonitor(monitorItem);

            if (_skyTelescopeVM == null)
            {
                _skyTelescopeVM = SkyTelescopeVM._skyTelescopeVM;
            }

            BindingOperations.EnableCollectionSynchronization(AlignmentPoints, _alignmentPointsLock);
            SkyServer.AlignmentModel.AlignmentPoints.CollectionChanged += AlignmentPoints_CollectionChanged;
        }
        /// <summary>
        /// Slews degrees from current position using the goto from the server
        /// </summary>
        /// <param name="degrees"></param>
        /// <param name="direction"></param>
        /// <param name="axis"></param>
        private int SlewAxis(double degrees, AxisId axis, bool direction = false)
        {
            if (SkyServer.AutoHomeStop)
            {
                return(-3);                        //stop requested
            }
            if (SkyServer.Tracking)
            {
                SkyServer.TrackingSpeak = false;
                SkyServer.Tracking      = false;
            }

            var positions = Axes.MountAxis2Mount();

            switch (axis)
            {
            case AxisId.Axis1:
                degrees = direction ? Math.Abs(degrees) : -Math.Abs(degrees);
                if (SkyServer.SouthernHemisphere)
                {
                    degrees = direction ? -Math.Abs(degrees) : Math.Abs(degrees);
                }
                SkyServer.SlewAxes(positions[0] + degrees, positions[1], SlewType.SlewMoveAxis);
                break;

            case AxisId.Axis2:
                degrees = direction ? -Math.Abs(degrees) : Math.Abs(degrees);
                if (SkyServer.SouthernHemisphere)
                {
                    degrees = direction ? Math.Abs(degrees) : -Math.Abs(degrees);
                }
                SkyServer.SlewAxes(positions[0], positions[1] + degrees, SlewType.SlewMoveAxis);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(axis), axis, null);
            }

            var monitorItem = new MonitorEntry
            {
                Datetime = HiResDateTime.UtcNow,
                Device   = MonitorDevice.Telescope,
                Category = MonitorCategory.Server,
                Type     = MonitorType.Information,
                Method   = MethodBase.GetCurrentMethod().Name,
                Thread   = Thread.CurrentThread.ManagedThreadId,
                Message  = $"{positions[0]},{positions[1]},{degrees},{axis},{direction}"
            };

            MonitorLog.LogToMonitor(monitorItem);

            while (SkyServer.IsSlewing)
            {
                //Console.WriteLine(@"slewing");
                Thread.Sleep(300);
            }

            var _ = new SkyAxisStop(0, axis);

            //Thread.Sleep(1500);
            return(0);
        }
        public MainWindowVM()
        {
            try
            {
                using (new WaitCursor())
                {
                    //setup property info from the GSServer
                    GSServer.StaticPropertyChanged          += PropertyChangedServer;
                    SkySettings.StaticPropertyChanged       += PropertyChangedSettings;
                    Settings.Settings.StaticPropertyChanged += PropertyChangedSettingsSettings;
                    Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

                    var monitorItem = new MonitorEntry
                    {
                        Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{Assembly.GetExecutingAssembly()}"
                    };
                    MonitorLog.LogToMonitor(monitorItem);

                    monitorItem = new MonitorEntry
                    {
                        Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "Loading MainWindowVM"
                    };
                    MonitorLog.LogToMonitor(monitorItem);

                    AppCount = GSServer.AppCount;
                    Settings.Settings.Load();
                    if (Settings.Settings.StartMinimized)
                    {
                        Settings.Settings.Windowstate = WindowState.Minimized;
                    }
                    MountType = SkySettings.Mount;

                    _mainWindowVm = this;

                    // Sets up the Tab menu items
                    UpdateTabViewModel("SkyWatcher");
                    UpdateTabViewModel("Focuser");
                    UpdateTabViewModel("Charts");
                    UpdateTabViewModel("Notes");
                    UpdateTabViewModel("Settings");
                    UpdateTabViewModel("GamePad");
                    UpdateTabViewModel("Model3D");
                    UpdateTabViewModel("Plot");
                    UpdateTabViewModel("PoleLocator");
                    UpdateTabViewModel("Pulses");
                    UpdateTabViewModel("Test");

                    // Set starting page
                    CurrentPageViewModel = PageViewModels[0];
                    SkyWatcherVMRadio    = true;

                    TopMost = Properties.Server.Default.StartOnTop;
                }
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Error, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                throw;
            }
        }