public _4DGridPosition(X_Value x, Y_Value y, Z_Value z, W_Value w) { this.X = x; this.Y = y; this.Z = z; this.W = w; }
public void SetGrid(int dimensions) { grid = new SwappingGrid(); for (int n = 0; n < 2; n++) { var builder = new InfiniteAdjacencyGridBuilder <int, _4DGridPosition>(); if (dimensions > 3) { builder.AddLayer(igp => igp.W, (igp, val) => igp.W = val); } if (dimensions > 2) { builder.AddLayer(igp => igp.Z, (igp, val) => igp.Z = val); } builder.AddLayer(igp => igp.Y, (igp, val) => igp.Y = val); builder.AddLayer(igp => igp.X, (igp, val) => igp.X = val); grid.Current = builder.Complete(); grid.Swap(); } var wCoord = W_Value.Get(0); var zCoord = Z_Value.Get(0); for (int y = 0; y < lines.Length; y++) { var yCoord = Y_Value.Get(y); for (int x = 0; x < lines[y].Length; x++) { var xCoord = X_Value.Get(x); var pos = new _4DGridPosition(xCoord, yCoord, zCoord, wCoord); int val = 0; if (lines[y][x] == '#') { grid.Front.Add(pos); val = 10000; } grid.Current.Set(pos, val); } } grid.Front.Swap(); ofInterest = new HashSet <_4DGridPosition>(); }
//********************************************************* public void Thread2() { try { while (request) { serialPort.ReadExisting(); byte[] data = new byte[8]; data[0] = 75; data[1] = 75; data[2] = 75; serialPort.Write(data, 0, 3); int[] d = new int[10]; label1.Text = ""; if (serialPort.ReadChar() == 65) { if (serialPort.ReadChar() == 65) { for (int i = 0; i <= 9; i++) { d[i] = serialPort.ReadChar(); //label1.Text += d[i].ToString() + ", "; } //----------------------Getting X-------------------------------- if (d[2] == 0) // this is for posetive values { double x = (int)(d[1] << 8) + (d[0]); X_Value.Invoke(new Action(() => X_Value.Text = ((x) / 100).ToString())); } else // this is for negetive values { double x = (int)(d[1] << 8) + (d[0]); X_Value.Invoke(new Action(() => X_Value.Text = (-(x) / 100).ToString())); } //-----------------------Getting Y------------------------------- if (d[5] == 0) // this is for posetive values { double y = (int)(d[4] << 8) + (d[3]); Y_Value.Invoke(new Action(() => Y_Value.Text = ((y) / 100).ToString())); } else // this is for negetive values { double y = (int)(d[4] << 8) + (d[3]); Y_Value.Invoke(new Action(() => Y_Value.Text = (-(y) / 100).ToString())); } //-----------------------Getting Z------------------------------- if (d[8] == 0) // this is for posetive values { double z = (int)(d[7] << 8) + (d[6]); Z_Value.Invoke(new Action(() => Z_Value.Text = ((z) / 100).ToString())); } else // this is for negetive values { double z = (int)(d[7] << 8) + (d[6]); Z_Value.Invoke(new Action(() => Z_Value.Text = (-(z) / 100).ToString())); } //Y_Value.Text = d[4].ToString(); } } System.Threading.Thread.Sleep(100); } } catch { } }