static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("ListScan: <scanserver address> <zone list file> <XML scanning configuration file>"); Console.WriteLine("Zone list file syntax: "); Console.WriteLine(" Plate line: <brick>,<plate>,<map init string>"); Console.WriteLine(" Zone line: <id>,<minx>,<maxx>,<miny>,<maxy>,<output name>"); Console.WriteLine(" Note: first line must be a Plate line "); return; } System.IO.StreamReader r = new System.IO.StreamReader(args[2]); string config = r.ReadToEnd(); r.Close(); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new TcpChannel()); SySal.DAQSystem.ScanServer ScanSrv = (SySal.DAQSystem.ScanServer)System.Runtime.Remoting.RemotingServices.Connect(typeof(SySal.DAQSystem.ScanServer), "tcp://" + args[0] + ":" + ((int)SySal.DAQSystem.OperaPort.ScanServer).ToString() + "/ScanServer.rem"); ScanSrv.SetScanLayout(config); SySal.DAQSystem.Scanning.MountPlateDesc plated = new SySal.DAQSystem.Scanning.MountPlateDesc(); r = new System.IO.StreamReader(args[1]); // bool isloaded = false; string line = r.ReadLine(); string [] tokens = line.Split(','); if (tokens.Length != 3) { Console.WriteLine("First Line must be a Plate line"); return; } do { tokens = line.Split(','); if (!(tokens.Length == 6 || tokens.Length == 3)) { Console.WriteLine("Plate line must be in the format:\n<brick>,<plate>,<map init string>"); Console.WriteLine("Zone line must be in the format:\n<id>,<minx>,<maxx>,<miny>,<maxy>,<output name>"); Console.WriteLine("Skipping line: " + line); continue; } try { if (tokens.Length == 3) { plated.BrickId = Convert.ToInt32(tokens[0]); plated.PlateId = Convert.ToInt32(tokens[1]); plated.MapInitString = tokens[2]; plated.TextDesc = ""; Console.WriteLine("Load Plate: " + plated.PlateId); if (!ScanSrv.LoadPlate(plated)) { Console.WriteLine("ERROR: Unable to LOAD PLATE"); return; } } else if (tokens.Length == 6) { int id; double minx, maxx, miny, maxy; id = Convert.ToInt32(tokens[0]); minx = Convert.ToDouble(tokens[1]); maxx = Convert.ToDouble(tokens[2]); miny = Convert.ToDouble(tokens[3]); maxy = Convert.ToDouble(tokens[4]); Console.WriteLine(" scan zone: " + id + " ( " + minx + ", " + maxx + ", " + miny + ", " + maxx + ", " + minx + ")"); SySal.DAQSystem.Scanning.ZoneDesc zd = new SySal.DAQSystem.Scanning.ZoneDesc(); zd.Series = id; zd.MinX = minx; zd.MaxX = maxx; zd.MinY = miny; zd.MaxY = maxy; zd.Outname = tokens[5]; ScanSrv.Scan(zd); } } catch (Exception x) { Console.WriteLine("Error \n" + x.Message + "\nat line: " + line); Console.WriteLine("Line skipped"); } } while ((line = r.ReadLine()) != null && line.Length > 0); Console.WriteLine("List scan complete"); }
static void Main(string[] args) { // // TODO: Add code to start application here // if (args.Length != 4) { Console.WriteLine("usage: CSTrackSearch <server> <input file> <link file> <output file>"); return; } System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new TcpChannel()); SySal.DAQSystem.ScanServer Srv = (SySal.DAQSystem.ScanServer)System.Runtime.Remoting.RemotingServices.Connect(typeof(SySal.DAQSystem.ScanServer), "tcp://" + args[0] + ":1777/ScanServer.rem"); System.IO.StreamReader inf = new System.IO.StreamReader(args[1]); SySal.DAQSystem.Scanning.MountPlateDesc mpd; mpd.Id.Part0 = mpd.Id.Part1 = mpd.Id.Part2 = mpd.Id.Part3 = 0; mpd.TextDesc = inf.ReadLine(); Srv.LoadPlate(mpd); StripesFragLink2.StripesFragmentLinker sfl = new StripesFragLink2.StripesFragmentLinker(); System.IO.FileStream sff = new System.IO.FileStream(args[2], System.IO.FileMode.Open, System.IO.FileAccess.Read); System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(typeof(StripesFragLink2.Configuration)); StripesFragLink2.Configuration sfc = (StripesFragLink2.Configuration)xmls.Deserialize(sff); SFL.Config = sfc; sff.Close(); System.IO.StreamWriter outf = new System.IO.StreamWriter(args[3]); outf.AutoFlush = true; System.DateTime Start = System.DateTime.Now; Console.WriteLine("Batch started. Time: " + Start.ToString()); string line; int pos; while ((line = inf.ReadLine()).Length > 0) { pos = 0; Identifier Id; double px, py, sx, sy, ptol, stol; int minpts; Id.Part0 = Convert.ToInt32(GetNextToken(line, ref pos)); Id.Part1 = Convert.ToInt32(GetNextToken(line, ref pos)); Id.Part2 = Convert.ToInt32(GetNextToken(line, ref pos)); Id.Part3 = Convert.ToInt32(GetNextToken(line, ref pos)); px = Convert.ToDouble(GetNextToken(line, ref pos)); py = Convert.ToDouble(GetNextToken(line, ref pos)); sx = Convert.ToDouble(GetNextToken(line, ref pos)); sy = Convert.ToDouble(GetNextToken(line, ref pos)); minpts = Convert.ToInt32(GetNextToken(line, ref pos)); ptol = Convert.ToDouble(GetNextToken(line, ref pos)); stol = Convert.ToDouble(GetNextToken(line, ref pos)); SySal.DAQSystem.Scanning.ZoneDesc zd; zd.Id = Id; zd.MinX = px - ptol; zd.MaxX = px + ptol; zd.MinY = py - ptol; zd.MaxY = py + ptol; zd.Outname = GetNextToken(line, ref pos).Trim(); bool success; Console.WriteLine("Zone {0}/{1}/{2}/{3} {4} {5} {6} {7} {8}", zd.Id.Part0, zd.Id.Part1, zd.Id.Part2, zd.Id.Part3, px, py, sx, sy, (success = Srv.Scan(zd))); if (success) { new DataProcessor(zd.Id, zd.Outname, px, py, sx, sy, minpts, ptol, stol, outf).Process(); } } inf.Close(); outf.Close(); Console.WriteLine("Batch finished. Total time: " + (System.DateTime.Now - Start).ToString()); }
static void Main(string[] args) { // // TODO: Add code to start application here // if (args.Length != 3) { Console.WriteLine("usage: filebatch <serveraddress> <inputfile> <outputfile>"); return; } ChannelServices.RegisterChannel(new TcpChannel()); SySal.DAQSystem.ScanServer Srv = (SySal.DAQSystem.ScanServer)RemotingServices.Connect(typeof(SySal.DAQSystem.ScanServer), "tcp://" + args[0] + ":" + ((int)(SySal.DAQSystem.OperaPort.ScanServer)).ToString() + "/ScanServer.rem"); System.IO.StreamReader r = new System.IO.StreamReader(args[1]); System.IO.StreamWriter w = new System.IO.StreamWriter(args[2]); w.AutoFlush = true; int count = 0; try { string [] data = r.ReadLine().Split(' '); if (data.Length != 5) { throw new Exception("Invalid header"); } SySal.DAQSystem.Scanning.MountPlateDesc mpd = new SySal.DAQSystem.Scanning.MountPlateDesc(); mpd.Id.Part0 = Convert.ToInt32(data[0]); mpd.Id.Part1 = Convert.ToInt32(data[1]); mpd.Id.Part2 = Convert.ToInt32(data[2]); mpd.Id.Part3 = Convert.ToInt32(data[3]); mpd.TextDesc = data[4]; mpd.MapInitString = r.ReadLine(); bool ret; w.WriteLine("LoadPlate: {0} {1} {2} {3} {4} - Result: {5}", data[0], data[1], data[2], data[3], data[4], (ret = Srv.LoadPlate(mpd))); if (ret == false) { throw new Exception("Plate not loaded"); } while (true) { string line; line = r.ReadLine(); if (line == null) { break; } data = line.Split(' '); if (data.Length != 9) { throw new Exception("Invalid prediction"); } SySal.DAQSystem.Scanning.ZoneDesc zd = new SySal.DAQSystem.Scanning.ZoneDesc(); zd.Id.Part0 = Convert.ToInt32(data[0]); zd.Id.Part1 = Convert.ToInt32(data[1]); zd.Id.Part2 = Convert.ToInt32(data[2]); zd.Id.Part3 = Convert.ToInt32(data[3]); zd.MinX = Convert.ToSingle(data[4]); zd.MaxX = Convert.ToSingle(data[5]); zd.MinY = Convert.ToSingle(data[6]); zd.MaxY = Convert.ToSingle(data[7]); zd.Outname = data[8]; w.WriteLine("Scan: {0} {1} {2} {3} {4} {5} {6} {7} {8} - Result: {9} - at {10}", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], Srv.Scan(zd), System.DateTime.Now); Console.WriteLine("Prediction {0} complete", ++count); } w.WriteLine("UnloadPlate: - Result: {0}", Srv.UnloadPlate()); } catch (Exception x) { w.WriteLine("Batch Interrupted at {0}", System.DateTime.Now); w.WriteLine("Reason: {0}", x.Message); w.WriteLine("Details: {0}", x.ToString()); } Console.WriteLine("Batch finished"); w.Close(); r.Close(); }