Exemplo n.º 1
0
 IProvider IProviderFactory.Create(string providerName)
 {
     if (providerName.ToLower() == "googleprovider")
     {
         return((IProvider)_dependencyResolver.GetService(typeof(GoogleProvider)));
     }
     if (providerName.ToLower() == "yahooprovider")
     {
         return((IProvider)_dependencyResolver.GetService(typeof(YahooProvider)));
     }
     return(null);
 }
        public void GetService_returns_null_when_type_not_registered()
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            var result = resolver.GetService(typeof (IDateTime));
            Assert.IsNull(result);
        }
        public void InitializeTest()
        {
            var     dependencyResolver = new NinjectDependencyResolver(new string[] { "Infrastructure.Tests" });
            ILogger logger             = null;

            logger = dependencyResolver.GetService <ILogger>(LoggerType.File.ToString());

            Assert.IsInstanceOf <FileLogger>(logger);
        }
        public void GetService_returns_instance_when_registered()
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);
            kernel.Bind<IDateTime>().To<DateTimeAdapter>();

            var result = resolver.GetService(typeof(IDateTime));
            Assert.That(result, Is.TypeOf<DateTimeAdapter>());
        }
Exemplo n.º 5
0
        public void GetService_returns_null_when_type_not_registered()
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            var result = resolver.GetService(typeof(IDateTime));

            Assert.IsNull(result);
        }
Exemplo n.º 6
0
        public NCcodeList ImportFromFileTest()
        {
            string testpath = System.Environment.CurrentDirectory + @"\TestFiles\WRONG_NC";
            NinjectDependencyResolver dd = new NinjectDependencyResolver();

            NCcodeList ncls = new NCcodeList((IDBInfo)dd.GetService(typeof(IDBInfo)));

            ncls.ImportFromFile(testpath);
            Assert.AreNotEqual(ncls.NCList.Count(), 0);
            return(ncls);
        }
Exemplo n.º 7
0
        public void GetService_returns_instance_when_registered()
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            kernel.Bind <IDateTime>().To <DateTimeAdapter>();

            var result = resolver.GetService(typeof(IDateTime));

            Assert.That(result, Is.TypeOf <DateTimeAdapter>());
        }
Exemplo n.º 8
0
        private IUserService CreateUserService()
        {
            var serviceBag = (IServiceBag)resolver.GetService(typeof(IServiceBag));

            return(serviceBag.UserService);
        }
