Exemplo n.º 1
0
        /// <summary>
        /// GetHardwareObjects creates the Hardware objects so
        /// that the data acquisition can occur.
        /// </summary>
        /// <param name="mirror">The IMirror to create</param>
        /// <param name="potstat">The IPotentiostat to create</param>
        /// <param name="laser">The ILaser to create</param>
        private void GetHardwareObjects(ref IMirror mirror, ref IPotentiostat potstat, ref ILaser laser)
        {
            //Create the interfaces
            this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), Strings.ConnectMirror);
            mirror = SHArKClassFactory.CreateIMirror();

            this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), Strings.ConnectLaser);
            laser = SHArKClassFactory.CreateILaser();

            this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), Strings.ConnectPotentiostat);
            potstat = SHArKClassFactory.CreateIPotentiostat();

            if (mirror == null || potstat == null || laser == null)
            {
                //Show the error
                this._view.Dispatcher.Invoke(new ShowErrorDelegate(this.ShowError), Strings.HardwareNotDetected);

                //Close the Tab
                this._view.Dispatcher.BeginInvoke(new PublishCloseEventDelegate(this.PublishCloseEvent));

                //Publish the event to notify that the Spectrum
                //has finished
                this._view.Dispatcher.Invoke(new NotifySpectrumEndedDelegate(this.NotifySpectrumEnded));

                //Change the Mouse cursor back
                this._view.Dispatcher.Invoke(new SetMouseCursorDelegate(this.SetMouseCursor), Cursors.Arrow);
            }
        }
