Esempio n. 1
0
        //private static SySal.DAQSystem.Scanning.ZoneDesc[] GetRegionScans(SySal.DAQSystem.Scanning.ZoneDesc newZones, SySal.DAQSystem.Scanning.ZoneDesc[] oldZones)
        //{
        //    if (oldZones.Length == 1) return GetRegionScans(newZones, oldZones[0]);

        //    foreach (SySal.DAQSystem.Scanning.ZoneDesc o in oldZones)
        //    {
        //        newZones = GetRegionScans(newZones, o);
        //    }
        //    return newZones;
        //}

        private static SySal.DAQSystem.Scanning.ZoneDesc[] GetRegionScans(SySal.DAQSystem.Scanning.ZoneDesc newZone, SySal.DAQSystem.Scanning.ZoneDesc oldZone)
        {
            float scale = 1000;

            float x      = Convert.ToSingle(newZone.MinX / scale);
            float y      = Convert.ToSingle(newZone.MinY / scale);
            float width  = Convert.ToSingle((newZone.MaxX - newZone.MinX) / scale);
            float height = Convert.ToSingle((newZone.MaxY - newZone.MinY) / scale);

            System.Drawing.RectangleF ZoneToScan = new System.Drawing.RectangleF(x, y, width, height);

            x      = Convert.ToSingle(oldZone.MinX / scale);
            y      = Convert.ToSingle(oldZone.MinY / scale);
            width  = Convert.ToSingle((oldZone.MaxX - oldZone.MinX) / scale);
            height = Convert.ToSingle((oldZone.MaxY - oldZone.MinY) / scale);
            System.Drawing.RectangleF OldZone = new System.Drawing.RectangleF(x, y, width, height);

            Console.WriteLine("ZoneToScan: " + ZoneToScan.Left + " " + ZoneToScan.Right + " " + ZoneToScan.Top + " " + ZoneToScan.Bottom);
            Console.WriteLine("OldZone:    " + OldZone.Left + " " + OldZone.Right + " " + OldZone.Top + " " + OldZone.Bottom);

            System.Drawing.Region NewRegion = new System.Drawing.Region(ZoneToScan);

            NewRegion.Exclude(OldZone);

            System.Drawing.RectangleF[] rectangles = NewRegion.GetRegionScans(new System.Drawing.Drawing2D.Matrix());

            if (rectangles.Length == 0)
            {
                return(null);
            }

            SySal.DAQSystem.Scanning.ZoneDesc[] zones = new SySal.DAQSystem.Scanning.ZoneDesc[rectangles.Length];

            for (int i = 0; i < zones.Length; i++)
            {
                zones[i]      = new SySal.DAQSystem.Scanning.ZoneDesc();
                zones[i].MinX = rectangles[i].Left * scale;
                zones[i].MaxX = rectangles[i].Right * scale;
                zones[i].MinY = rectangles[i].Top * scale;
                zones[i].MaxY = rectangles[i].Bottom * scale;
            }
            return(zones);
        }
Esempio n. 2
0
            public override bool Execute()
            {
                Console.WriteLine();
                Console.Write(LineNumber + "->" + StrScan + "->");
                SySal.DAQSystem.Scanning.ZoneDesc zd = new SySal.DAQSystem.Scanning.ZoneDesc();
                zd.Series           = Id;
                zd.MinX             = MinX;
                zd.MinY             = MinY;
                zd.MaxX             = MaxX;
                zd.MaxY             = MaxY;
                zd.UsePresetSlope   = UseSlopePresel;
                zd.PresetSlope.X    = 0.5 * (MinSX + MaxSX);
                zd.PresetSlope.Y    = 0.5 * (MinSY + MaxSY);
                zd.PresetSlopeAcc.X = 0.5 * (MaxSX - MinSX);
                zd.PresetSlopeAcc.Y = 0.5 * (MaxSY - MinSY);
                zd.Outname          = OutputFile;
                bool scan = ScanSrv.Scan(zd);

                Console.Write(scan);
                return(scan);
            }
