public enuScannerErrors Initialize() { mStatus = 0; //todo: check parameters, reflect correctness in the status flag //store current absolute position as starting position and calculate edge positions if (mPositioner.GetAbsolutePosition(ref mStartPosition) != enuPositionerStatus.Error) { return(enuScannerErrors.Error); // todo: log the error? } Position mPos = new Position(); mPos = mStartPosition.Copy; mPos.X += mRadius; mPos.Y += mRadius; if (mPositioner.ValidateAbsolutePosition(ref mPos) != enuPositionerStatus.Ready) { return(enuScannerErrors.Error); // upper right corner } mPos = mStartPosition.Copy; mPos.X -= mRadius; mPos.Y -= mRadius; if (mPositioner.ValidateAbsolutePosition(ref mPos) != enuPositionerStatus.Ready) { return(enuScannerErrors.Error); // lower left corner } mPos = mStartPosition.Copy; mPos.X += mRadius; mPos.Y -= mRadius; if (mPositioner.ValidateAbsolutePosition(ref mPos) != enuPositionerStatus.Ready) { return(enuScannerErrors.Error); // lower right corner } mPos = mStartPosition.Copy; mPos.X -= mRadius; mPos.Y += mRadius; if (mPositioner.ValidateAbsolutePosition(ref mPos) != enuPositionerStatus.Ready) { return(enuScannerErrors.Error); // upper left corner } if (mPositioner.ValidateSpeeds(ref mSpeeds) != enuPositionerStatus.Ready) { return(enuScannerErrors.Error); // todo: log the error? } mStatus = enuScannerErrors.Initialized; mStatus |= enuScannerErrors.Ready; return(mStatus); }
public override enExperimentStatus Configure(IExperiment parent, string resultsFilePath) { if (status != enExperimentStatus.Running) { this.parent = parent; ResultsFilePath = Path.Combine(resultsFilePath, Name); ; ResultsFileName = "ExpScanArray - " + Name + ".dat"; IPositioner pos = Settings.Positioners[Settings.Positioner]; if (Settings.Tilt) { pos = Settings.Positioners[Settings.TiltPositioner]; Tilt = new TiltCorrection(pos, Settings.Pos1, Settings.Pos2, Settings.Pos3, Settings.Offset); Tilt.PositionStore = PositionStore; } Scanner = new ScannerArray(Settings.ScannerMode, pos, Settings.Lengths, Settings.Increments, Settings.Speeds, Settings.ReverseSpeeds, Settings.PreMovementHook, Settings.PostMovementHook, Tilt, Settings.XDelay, Settings.YDelay, Settings.ZDelay, log); Scanner.Initialize(); //safety check: if the tilt correction is in use, a scan in Z direction is not a good idea. if ((Math.Abs(Settings.Increments.Z) > 0) && (Math.Abs(Settings.Lengths.Z) > 0) && (Math.Abs(Settings.Increments.Z) <= Math.Abs(Settings.Lengths.Z)) && (Settings.Tilt)) { //todo: describe error return enExperimentStatus.Error; } // create ScanData container scanData = new ScanData(); scanData.experimentName = Name; reverseScanX = Settings.Increments.X < 0; reverseScanY = Settings.Increments.Y < 0; scanData.setScanDimensions(Scanner.NumScanPoints[0], Scanner.NumScanPoints[1]); // Current Positioner pos Position startPos = new Position(); if(pos.GetAbsolutePosition(ref startPos) != enuPositionerStatus.Ready) return enExperimentStatus.Error; // set scanData dimensions scanData.X0 = Math.Min(startPos.X, (Scanner.NumScanPoints[0] - 1) * Settings.Increments.X); scanData.Y0 = Math.Min(startPos.Y, (Scanner.NumScanPoints[1] - 1) * Settings.Increments.Y); scanData.X1 = Math.Max(startPos.X, (Scanner.NumScanPoints[0] - 1) * Settings.Increments.X); scanData.Y1 = Math.Max(startPos.Y, (Scanner.NumScanPoints[1] - 1) * Settings.Increments.Y); status = enExperimentStatus.Idle; return status; } return enExperimentStatus.Error; }
//absolute global position as returned by all positioners public Position CurrentAbsolutePosition() { Position pos = new Position(0, 0, 0); Position ipos = new Position(0, 0, 0); var positioners = hwStore.Where(x => typeof(IPositioner).IsAssignableFrom(x.Value.GetType())).Select(x => x); foreach (var iterator in positioners) { IPositioner positioner = iterator.Value as IPositioner; positioner.GetAbsolutePosition(ref ipos); pos = pos.Sum(ipos); } return(pos); }