Exemplo n.º 2
0
        public IEnumerable <Synchronization> GetByMirror(IMirror mirror, int?take)
        {
            var mirrorId = new ObjectId(mirror.Id);
            var filter   = Builders <BsonDocument> .Filter.Eq("MirrorId", mirrorId);

            var sort = Builders <BsonDocument> .Sort.Descending("_id");

            var document = base.collection.Find(filter).Sort(sort).Limit(take);

            var result = new List <Synchronization>();

            if (document != null && document.Count() > 0)
            {
                using (var cursor = document.ToCursor())
                {
                    while (cursor.MoveNext())
                    {
                        using (var enumerator = cursor.Current.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                var doc = enumerator.Current;

                                var dto   = BsonSerializer.Deserialize <SynchronizationDto>(doc);
                                var model = this.ConvertToModel(dto);
                                result.Add(model);
                            }
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 3
0
 public RepositoryComparer(IBlackMirrorHttpClient httpClient, IMirror mirror, IEnumerable <IRevision> sourceRepositoryLog, IEnumerable <IRevision> targetRepositoryLog)
 {
     this.httpClient          = httpClient;
     this.mirror              = mirror;
     this.sourceRepositoryLog = sourceRepositoryLog.ToList();
     this.targetRepositoryLog = targetRepositoryLog.ToList();
 }
Exemplo n.º 4
0
        /// <summary>
        /// CreateIMirror returns an IMirror interface based
        /// on the current configuration.
        /// </summary>
        /// <returns>IMirror object if one is configured; NULL otherwise</returns>
        public static IMirror CreateIMirror()
        {
            //Declare a variable to return
            IMirror rtn = null;

            //Try to get an RDH2Mirror object
            //try
            //{
            //    rtn = new Mirror.RDH2Mirror();
            //}
            //catch { }

            //Try to get a LEGOMirror object if the RDH2Mirror
            //couldn't be created
            if (rtn == null)
            {
                try
                {
                    rtn = new Mirror.LEGOMirror();
                }
                catch { }
            }

            //Return the result
            return(rtn);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //Get an IMirror to move the motor
            IMirror mirror = ClassFactory.CreateIMirror();

            //Loop through commands
            String quit = "n";

            do
            {
                //Get the axis
                Console.Write("Axis: (X)");
                String axisStr = Console.ReadLine();

                if (axisStr == String.Empty)
                {
                    axisStr = "X";
                }

                //Get the power
                Console.Write("Power: (25)");
                String powerStr = Console.ReadLine();

                if (powerStr == String.Empty)
                {
                    powerStr = "25";
                }

                //Get the degrees
                Console.Write("Degrees: (90)");
                String degStr = Console.ReadLine();

                if (degStr == String.Empty)
                {
                    degStr = "90";
                }

                //Move the Mirror
                MirrorAxis axis    = (MirrorAxis)Enum.Parse(typeof(MirrorAxis), axisStr);
                Int32      power   = Int32.Parse(powerStr);
                Int32      degrees = Int32.Parse(degStr);

                mirror.Move(axis, degrees);

                //Get the char to quit
                Console.Write("Quit: (n)");
                quit = Console.ReadLine();

                if (quit == String.Empty)
                {
                    quit = "n";
                }

                Console.WriteLine();
            }while (quit != "y");

            //Dispose of the Mirror
            mirror.Dispose();
        }
Exemplo n.º 6
0
 /// <summary>
 /// view_Selected generates the IMirror interface so
 /// that the user can move the mirrors.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void view_Selected(object sender, RoutedEventArgs e)
 {
     //Create the IMirror interface
     if (this._mirror == null)
     {
         this._mirror = SHArKClassFactory.CreateIMirror();
     }
 }
Exemplo n.º 7
0
            public override bool Test(Sim a, IMirror target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!a.SimDescription.IsMermaid)
                {
                    return(false);
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Exemplo n.º 8
0
 /// <summary>
 /// view_Unselected cleans up the IMirror interface.
 /// </summary>
 /// <param name="sender">The View that is being Unselected</param>
 /// <param name="e">The EventArgs sent by the System</param>
 void view_Unselected(object sender, RoutedEventArgs e)
 {
     //Clean up the IMirror if it was created
     if (this._mirror != null)
     {
         this._mirror.Dispose();
         this._mirror = null;
     }
 }
        /// <summary>
        /// FindHardware attempts to create the hardware objects
        /// and display them to the user.
        /// </summary>
        private void FindHardware(Object parameter)
        {
            //Unpack the Parameters
            WizardControl wizard = parameter as WizardControl;

            //Set the button Enable states
            wizard.Dispatcher.BeginInvoke(new DisableButtonsDelegate(this.DisableButtons));

            //Set the Cursor on the WizardControl
            wizard.Dispatcher.BeginInvoke(new ChangeCursorDelegate(this.ChangeCursor), Cursors.Wait);

            //Create the Hardware objects
            IMirror       mirror  = SHArKClassFactory.CreateIMirror();
            IPotentiostat potstat = SHArKClassFactory.CreateIPotentiostat();
            ILaser        laser   = SHArKClassFactory.CreateILaser();

            //Get the names of the hardware -- default to not found
            String mirrorName  = Strings.DeviceNotFound;
            String potstatName = Strings.DeviceNotFound;
            String laserName   = Strings.DeviceNotFound;

            if (mirror != null)
            {
                mirrorName = mirror.Name;
                mirror.Dispose();
            }


            if (potstat != null)
            {
                potstatName = potstat.Name;
                potstat.Dispose();
            }

            if (laser != null)
            {
                laserName = laser.Name;
                laser.Dispose();
            }

            //Set the labels in the Page
            wizard.Dispatcher.BeginInvoke(new SetLabelTextDelegate(this.SetLabelText), TextBlockType.Mirror, mirrorName);
            wizard.Dispatcher.BeginInvoke(new SetLabelTextDelegate(this.SetLabelText), TextBlockType.Potentiostat, potstatName);
            wizard.Dispatcher.BeginInvoke(new SetLabelTextDelegate(this.SetLabelText), TextBlockType.Laser, laserName);

            //Set the Cursor on the WizardControl
            wizard.Dispatcher.BeginInvoke(new ChangeCursorDelegate(this.ChangeCursor), Cursors.Arrow);

            //Enable the buttons as necessary
            wizard.Dispatcher.BeginInvoke(new EnableButtonsDelegate(this.EnableButtons), wizard);

            //Set the flag that the Hardware has been searched for
            this._hardwareSearched = true;
        }
Exemplo n.º 10
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }
        IMirror mirror = GetMirrorObject();

        vh.GetUIVertexStream(_vertices);
        mirror.Draw(_vertices);
        vh.Clear();
        vh.AddUIVertexTriangleStream(_vertices);
    }
Exemplo n.º 11
0
        public static MirrorDto ToDto(this IMirror mirror)
        {
            var d = new MirrorDto
            {
                Id                      = mirror.Id,
                Name                    = mirror.Name,
                SourceRepository        = mirror.SourceRepository.ToDto(),
                TargetRepository        = mirror.TargetRepository.ToDto(),
                TargetRepositoryRefSpec = mirror.TargetRepositoryRefSpec,
                Owner                   = mirror.Owner.ToDto(),
                CreationTime            = mirror.CreationTime,
                LastSynced              = mirror.LastSynced
            };

            return(d);
        }
Exemplo n.º 12
0
        /// <summary>
        /// SetInitialLaserPosition moves the laser to the
        /// initial position indicated by the NewSpectrumInfo
        /// object.
        /// </summary>
        private void SetInitialLaserPosition(IMirror mirror, Int32 xIndex, Int32 yIndex)
        {
            //Number of Columns is always right
            Int32 columns = xIndex;

            //Calculate the number of rows to move -- subtract
            //from the total rows
            Int32 rows = this._newSpecInfo.Rows - yIndex;

            //Calculate the amount that needs to be moved
            Int32 initialXStep = columns * this._newSpecInfo.StepSize * -1;
            Int32 initialYStep = rows * this._newSpecInfo.StepSize * -1;

            //Move the mirror
            mirror.Move(MirrorAxis.X, initialXStep);
            mirror.Move(MirrorAxis.Y, initialYStep);
        }
Exemplo n.º 13
0
    private IMirror GetMirrorObject()
    {
        Image   image  = graphic as Image;
        IMirror mirror = Mirrors[Image.Type.Simple];

        if (Mirrors.ContainsKey(image.type))
        {
            mirror = Mirrors[image.type];
            mirror.Init(_mirrorType, image);
            if (mirror.CanDraw)
            {
                return(mirror);
            }
        }

        mirror.Init(_mirrorType, image);
        return(mirror);
    }
Exemplo n.º 14
0
        public async Task <IReflection> GetLatestReflectionAsync(IMirror mirror)
        {
            var uri = new Uri(this.mirrorUri, mirror.Id + "/reflections?take=1");

            Logging.Log().Debug($"Sending HTTP GET request to {uri}");

            string response = await this.httpClient.GetStringAsync(uri);

            var dto = JsonConvert.DeserializeObject <List <ReflectionDto> >(response);

            if (dto.Count == 0)
            {
                return(null);
            }

            var model = dto.First().ToReflection();

            return(model);
        }
Exemplo n.º 15
0
            public override bool Test(Sim a, IMirror target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    if (a.CurrentOutfitCategory == OutfitCategories.Singed)
                    {
                        return(false);
                    }

                    if (a.CurrentOutfitCategory == OutfitCategories.SkinnyDippingTowel)
                    {
                        return(false);
                    }

                    return(Sims.CASBase.PublicAllow(a.SimDescription, ref greyedOutTooltipCallback));
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return(false);
                }
            }
Exemplo n.º 16
0
 public SynchronizationProcess(IMirror mirror)
 {
     this.Mirror = mirror;
 }
Exemplo n.º 17
0
 public IReflection GetLatestReflection(IMirror mirror)
 {
     return(this.GetLatestReflectionAsync(mirror).Result);
 }
Exemplo n.º 18
0
 public override string GetInteractionName(Sim actor, IMirror target, InteractionObjectPair iop)
 {
     return(base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target)));
 }
