コード例 #1
0
 void RefreshProgramSettings(SySal.OperaDb.OperaDbConnection conn)
 {
     SySal.OperaDb.OperaDbDataReader rd2 = null;
     try
     {
         lvProgramSettings.Items.Clear();
         string sql = "";
         if (chkFavorites.Checked)
         {
             sql = "select to_number(value), substr(name, length('PROGSET') + 2) as description from opera.lz_sitevars where name like 'PROGSET %' and exists (select * from tb_programsettings where id = to_number(value) and driverlevel = 2 and instr(upper(executable), 'TOTALSCAN') > 0) order by value";
         }
         else
         {
             sql = "select id, description from tb_programsettings where driverlevel = 2 and instr(upper(executable), 'TOTALSCAN') > 0 order by id";
         }
         rd2 = new SySal.OperaDb.OperaDbCommand(sql, conn).ExecuteReader();
         while (rd2.Read())
         {
             ListViewItem lvi = new ListViewItem(rd2.GetInt64(0).ToString());
             lvi.Tag = rd2.GetInt64(0);
             lvi.SubItems.Add(rd2.GetString(1));
             lvProgramSettings.Items.Add(lvi);
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.ToString(), "Error Accessing DB", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         if (rd2 != null)
         {
             rd2.Close();
         }
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: kryssb/SySal.NET
        static void Main(string[] args)
        {
            if (args.Length != 7)
            {
                Console.WriteLine("usage: CSRelatedGraphSelector.exe <tlg file> <ascii file> <brick> <plate> <mingrains> <postol> <slopetol>");
                Console.WriteLine("output: BRICK PLATE GRAINS PX PY PZ SX SY SIGMA DPX DPY DSX DSY");
                return;
            }
            int brickid = Convert.ToInt32(args[2]);

            if (brickid > 1999999)
            {
                Console.WriteLine("No track to select on a CS.");
                System.IO.File.WriteAllText(args[1], "\r\n");
                return;
            }
            SySal.OperaDb.OperaDbConnection conn = SySal.OperaDb.OperaDbCredentials.CreateFromRecord().Connect();
            conn.Open();
            int csid = brickid;

            try
            {
                csid = SySal.OperaDb.Convert.ToInt32(new SySal.OperaDb.OperaDbCommand("SELECT MAX(ID) FROM TB_EVENTBRICKS WHERE MOD(ID,1000000) = " + (brickid - (brickid / 1000000) * 1000000), conn).ExecuteScalar());
            }
            catch (Exception) { }
            SySal.OperaDb.OperaDbDataReader csr = new SySal.OperaDb.OperaDbCommand("SELECT (ID_PLATE - 1) * 300 + 4850 as Z, POSX, POSY, SLOPEX, SLOPEY FROM VW_LOCAL_CS_CANDIDATES WHERE ID_CS_EVENTBRICK = " + csid, conn).ExecuteReader();
            System.Collections.ArrayList    arr = new System.Collections.ArrayList();
            while (csr.Read())
            {
                SySal.Tracking.MIPEmulsionTrackInfo info = new SySal.Tracking.MIPEmulsionTrackInfo();
                info.Intercept.Z = csr.GetDouble(0);
                info.Intercept.X = csr.GetDouble(1);
                info.Intercept.Y = csr.GetDouble(2);
                info.Slope.X     = csr.GetDouble(3);
                info.Slope.Y     = csr.GetDouble(4);
                arr.Add(info);
            }
            csr.Close();
            double Z = SySal.OperaDb.Convert.ToDouble(new SySal.OperaDb.OperaDbCommand("SELECT Z FROM TB_PLATES WHERE ID_EVENTBRICK = " + brickid + " AND ID = " + Convert.ToInt32(args[3]).ToString(), conn).ExecuteScalar());

            conn.Close();
            SySal.DataStreams.OPERALinkedZone lz = new SySal.DataStreams.OPERALinkedZone(args[0]);
            int    basen = lz.Length;
            int    i;
            int    mingrains = Convert.ToInt32(args[4]);
            double postol    = Convert.ToDouble(args[5]);
            double slopetol  = Convert.ToDouble(args[6]);
            string outstr    = "";
            int    sel       = 0;

            for (i = 0; i < basen; i++)
            {
                SySal.Tracking.MIPEmulsionTrackInfo lzinfo = lz[i].Info;
                if (lzinfo.Count < mingrains)
                {
                    continue;
                }
                foreach (SySal.Tracking.MIPEmulsionTrackInfo csinfo in arr)
                {
                    double dz         = Math.Abs(csinfo.Intercept.Z - Z);
                    double slopescatt = 0.014 * Math.Sqrt(dz / (1.3 * 5600.0)); /* assume 1 GeV */
                    double posscatt   = slopescatt * dz / Math.Sqrt(3.0);
                    double dsx        = csinfo.Slope.X - lzinfo.Slope.X;
                    double dsy        = csinfo.Slope.Y - lzinfo.Slope.Y;
                    if (dsx * dsx + dsy * dsy > (2.0 * (slopescatt * slopescatt + slopetol * slopetol)))
                    {
                        continue;
                    }
                    double dpx = csinfo.Intercept.X + (Z - csinfo.Intercept.Z) * (csinfo.Slope.X + lzinfo.Slope.X) * 0.5 - lzinfo.Intercept.X;
                    double dpy = csinfo.Intercept.Y + (Z - csinfo.Intercept.Z) * (csinfo.Slope.Y + lzinfo.Slope.Y) * 0.5 - lzinfo.Intercept.Y;
                    if (dpx * dpx + dpy * dpy > (2.0 * (posscatt * posscatt + postol * postol)))
                    {
                        continue;
                    }
                    outstr += "\r\n" + brickid + " " + args[3] + " " + lzinfo.Count + " " + lzinfo.Intercept.X + " " + lzinfo.Intercept.Y + " " + Z + " " + lzinfo.Slope.X + " " + lzinfo.Slope.Y + " " + lzinfo.Sigma + " " + dpx + " " + dpy + " " + dsx + " " + dsy;
                    sel++;
                    break;
                }
            }
            Console.WriteLine("Selected: " + sel + " track(s)");
            System.IO.File.WriteAllText(args[1], outstr);
        }
コード例 #3
0
 private void OnLoad(object sender, EventArgs e)
 {
     SySal.OperaDb.OperaDbConnection conn = null;
     SySal.OperaDb.OperaDbDataReader rd1  = null;
     SySal.OperaDb.OperaDbDataReader rd3  = null;
     SySal.OperaDb.OperaDbDataReader rd4  = null;
     try
     {
         conn = SySal.OperaDb.OperaDbCredentials.CreateFromRecord().Connect();
         conn.Open();
         rd1 = new SySal.OperaDb.OperaDbCommand("select id, name from tb_machines where id_site = (select value from opera.lz_sitevars where name = 'ID_SITE') and isscanningserver > 0 order by name", conn).ExecuteReader();
         while (rd1.Read())
         {
             ListViewItem lvi = new ListViewItem(rd1.GetInt64(0).ToString());
             lvi.Tag = rd1.GetString(1) /*rd1.GetInt64(0)*/;
             lvi.SubItems.Add(rd1.GetString(1));
             lvMachines.Items.Add(lvi);
         }
         rd1.Close();
         rd3 = new SySal.OperaDb.OperaDbCommand("select value from opera.lz_sitevars where name = 'BM_AutoStartFile'", conn).ExecuteReader();
         if (rd3.Read())
         {
             m_AutoStartPath = rd3.GetString(0);
         }
         else
         {
             MessageBox.Show("AutoStart file path not set in LZ_SITEVARS.\r\nCannot continue.", "Infrastructure Setup Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Close();
             return;
         }
         System.Collections.ArrayList pa = new System.Collections.ArrayList();
         rd4 = new SySal.OperaDb.OperaDbCommand("select id, z from tb_plates where id_eventbrick = " + BrickId + " order by z desc", conn).ExecuteReader();
         while (rd4.Read())
         {
             pa.Add(new PlateRecord(rd4.GetInt32(0), rd4.GetDouble(1)));
         }
         if (pa.Count == 0)
         {
             throw new Exception("No plates registered in your DB for this brick.\r\nPlease check and retry.");
         }
         Plates = (PlateRecord[])pa.ToArray(typeof(PlateRecord));
         int i;
         for (i = 0; i < Plates.Length && Plates[i].Id != VolStart.Plate; i++)
         {
             ;
         }
         cmbPlates.Items.Add(i + "/0");
         cmbPlates.Items.Add("0/" + (Plates.Length - 1 - i));
         cmbSkew.Items.Add(VolStart.Slope.X.ToString("F4", System.Globalization.CultureInfo.InvariantCulture) + "/" + VolStart.Slope.Y.ToString("F4", System.Globalization.CultureInfo.InvariantCulture));
         rd4.Close();
         cmbNotes.Items.Add("TotalScan on brick " + BrickId);
         cmbNotes.Items.Add("TotalScan on brick " + BrickId + " around vertex point");
         cmbNotes.Items.Add("TotalScan on brick " + BrickId + " around stopping point");
         cmbNotes.SelectedIndex = VolumeStartsFromTrack ? 2 : 1;
         RefreshProgramSettings(conn);
         cmbWidthHeight.SelectedIndex = 0;
         cmbPlates.SelectedIndex      = 0;
         cmbSkew.SelectedIndex        = 0;
         OnWidthHeightLeave(this, null);
         OnPlatesLeave(this, null);
         OnSkewLeave(this, null);
     }
     catch (Exception x)
     {
         MessageBox.Show(x.ToString(), "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
     }
     finally
     {
         if (rd1 != null)
         {
             rd1.Close();
         }
         if (rd3 != null)
         {
             rd3.Close();
         }
         if (rd4 != null)
         {
             rd3.Close();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
 }