Ejemplo n.º 1
1
        static StationDisplay()
        {
            var db       = DbScheme.GetConnection("Main");
            int ccdCount = CcdCount;

            Panels         = new Panel[ccdCount];
            DisplayWindows = new CogRecordDisplay[ccdCount];
            var tp     = MyTabs["Display", 0];
            int width  = tp.Width / 2;
            int height = tp.Height;

            for (int i = 0; i < ccdCount; i++)
            {
                Panels[i]         = new Panel();
                DisplayWindows[i] = new CogRecordDisplay();

                Panels[i]              = new Panel();
                DisplayWindows[i]      = new CogRecordDisplay();
                DisplayWindows[i].Dock = DockStyle.Fill;
                DisplayWindows[i].Tag  = false;
                Panels[i].Controls.Add(DisplayWindows[i]);
                tp.Controls.Add(Panels[i]);
            }

            Panels[0].Location = new Point(0, 0);
            Panels[0].Size     = new Size(width, height);

            Panels[1].Location = new Point(width, 0);
            Panels[1].Size     = new Size(width, height);

            for (int i = 0; i < CcdCount; i++)
            {
                Panels[i].Tag = i;
            }

            Stations = new Dictionary <int, StationDisplay>();
            for (int i = 0; i < ccdCount; i++)
            {
                Stations[i] = new StationDisplay(i);
                Stations[i].SetDoubleClick();

                Label myLabel = new Label();
                myLabel.Text      = string.Format("画面{0}", i + 1);
                myLabel.Location  = new Point(20, 20);
                myLabel.ForeColor = Color.Yellow;
                Stations[i][i].Controls.Add(myLabel);
            }
        }
Ejemplo n.º 2
0
        public static Dictionary <string, string> FindVpps(int ccdId, int brandId)
        {
            var db       = DbScheme.GetConnection("Main");
            var vppFiles = new Dictionary <string, string>();

            string brand = db.ExecuteScalar <string>("select brand from CcdBrand where brandId = ?", brandId);

            CcdVpp myCcdVpp = db.Query <CcdVpp>("select * from CcdVpp where ccdId = ?", ccdId).First();
            var    home     = new DirectoryInfo(Path.Combine(myCcdVpp.VppHome, brand));
            var    files    = home.GetFiles("*.vpp");

            string pattern = string.Format("_(?<ccdName>{0})(.*?)(?<partId>{1})$", myCcdVpp.NamePattern, myCcdVpp.PartPattern);

            Regex patternVpp = new Regex(pattern);

            foreach (var file in files)
            {
                string name = Path.GetFileNameWithoutExtension(file.FullName);
                if (patternVpp.IsMatch(name))
                {
                    var match  = patternVpp.Match(name);
                    var groups = match.Groups;
                    vppFiles[groups["partId"].Value] = file.FullName;
                }
            }

            return(vppFiles);
        }
Ejemplo n.º 3
0
        public CcdCycle GetInfo()
        {
            var db    = DbScheme.GetConnection("Data");
            var query = db.Query <CcdCycle>("select * from CcdCycle where id = ?", Index);

            return(query.First());
        }
Ejemplo n.º 4
0
        public StationToolBlock(int ccdId)
        {
            CcdId             = ccdId;
            OfflineImageCycle = 1;
            var db      = DbScheme.GetConnection("Data");
            int brandId = db.ExecuteScalar <int>("select data from RunStatus where name = ?", "BrandId");

            BrandId     = brandId;
            VppFileName = Helper.VppHelper.FindVpps(CcdId, brandId)[""];
            LoadVpp();
            VtInBlock = new ActionBlock <CcdTerminalIn>(x => x.RunToolBlock(MyCogToolBlock));

            if (!RunParams.CcdGrabBlock.ContainsKey(CcdId))
            {
                RunParams.CcdGrabBlock[CcdId] = new ActionBlock <int>(x => OnGrabImage(x));
            }

            if (!RunParams.CcdOfflineBlock.ContainsKey(CcdId))
            {
                RunParams.CcdOfflineBlock[CcdId] = new ActionBlock <int>(x => RunOffline(x));
            }

            if (!RunParams.CcdCheckBlock.ContainsKey(CcdId))
            {
                RunParams.CcdCheckBlock[CcdId] = new ActionBlock <int>(x => CheckResult(x));
            }

            if (!RunParams.CcdDisplayBlock.ContainsKey(CcdId))
            {
                RunParams.CcdDisplayBlock[CcdId] = new ActionBlock <int>(x => DisplayShow(x));
            }
        }