Exemplo n.º 19
0
            public override bool Test(Sim a, IMirror target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    if (a.CurrentOutfitCategory == OutfitCategories.Singed) return false;

                    if (a.CurrentOutfitCategory == OutfitCategories.SkinnyDippingTowel) return false;

                    return Sims.CASBase.PublicAllow(a.SimDescription, ref greyedOutTooltipCallback);
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return false;
                }
            }
Exemplo n.º 20
0
 public override string GetInteractionName(Sim actor, IMirror target, InteractionObjectPair iop)
 {
     return base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Acquire3DData is called in a separate thread to
        /// acquire the data set up in the NewSpectrumInfo
        /// object passed to the Tab.
        /// </summary>
        private void Acquire3DData()
        {
            //Set the Mouse cursor
            this._view.Dispatcher.Invoke(new SetMouseCursorDelegate(this.SetMouseCursor), Cursors.Wait);

            //Set the basic Chart Properties
            this._view.Dispatcher.Invoke(new SetDocumentNameDelegate(this.SetDocumentName), Path.GetFileName(this._newSpecInfo.FileName));
            this._view.Dispatcher.Invoke(new SetAxisRangesDelegate(this.SetAxisRanges), this._newSpecInfo.Columns - 1, this._newSpecInfo.Rows - 1);

            //Set the run state on the Chart
            this._view.Dispatcher.Invoke(new SetRunStateDelegate(this.SetRunState), true);

            //Get the Hardware objects -- just return
            //if any of them is null
            IMirror       mirror  = null;
            IPotentiostat potstat = null;
            ILaser        laser   = null;

            this.GetHardwareObjects(ref mirror, ref potstat, ref laser);

            if (mirror == null || potstat == null || laser == null)
            {
                return;
            }

            //Try to run the entire Acquisition
            try
            {
                //Initialize the new SHArKFile
                ISHArKFile file = SHArKFileFactory.Create(this._newSpecInfo.FileName, true);

                //Set the potential on the electrode
                potstat.SetPotential(this._newSpecInfo.BiasPotential);

                //Reset the Laser to the Initial Position
                this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), Strings.ResetInitialPosition);
                this.SetInitialLaserPosition(mirror, this._newSpecInfo.Columns, 0);

                //Finally, reset the mouse cursor so that the user
                //can see that initial processing is over
                this._view.Dispatcher.Invoke(new SetMouseCursorDelegate(this.SetMouseCursor), Cursors.Arrow);

                //Check the Poteniostat to see if the current is too
                //high to start a scan -- open the box if necessary
                if (potstat.IsCurrentSettled == false)
                {
                    this._view.Dispatcher.Invoke(new ShowDarkCurrentDialogDelegate(this.ShowDarkCurrentDialog), potstat);
                }

                //Do the acquisition while the user does not
                //want to Pause or Stop
                Int32 xIndex = 0;
                Int32 yIndex = this._newSpecInfo.Rows - 1;
                Int32 xStep  = this._newSpecInfo.StepSize;

                while (this.IsRunning == true)
                {
                    //Get the time remaining as a String
                    TimeSpan tsRemaining   = this._newSpecInfo.CalculateTimeRemaining(xIndex, yIndex);
                    String   timeRemaining = String.Format("{0:D2}:{1:D2}:{2:D2}", tsRemaining.Hours, tsRemaining.Minutes, tsRemaining.Seconds);

                    //Set the status on the Window to show that the
                    //scan is running
                    this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(SetWindowStatus),
                                                 String.Format("{0} {1} Remaining", Strings.ScanRunning, timeRemaining));

                    //Get the Dark Current value from the Potentiostat
                    Double darkCurrent = potstat.GetCurrent(this._newSpecInfo.NumberCurrentSamples);

                    //Turn on the Laser and wait the specified amount of time
                    laser.SetLaserState(true);
                    Thread.Sleep(this._newSpecInfo.MillisecondsLaserOnDelay);

                    //Acquire the data for the current point
                    Double lightCurrent = potstat.GetCurrent(this._newSpecInfo.NumberCurrentSamples);

                    //Add the Point to the file
                    Point p = new Point(xIndex, yIndex, lightCurrent - darkCurrent);
                    file.AddDataPoint(p);

                    //Turn off the laser and wait the specified amount of time
                    laser.SetLaserState(false);
                    Thread.Sleep(this._newSpecInfo.MillisecondsLaserOffDelay);

                    //Set the Point in the ObservableCollection so
                    //that it updates the Chart
                    this._view.Dispatcher.Invoke(new AddPointsToChartDelegate(this.AddPointsToChart), new Point[] { p }, this._newSpecInfo.MaxCurrentValue);

                    //Determine the direction of the X-Axis movement --
                    //if this is an odd row (relative to starting at
                    //this._newSpecInfo.Rows - 1), move backward
                    xStep = this._newSpecInfo.StepSize;

                    if ((this._newSpecInfo.Rows % 2 == 0 && yIndex % 2 == 0) ||
                        (this._newSpecInfo.Rows % 2 == 1 && yIndex % 2 == 1))
                    {
                        xStep *= -1;
                    }

                    //Determine if the Y-Axis mirror needs to move.
                    //If the direction is positive, move when the
                    //X-Axis gets to Columns.  Otherwise, move when
                    //the X-Axis gets to 0.
                    if ((xStep > 0 && xIndex == this._newSpecInfo.Columns - 1) ||
                        (xStep < 0 && xIndex == 0))
                    {
                        //Move the Y-Axis Mirror
                        mirror.Move(MirrorAxis.Y, this._newSpecInfo.StepSize);

                        //Update the yIndex
                        yIndex--;
                    }

                    //Move to the next Column if necessary
                    if ((xStep > 0 && xIndex < this._newSpecInfo.Columns - 1) ||
                        (xStep < 0 && xIndex > 0))
                    {
                        //Move to the next Column
                        mirror.Move(MirrorAxis.X, xStep);

                        //Update the xIndex based on the direction
                        //of the step
                        if (xStep > 0)
                        {
                            xIndex++;
                        }
                        else
                        {
                            xIndex--;
                        }
                    }

                    //Check to see if the scan is finished
                    if (yIndex == -1 && ((xStep > 0 && xIndex == this._newSpecInfo.Columns - 1) || (xStep < 0 && xIndex == 0)))
                    {
                        this.IsRunning = false;
                    }

                    //If the user has Paused the acquisition,
                    //loop and Sleep until resumed
                    while (this.IsPaused == true && this.IsRunning == true)
                    {
                        //Stop the Laser from modulating
                        laser.SetLaserState(false);

                        //Set the status on the Window
                        this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus),
                                                     String.Format("{0} {1} Remaining", Strings.ScanPaused, timeRemaining));

                        //Sleep for a half-second
                        Thread.Sleep(500);
                    }
                }

                //Stop the Laser from modulating
                laser.SetLaserState(false);

                //Move the Mirror back to the Initial Position
                this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), Strings.ResetInitialPosition);
                this.SetInitialLaserPosition(mirror, xIndex, yIndex);
            }
            catch (System.Exception e)
            {
                //Show an error message and return
                this._view.Dispatcher.Invoke(new ShowErrorDelegate(this.ShowError), e.Message);
                return;
            }
            finally
            {
                //Clean up the Hardware objects
                if (mirror != null)
                {
                    mirror.Dispose();
                }

                if (potstat != null)
                {
                    potstat.SetPotential(0.0);
                    potstat.Dispose();
                }

                if (laser != null)
                {
                    laser.SetLaserState(false);
                    laser.Dispose();
                }

                //Publish the event to notify that the Spectrum
                //has finished
                this._view.Dispatcher.Invoke(new NotifySpectrumEndedDelegate(this.NotifySpectrumEnded));

                //Reset the Window Status
                this._view.Dispatcher.Invoke(new SetWindowStatusDelegate(this.SetWindowStatus), String.Empty);
            }
        }
Exemplo n.º 22
0
 public IEnumerable <ISynchronization> GetByMirror(IMirror mirror, int?take = null)
 {
     return(this.query.GetByMirror(mirror, take));
 }
Exemplo n.º 23
0
        public IEnumerable <IReflection> GetByMirror(IMirror mirror, int?take)
        {
            var result = this.query.GetByMirror(mirror, take);

            return(result);
        }
Exemplo n.º 24
0
            public override bool Test(Sim a, IMirror target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!a.SimDescription.IsMermaid) return false;

                return base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback);
            }