Exemplo n.º 9
0
 public void GetService_BindingDefined_ShouldReturnDefined()
 {
     Assert.IsInstanceOf <Class1>(_resolver.GetService(typeof(Intf1)));
 }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            //pointCoord test = new pointCoord("X;500");


            string outputfolder = Program.InfoPath + productList1.listBox1.SelectedItem.ToString() + "\\NC\\COUPON\\";

            localMethod.creatDir(outputfolder);



            foreach (var cc in controlList.Values)
            {
                List <string> sb = new List <string>();

                if (cc[1].ForeColor == Color.ForestGreen)
                {
                    //获取试片文本
                    string coupontext = cc[0].Text;
                    var    cptmp      = coupontext.Split('/');


                    //获取试片编号
                    var cpmarkls = from dd in coupondt.AsEnumerable()
                                   where dd["试片1"].ToString() == "C1-" + cptmp[0] && dd["试片2"].ToString() == "C1-" + cptmp[1]
                                   select new {
                        cpno     = dd["组合编号"].ToString(),
                        progUUID = dd["程序段编号"].ToString(),
                        progID   = dd["ID"].ToString()
                    };
                    string cpmark;
                    if (cpmarkls.Count() > 0)
                    {
                        cpmark = cpmarkls.First().cpno;
                    }
                    else
                    {
                        cpmark = "NEW";
                    }



                    //选择“对号” 的tag
                    string           mark        = cc[1].Tag.ToString();
                    string           folderpath  = Program.InfoPath + "SAMPLE\\COUPON\\TAB\\" + mark + "\\";
                    pointCoordList   ptls        = new pointCoordList();
                    pointCoordList[] couponModel = new pointCoordList[3] {
                        new pointCoordList(folderpath + mark + "_upper.tab"),
                        new pointCoordList(folderpath + mark + "_lower.tab"),
                        new pointCoordList(folderpath + mark + "_middle.tab")
                    };
                    //判断一共有几种紧固件c[2]-c[4]

                    var fstcontrol = cc.Skip(2);
                    var fstlist    = from ff in fstcontrol
                                     where ff.Text != ""
                                     select ff.Text;


                    foreach (string fstname in fstlist)
                    {
                        string fstnamemark = fstname;
                        //判断加工代码
                        string Mcode;
                        if (fstname.Contains("B020600"))
                        {
                            Mcode = "M62";

                            fstnamemark = fstname.Split('-')[0];
                        }
                        else
                        {
                            Mcode = "M60";
                        }
                        //Read the enter/out NC codes
                        string progfolder = Program.InfoPath + @"SAMPLE\COUPON\TAB\ENTER\";
                        Func <string, NCcodeList> openNCfile = delegate(string name)
                        {
                            //Type dd = typeof(NCcodeList);
                            //NCcodeList obj = (NCcodeList)dd.Assembly.CreateInstance(dd.FullName);
                            NinjectDependencyResolver dd = new NinjectDependencyResolver();
                            NCcodeList obj = new NCcodeList((IDBInfo)dd.GetService(typeof(IDBInfo)));
                            obj.ImportFromFile(progfolder + name);
                            obj.NCList.RemoveRange(0, 2);
                            obj.NCList.RemoveRange(obj.NCList.Count - 2, 2);
                            return(obj);
                        };
                        string        beginProg;
                        string        enterProg;
                        string        outProg;
                        string        endProg;
                        List <string> beginNC;
                        List <string> enterNC;
                        List <string> outNC;
                        List <string> endNC;
                        if (mark.Contains("left"))
                        {
                            beginProg = "M98 P3601";
                            beginNC   = openNCfile("BEGIN_LEFT").NCList;
                            enterProg = "M98 P3602";
                            enterNC   = openNCfile("ENTER_LEFT").NCList;
                            outProg   = "M98 P3603";
                            outNC     = openNCfile("OUT_LEFT").NCList;
                            endProg   = "M98 P3604";
                            endNC     = openNCfile("END_LEFT").NCList;
                        }
                        else
                        {
                            beginProg = "M98 P3701";
                            beginNC   = openNCfile("BEGIN_RIGHT").NCList;
                            enterProg = "M98 P3702";
                            enterNC   = openNCfile("ENTER_RIGHT").NCList;
                            outProg   = "M98 P3703";
                            outNC     = openNCfile("OUT_RIGHT").NCList;
                            endProg   = "M98 P3704";
                            endNC     = openNCfile("END_RIGHT").NCList;
                        }



                        string progID;

                        var cpmarkls2 = cpmarkls.Where(x => x.progUUID.Contains(fstnamemark));
                        if (cpmarkls2.Count() > 0)
                        {
                            progID = cpmarkls2.First().progID;
                        }
                        else
                        {
                            progID = "NEW";
                        }
                        // sb.Add("%");
                        string Ocode = "O" + productList1.listBox1.SelectedItem.ToString().Split('_')[1].Substring(3, 4) + progID.PadLeft(2, '0') + cpmark.Substring(1).PadLeft(2, '0');


                        string filename = progID + "_" + cpmark + "_" + fstname + "_" + cptmp[0] + "_" + cptmp[1] + "_" + mark.ToUpper();

                        sb.Add("(MSG, START COUPON TEST:" + filename + ")");

                        ////下铆头降到最低
                        //sb.Add("M53");
                        ////所有传感器关闭
                        //sb.Add("M51");
                        //// 取消传感器补偿清除传感器在点位模式下创建的坐标补偿
                        //sb.Add("M26");
                        ////取消视觉修正补偿清除视觉修正导致的XY坐标补偿
                        //sb.Add("M35");
                        //进入程序代码
                        //校准工装用的代码
                        sb.Add("(MSG, IF YOU ARE AT INSPECTION LOCATION THEN IGNORE NEXT STATEMENT)");
                        sb.Add("(MSG, BEGIN ENTER)");
                        sb.AddRange(beginNC);

                        sb.AddRange(enterNC);

                        sb.Add("(MSG, END ENTER)");
                        //获取换刀用的T代码
                        sb.Add("M56" + fstenerT[fstname]);


                        //更换钻头工位
                        sb.Add("M83T0");

                        //更换上铆头工位
                        sb.Add("M83T100");

                        //准备注胶循环
                        sb.Add("M83T100");

                        //试片上升
                        sb.Add(couponModel[0][0].Offset("Z;40;W;40;").ToString());


                        //处理Upper 及Lower位置
                        //取得第一个点并校准
                        sb.Add("M34T1");
                        sb.Add(couponModel[0][0].ToString());
                        sb.Add("M51");
                        sb.Add("M50T00");
                        sb.Add("M39");
                        sb.Add("M31");

                        //下铆头上升
                        sb.Add("M57T300");

                        //校准通过(该位置无紧固件)则进行铆接
                        sb.Add(Mcode);

                        for (int i = 1; i < 21; i++)
                        {
                            sb.Add("M34T1");
                            sb.Add(couponModel[0][i].ToString());
                            sb.Add("M39");
                            sb.Add("M31");
                            sb.Add(Mcode);
                        }
                        //下铆头下降
                        sb.Add("M57T4000");

                        //试片下降
                        sb.Add("(MSG, COUPON FIXTURE WILL GO UP AND MOVE TO NEXT LINE TO INSTALL FASTERNERS)");
                        sb.Add(couponModel[0][20].Offset("Z;40;W;40;").ToString());

                        //进行lower铆接
                        //添加走回工装校准点校准的脚本
                        //板子上升
                        sb.Add(couponModel[1][0].Offset("Z;40;W;40;").ToString());

                        //取得第一个点并校准
                        sb.Add("M34T1");
                        sb.Add(couponModel[1][0].ToString());
                        sb.Add("M51");
                        sb.Add("M50T00");
                        sb.Add("M39");
                        sb.Add("M31");


                        //下铆头上升
                        sb.Add("M57T300");

                        //校准通过(该位置无紧固件)则进行铆接
                        sb.Add(Mcode);
                        for (int i = 1; i < 21; i++)
                        {
                            sb.Add("M34T1");
                            sb.Add(couponModel[1][i].ToString());
                            sb.Add("M39");
                            sb.Add("M31");
                            sb.Add(Mcode);
                        }


                        sb.Add("(MSG, START DRILL HOLES ON COUPONS)");
                        //开始钻孔操作
                        Mcode = "M61";



                        //下铆头下降
                        sb.Add("M57T4000");
                        //试片下降
                        sb.Add("(MSG, COUPON FIXTURE WILL GO UP AND MOVE TO NEXT LINE TO INSTALL FASTERNERS)");
                        sb.Add(couponModel[1][20].Offset("Z;40;W;40;").ToString());
                        sb.Add(couponModel[2][0].Offset("Z;40;W;40;").ToString());
                        //取得第一个点并校准
                        sb.Add("M34T1");
                        sb.Add(couponModel[2][0].ToString());
                        sb.Add("M51");
                        sb.Add("M50T00");
                        sb.Add("M39");
                        sb.Add("M31");


                        //下铆头上升
                        sb.Add("M57T300");

                        //校准通过(该位置无紧固件)则进行加工
                        sb.Add(Mcode);
                        for (int i = 1; i < 21; i++)
                        {
                            sb.Add("M34T1");
                            sb.Add(couponModel[2][i].ToString());
                            sb.Add("M39");
                            sb.Add("M31");
                            sb.Add(Mcode);
                        }
                        //下铆头下降
                        sb.Add("M57T4000");

                        //试片降低
                        sb.Add(couponModel[2][20].Offset("Z;40;W;40;").ToString());
                        sb.Add("(MSG, END COUPON TEST:" + filename + ")");
                        sb.Add("(MSG, NOW OUT THE FIXTURE)");
                        sb.AddRange(outNC);
                        sb.Add("(MSG, IF YOU WANT TO CONTINUE COUPON TEST THEN SKIP NEXT STATEMENT)");

                        sb.AddRange(endNC);
                        //     sb.Add("%");



                        //输出文件至目录
                        int m        = 0;
                        var outputNC = sb.ConvertAll(x => "N" + ((++m) * 2).ToString() + " " + x);
                        outputNC.Insert(0, "%");
                        outputNC.Insert(1, Ocode);
                        outputNC.Insert(outputNC.Count - 1, "%");
                        outputNC.WriteFile(outputfolder + filename);
                    }
                }
            }
            //复制进出程序至输出目录
            List <FileInfo> en = new List <FileInfo>();

            en.WalkTree(Program.InfoPath + @"SAMPLE\COUPON\TAB\ENTER\", false);
            en.copyto(outputfolder);


            System.Diagnostics.Process.Start("explorer.exe", outputfolder);
        }