Ejemplo n.º 5
0
        public ZoneInfo(int ccdId, int brandId)
        {
            BrandId = brandId;
            CcdId   = ccdId;

            var db = DbScheme.GetConnection("Data");

            Index = db.ExecuteScalar <int>("select id from CcdCycle where brandId = ? and ccdId = ?", BrandId, CcdId);
        }
Ejemplo n.º 6
0
        static StructureHelper()
        {
            var arr              = ConfigurationManager.AppSettings["db"].Split('|');
            var dbType           = arr[0];
            var connectionString = arr[1];

            if (dbType == "mysql")
            {
                scheme = new MySqlScheme(connectionString);
            }

            var eventType = typeof(BaseEvent);

            _events = Assembly.GetExecutingAssembly().GetTypes().Where(x => !x.IsAbstract && x.IsClass && x.IsSubclassOf(eventType)).Select(x => Activator.CreateInstance(x) as BaseEvent).ToList();
        }
Ejemplo n.º 7
0
        private void DisplayStation_DoubleClick(object sender, EventArgs e)
        {
            CogRecordDisplay display = sender as CogRecordDisplay;
            Panel            panel   = display.Parent as Panel;
            int  displayIndex        = (int)panel.Tag;
            bool status = (bool)display.Tag;

            int ccdCount = DbScheme.GetUiParams("CcdCount");

            if (!status)
            {
                panel.Location = new Point(0, 0);
                panel.Size     = new Size(Tp.Width, Tp.Height);
                for (int i = 0; i < ccdCount; i++)
                {
                    if (i != displayIndex)
                    {
                        Panels[i].Hide();
                    }
                    else
                    {
                        Panels[i].Show();
                    }
                }
                display.Tag = true;
            }
            else
            {
                var tp     = MyTabs["Display", 0];
                int width  = tp.Width / 2;
                int height = tp.Height;
                Panels[0].Location = new Point(0, 0);
                Panels[0].Size     = new Size(width, height);
                Panels[1].Location = new Point(width, 0);
                Panels[1].Size     = new Size(width, height);

                for (int i = 0; i < CcdCount; i++)
                {
                    Panels[i].Show();
                }

                display.Tag = false;
            }
        }
Ejemplo n.º 8
0
        private void OnGrabImage(int x)
        {
            var grabBlobk  = RunParams.CcdGrabBlock[CcdId];
            int imageIndex = x;

            UiMainForm.LogMessage(string.Format("Ccd{0}开始拍照", CcdId));

            var vIo = VirtualIo.GetDevice(CcdId);

            if (imageIndex == 0)
            {
                for (int i = 1; i < 3; i++)
                {
                    vIo.ResetPort(i);
                }
            }
            double        exposure = DbScheme.GetCcdParams(CcdId, BrandId, x, "Exposure");
            CcdTerminalIn vtIn     = GrabImage(imageIndex, exposure);

            VtInBlock.Post(vtIn);
        }
