public MainView() { InitializeComponent(); if (!mvvmContext1.IsDesignMode) { InitializeBindings(); } //读取系统参数 SysPara = OperatePara.LoadPara("Para.cfg"); DB_Operate = new DB_Operate(SysPara.UserDB, SysPara.UserTB, SysPara.UserPath); //指定用户数据库和表 DB_Work = new DB_Operate(SysPara.WorkDB, SysPara.WorkTB, SysPara.WorkPath); //指定工作数据库和表 //页面跳转 getUserList(); if (!getAuthority()) { this.TabControl.SelectedPage = this.TabControl.Pages[0];//跳转到登录页面 } FirstSign = true; //创建页面 if (TabControl.SelectedPage.Text == "用户") { //刷新列表 getUserList(); User_List.SelectedIndex = 0; } //DB_Work.DB_Table.RowChanged += new DataRowChangeEventHandler(refreshDB); //配置连接参数 ReadPLCValue = new ReadValue(SysPara.PlcIp, SysPara.PlcPort, SysPara.PlcSA1, SysPara.PlcDA1, SysPara.PlcDA2); plcStatus(); //配置流程参数 WorkProcess.equal1ClearEvent += new ValueChange.Change_Event(workProcessClear); //清空参数 WorkProcess.equal1Event += new ValueChange.Change_Event(workProcessGoing); //==1触发读取流程参数 //配置Log参数 Log = new LogNetDateTime("./Log", GenerateMode.ByEveryHour); //配置扫码枪参数 CodeDevice = new RS232(); CodeDevice.Receive_Event += new Receive_Delegate(CodeResolve); //刷新串口列表 Com_List.Items.AddRange(CodeDevice.PortName.ToArray()); Com_List.SelectedIndex = SysPara.PortNo; //连接扫码枪 OpenCodeDevice(); //判断OK/NG judgeEnable.Checked = SysPara.Judge; JudgeDisable.Checked = !SysPara.Judge; //User管理 userListEdit.DataSource = DB_Operate.DB_Table; //主页的信息显示 InitialData(); }
/// <summary> /// 13点模式 /// </summary> /// <param name="data"></param> /// <param name="listName"></param> /// <returns></returns> public PlaneData Mode13Point(ReadValue data, string[] listName) { PlaneData Result = new PlaneData(); //生成该平面坐标点集合 for (int i = 0; i < listName.Length; i++) { Result.PlanePointList.Add((Vector3D)data.GetType().GetField(listName[i]).GetValue(data)); } Result.Plane = Algorithm.getPlanePara(Result.PlanePointList.ToArray());//平面参数计算 double x = (Result.PlanePointList.Max(o => o.X) + Result.PlanePointList.Min(o => o.X)) / 2; double y = (Result.PlanePointList.Max(o => o.Y) + Result.PlanePointList.Min(o => o.Y)) / 2; double z = Result.Plane.Kx * x + Result.Plane.Ky * y + Result.Plane.B; Result.PlaneCriterionPoint = new Vector3D(x, y, z); Result.PlaneLastPoint = Result.PlanePointList[Result.PlanePointList.Count - 1];//计算最后点位 double delta = Algorithm.getDotToPlaneDistance(Result.PlaneCriterionPoint, Result.Plane); return(Result); }