public static int MoveTo(double position) { int movestat; ccdsoftCamera tsxc = new ccdsoftCamera(); if (position < tsxc.focPosition) { movestat = tsxc.focMoveIn((int)(tsxc.focPosition - position)); } else { movestat = tsxc.focMoveOut((int)(position - tsxc.focPosition)); } return(movestat); }
public static string PresetFocus() { //Sets the focuser to the position set by the StepsPerDegree and StepAtZero (slope and intercept) // as accumulated for the focuser. If StepsPerDegree is zero, then no movement is made Configuration cfg = new Configuration(); ccdsoftCamera tsxc = new ccdsoftCamera(); tsxc.Connect(); double currentTemp = tsxc.focTemperature; int currentPosition = tsxc.focPosition; double stepsPerDegree = Convert.ToDouble(cfg.StepsPerDegree); double positionAtZero = Convert.ToDouble(cfg.PositionAtZero); string logUpdate; if (stepsPerDegree != 0.0) { int newPosition = (int)(currentTemp * stepsPerDegree + positionAtZero); int move = (newPosition - currentPosition); logUpdate = "Moving Focuser to initial position @ " + currentTemp.ToString("0.0") + " C => " + newPosition.ToString("0") + " Steps"; try { if (move > 0) { tsxc.focMoveOut(move); } else { tsxc.focMoveIn(-move); } } catch (Exception ex) { logUpdate += " -- FAILED: " + ex.Message; } } else { logUpdate = "Cannot determine preset position for focuser"; } return(logUpdate); }