public void measurementsCompleted(object sender, EventArgs args) { //if scanning then go to the next point if (scanning) { if (scanIndex < scanPoints.GetLength(0)) { txtSetXPos.Text = Convert.ToString(scanPoints[scanIndex, 0]); txtSetYPos.Text = Convert.ToString(scanPoints[scanIndex, 1]); txtSetZPos.Text = Convert.ToString(scanPoints[scanIndex, 2]); gotoPoint(); scanIndex++; if (xyzPointReached != null) { XYZEventArgs evt = new XYZEventArgs(getCurrentPoint()); xyzPointReached(this, evt); } } else { cmdStartScan.BackColor = stdBgColor; scanning = false; } } }
/** * Called when the xyz stage is at a new point * */ public void xyzPointReached(object sender, XYZEventArgs evt) { //record the current point datasaverRaw.writeCoordinates(evt.curPoint.x, evt.curPoint.y, evt.curPoint.z, 0, null); datasaverProcessed.writeCoordinates(evt.curPoint.x, evt.curPoint.y, evt.curPoint.z, 0, null); //count the no. of data aquisitions before allowing the xyz stage to continue nMeasurements = 0; }
private void cmdStartScan_Click(object sender, EventArgs e) { //clean up any previous on-going scan scanning = false; //goto the start point gotoStart(); //calculate the scanning points int ntot = nx * ny * nz; scanPoints = new double[ntot, 3]; double dx = Convert.ToDouble(txtDeltaX.Text); double dy = Convert.ToDouble(txtDeltaY.Text); double dz = Convert.ToDouble(txtDeltaZ.Text); for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { for (int k = 0; k < nz; k++) { int curIndex = i * ny * nz + j * nz + k; scanPoints[curIndex, 0] = startPoint.x + i * dx; scanPoints[curIndex, 1] = startPoint.y + j * dy; scanPoints[curIndex, 2] = startPoint.z + k * dz; } } } //start at one as the first point will be measured directly below scanIndex = 1; //raise the flag that a scan is now ongoing scanning = true; stdBgColor = cmdStartScan.BackColor; cmdStartScan.BackColor = Color.LawnGreen; //send the event that a point has been reached and that data should be collected if (xyzPointReached != null) { XYZEventArgs evt = new XYZEventArgs(getCurrentPoint()); xyzPointReached(this, evt); } }