Esempio n. 3
0
        public static SySal.DAQSystem.Scanning.ZoneDesc[] CalculateZones(long brickid, long plateid)
        {
            System.Data.DataSet ds = new System.Data.DataSet();
            new SySal.OperaDb.OperaDbDataAdapter("select minx-zerox, maxx-zerox, miny-zeroy, maxy-zeroy from tb_eventbricks where id = " + brickid, Conn).Fill(ds);

            double local_brick_minx = Convert.ToDouble(ds.Tables[0].Rows[0][0], System.Globalization.CultureInfo.InvariantCulture);
            double local_brick_maxx = Convert.ToDouble(ds.Tables[0].Rows[0][1], System.Globalization.CultureInfo.InvariantCulture);
            double local_brick_miny = Convert.ToDouble(ds.Tables[0].Rows[0][2], System.Globalization.CultureInfo.InvariantCulture);
            double local_brick_maxy = Convert.ToDouble(ds.Tables[0].Rows[0][3], System.Globalization.CultureInfo.InvariantCulture);

            System.Collections.ArrayList newZoneArray = new ArrayList();
            string EventType = Convert.ToString(new SySal.OperaDb.OperaDbCommand("select DISTINCT type from vw_local_predictions where id_cs_eventbrick = " + brickid, Conn).ExecuteScalar());

            //TODO: improve this part: multi-zone for CC-like events

            if (EventType.Equals("CC") || EventType.Equals("NC"))
            {
                ds = new System.Data.DataSet();
                new SySal.OperaDb.OperaDbDataAdapter("select pred_localx, pred_localy, POSTOL1, POSTOL2 from vw_local_predictions where id_cs_eventbrick = " + brickid, Conn).Fill(ds);

                double posx, posy, postolx, postoly;
                SySal.DAQSystem.Scanning.ZoneDesc zone = new SySal.DAQSystem.Scanning.ZoneDesc();
                posx    = Convert.ToDouble(ds.Tables[0].Rows[0][0], System.Globalization.CultureInfo.InvariantCulture);
                posy    = Convert.ToDouble(ds.Tables[0].Rows[0][1], System.Globalization.CultureInfo.InvariantCulture);
                postolx = (ds.Tables[0].Rows[0][2] != DBNull.Value) ? Convert.ToDouble(ds.Tables[0].Rows[0][2], System.Globalization.CultureInfo.InvariantCulture) : ProgSettings.PositionToleranceX;
                postoly = (ds.Tables[0].Rows[0][3] != DBNull.Value) ? Convert.ToDouble(ds.Tables[0].Rows[0][3], System.Globalization.CultureInfo.InvariantCulture) : ProgSettings.PositionToleranceY;

                zone.MinX = posx - postolx;
                zone.MaxX = posx + postolx;
                zone.MinY = posy - postoly;
                zone.MaxY = posy + postoly;

                foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
                {
                    posx    = Convert.ToDouble(dr[0], System.Globalization.CultureInfo.InvariantCulture);
                    posy    = Convert.ToDouble(dr[1], System.Globalization.CultureInfo.InvariantCulture);
                    postolx = (dr[2] != DBNull.Value) ? Convert.ToDouble(dr[2], System.Globalization.CultureInfo.InvariantCulture) : ProgSettings.PositionToleranceX;
                    postoly = (dr[3] != DBNull.Value) ? Convert.ToDouble(dr[3], System.Globalization.CultureInfo.InvariantCulture) : ProgSettings.PositionToleranceY;

                    zone.MinX = Math.Min(zone.MinX, posx - postolx);
                    zone.MaxX = Math.Max(zone.MaxX, posx + postolx);
                    zone.MinY = Math.Min(zone.MinY, posy - postoly);
                    zone.MaxY = Math.Max(zone.MaxY, posy + postoly);
                }
                newZoneArray.Add(zone);
            }

            foreach (SySal.DAQSystem.Scanning.ZoneDesc z in newZoneArray)
            {
                if (z.MinX < local_brick_minx)
                {
                    z.MinX = local_brick_minx;
                }
                if (z.MaxX > local_brick_maxx)
                {
                    z.MaxX = local_brick_maxx;
                }
                if (z.MinY < local_brick_miny)
                {
                    z.MinY = local_brick_miny;
                }
                if (z.MaxY > local_brick_maxy)
                {
                    z.MaxY = local_brick_maxy;
                }
            }

            System.Collections.ArrayList ZoneArray = null;

            if (ProgSettings.SkipMeasuredAreas == true)
            {
                ZoneArray = new ArrayList();

                ds = new System.Data.DataSet();
                new SySal.OperaDb.OperaDbDataAdapter("SELECT a.id_processoperation, MIN(a.minx) as minx, MAX(a.maxx) as maxx, MIN(a.miny) as miny, MAX(a.maxy) as maxy FROM tb_zones a INNER JOIN tb_proc_operations b ON(b.id = a.id_processoperation) WHERE a.id_eventbrick = " + brickid + " AND b.id_plate = " + plateid + " AND b.success = 'Y' GROUP BY a.id_processoperation", Conn).Fill(ds);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    SySal.DAQSystem.Scanning.ZoneDesc[] oldZones = new SySal.DAQSystem.Scanning.ZoneDesc[ds.Tables[0].Rows.Count];
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        oldZones[i]        = new SySal.DAQSystem.Scanning.ZoneDesc();
                        oldZones[i].Series = Convert.ToInt64(ds.Tables[0].Rows[0][0]);
                        oldZones[i].MinX   = Convert.ToDouble(ds.Tables[0].Rows[0][1], System.Globalization.CultureInfo.InvariantCulture);
                        oldZones[i].MaxX   = Convert.ToDouble(ds.Tables[0].Rows[0][2], System.Globalization.CultureInfo.InvariantCulture);
                        oldZones[i].MinY   = Convert.ToDouble(ds.Tables[0].Rows[0][3], System.Globalization.CultureInfo.InvariantCulture);
                        oldZones[i].MaxY   = Convert.ToDouble(ds.Tables[0].Rows[0][4], System.Globalization.CultureInfo.InvariantCulture);
                    }

                    foreach (SySal.DAQSystem.Scanning.ZoneDesc n in newZoneArray)
                    {
                        foreach (SySal.DAQSystem.Scanning.ZoneDesc o in oldZones)
                        {
                        }
                    }
                }
            }
            else
            {
                ZoneArray = newZoneArray;
            }

            return((SySal.DAQSystem.Scanning.ZoneDesc[])ZoneArray.ToArray(typeof(SySal.DAQSystem.Scanning.ZoneDesc)));
        }
Esempio n. 4
0
        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");
        }
Esempio n. 5
0
        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();
        }