Ejemplo n.º 9
0
        static UiMainForm()
        {
            DbScheme.Create();
            var db = DbScheme.Connections["Main"];

            int ccdCount   = db.ExecuteScalar <int>("select data from UiParams where name = ?", "CcdCount");
            int brandCount = db.ExecuteScalar <int>("select data from UiParams where name = ?", "BrandCount");

            ScreenWidth  = db.ExecuteScalar <int>("select data from UiParams where name = ?", "ScreenWidth");
            ScreenHeight = db.ExecuteScalar <int>("select data from UiParams where name = ?", "ScreenHeight");

            int[] partCounts = new int[ccdCount];

            for (int i = 0; i < ccdCount; i++)
            {
                partCounts[i] = db.ExecuteScalar <int>("select data from UiParams where name = ?", string.Format("PartCountCcd{0}", i + 1));
            }

            Project       = new ProjectCcd(ccdCount, brandCount, partCounts);
            Panels        = new Dictionary <string, Panel>();
            WorkAreaPanel = new Panel();
        }
Ejemplo n.º 10
0
        public UiZoneInfo(ProjectCcd project, Panel panel)
        {
            Project        = project;
            MainPanel      = panel.Controls.OfType <Panel>().First();
            MainPanel.Dock = DockStyle.Fill;

            int zoneCount = Project.CcdCount;

            Zones        = new GroupBox[zoneCount];
            Infos        = new ZoneInfo[zoneCount];
            ZoneBlocks   = new ActionBlock <CcdCycle> [zoneCount];
            StatusBlocks = new ActionBlock <bool> [zoneCount];
            int width  = panel.Width;
            int height = panel.Height;

            int height0 = height / zoneCount;
            int width0  = width;

            var    db   = DbScheme.GetConnection("Main");
            string text = string.Empty;

            for (int i = 0; i < zoneCount; i++)
            {
                Zones[i]        = new GroupBox();
                Zones[i].Width  = width0;
                Zones[i].Height = height0 - 5;
                Zones[i].Left   = 0;
                Zones[i].Top    = height0 * i;
                text            = db.ExecuteScalar <string>("select nameCn from CcdInfo where ccdId = ?", i);
                Zones[i].Text   = text; // string.Format("CCD{0}", i + 1);
                MainPanel.Controls.Add(Zones[i]);
                Infos[i] = new ZoneInfo(i, Project.BrandId);
            }

            for (int i = 0; i < zoneCount; i++)
            {
                AddZoneUi(i);
            }
        }
        static StationToolBlockEdit()
        {
            var db       = DbScheme.GetConnection("Main");
            int ccdCount = db.ExecuteScalar <int>("select data from UiParams where name = ?", "CcdCount");

            Panels      = new Dictionary <string, Panel> [ccdCount];
            EditWindows = new CogToolBlockEditV2[ccdCount];

            for (int i = 0; i < ccdCount; i++)
            {
                Panels[i]      = new Dictionary <string, Panel>();
                EditWindows[i] = new CogToolBlockEditV2();
                var tp = MyTabs["Vpp", i];
                Panels[i]["Main"]   = new Panel();
                EditWindows[i]      = new CogToolBlockEditV2();
                EditWindows[i].Dock = DockStyle.Fill;
                Panels[i]["Main"].Controls.Add(EditWindows[i]);

                tp.Controls.Add(Panels[i]["Main"]);
                int width = tp.Width;
                Panels[i]["Main"].Location = new Point(0, 0);
                Panels[i]["Main"].Size     = new Size(width, tp.Height - 60);
                Panels[i]["Main"].Tag      = "Main";

                Panels[i]["Aux"] = new Panel();
                tp.Controls.Add(Panels[i]["Aux"]);
                Panels[i]["Aux"].Location = new Point(0, Panels[i]["Main"].Bottom);
                Panels[i]["Aux"].Size     = new Size(width, 60);
                Panels[i]["Aux"].Tag      = "Aux";
            }

            Stations = new Dictionary <int, StationToolBlockEdit>();
            for (int i = 0; i < ccdCount; i++)
            {
                Stations[i] = new StationToolBlockEdit(i);
            }
        }
Ejemplo n.º 12
0
        public int UpdateInfo(CcdCycle ccdCycle)
        {
            var db = DbScheme.GetConnection("Data");

            return(db.Update(ccdCycle));
        }