void Awake() { if (instance != null && instance != this) { Destroy (gameObject); } instance = this; DontDestroyOnLoad (gameObject); }
private void Go_Click(object sender, System.EventArgs e) { // + GrablinkSnapshotTrigger Sample Program // Start an acquisition sequence by activating the channel String channelState; MC.GetParam(channel, "ChannelState", out channelState); if (channelState != "ACTIVE") { MC.SetParam(channel, "ChannelState", "ACTIVE"); } // Generate a soft trigger event MC.SetParam(channel, "ForceTrig", "TRIG"); Refresh(); // - GrablinkSnapshotTrigger Sample Program }
public void onCreate(string regNum, DateTime parkedDateTime, string type = "", int size = 0) { Singelton singleton = Singelton.Instance; if (type.ToLower().Equals("car")) { Vehicle car = new Car(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = car; } else if (type.ToLower().Equals("mc")) { Vehicle mc = new MC(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = mc; } else if (!type.ToLower().Equals("mc") && !type.ToLower().Equals("car")) { Vehicle custom = new CustomVehicle(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = custom; } }
public static void Main() { vector a = new vector(0.0, 0.0, 0.0); vector b = new vector(2.0, 2.0, 2.0); int exact = 16; WriteLine("N error Abs(estim-exact) 1/sqrt(N)"); Func <vector, double> g = (x) => { return(x[0] * x[0] * x[0] * x[1] * x[2]); }; int N1 = 5000; vector resg1 = MC.plainmc(g, a, b, N1); double scale = resg1[1] * Sqrt(N1); for (int N = 10000; N < 1000000; N = N + 5000) { vector resg = MC.plainmc(g, a, b, N); WriteLine($"{N} {resg[1]} {Abs(resg[0]-exact)} {scale/Sqrt(N)}"); } //WriteLine($"Lower bound (0,0,0), upper bound (3.14, 3.14, 3.14)"); }
private void multiCamProcessingCallback(ref MC.SIGNALINFO signalInfo) { if (signalInfo.Signal == MC.SIG_SURFACE_PROCESSING) { int width; int height; IntPtr bufferAddress; uint currentChannel = signalInfo.Instance; uint currentSurface = signalInfo.SignalInfo; IplImage output; unsafe { MC.GetParam(currentChannel, "ImageSizeX", out width); MC.GetParam(currentChannel, "ImageSizeY", out height); MC.GetParam(currentSurface, "SurfaceAddr:0", out bufferAddress); output = new IplImage(new Size(width, height), IplDepth.U8, 1, bufferAddress).Clone(); } global_observer.OnNext(output); } }
public static void Main() { vector a = new vector(0.0, 0.0, 0.0); vector b = new vector(PI, PI, PI); int N = 50000;//evaluations Func <vector, double> g = (x) => { return(x[0] * x[0] * x[1] * x[2]); }; Func <vector, double> f = (x) => { return(1 / (1 - Cos(x[0]) * Cos(x[1]) * Cos(x[2])) / PI / PI / PI); }; vector resf = MC.plainmc(f, a, b, N); vector resg = MC.plainmc(g, a, b, N); WriteLine("Two integrals calculated via Monte Carlo Integration"); WriteLine($"Lower bound (0,0,0), upper bound (3.14, 3.14, 3.14)"); WriteLine($"Evaluations: {N}"); Write("\n"); WriteLine("x^2*y*z"); WriteLine($"Results: integral estimate {resg[0]}, error {resg[1]}"); Write("\n"); WriteLine("1/(1-Cos(x)*Cos(y)*Cos(z))*1/(PI^3)"); WriteLine($"Results: integral estimate {resf[0]}, error {resf[1]}"); }
public void getCost(DateTime parkedDateTime, string type) { if (type.ToLower().Equals("car")) { Singelton singleton = Singelton.Instance; iPriceCalculator iCar = new Car(parkedDateTime); singleton.Return_Cost = iCar; } else if (type.ToLower().Equals("mc")) { Singelton singleton = Singelton.Instance; iPriceCalculator iMC = new MC(parkedDateTime); singleton.Return_Cost = iMC; } else { Singelton singleton = Singelton.Instance; iPriceCalculator iCustom = new CustomVehicle(parkedDateTime); singleton.Return_Cost = iCustom; } }
public string LoadMCData() { string message = string.Empty; try { string masterMCpath = ConfigurationManager.AppSettings["MasterMCpath"]; MC objData = new MC(); OBJtoXML xmltoObj = new OBJtoXML(); List <MCData> data = objData.LoadData(); xmltoObj.CreateXML(data, masterMCpath, "MCData", false); message = "Loaded MC Data"; } catch (Exception ex) { message = ex.Message; } return(message); }
public void LoginIn() { //Click over the initial setup of MC for communication configs MC.SetCommunicationConfig(); MC.Login(); Activity.Misc.Sleep(3000); //Activity.CheckBox.ClickByDevice(); MC.SelectPlatform("check1", Share.Platform.Android); Activity.Misc.PressKeyCode(Share.KeyCode.Back); Activity.Misc.Sleep(6000); Activity.Click.ByClassName("widget.Button", "APPLY"); Activity.Misc.Sleep(500); //LaunchApp MC.SearchApp("Field Inventory - Cycle Count"); Activity.Misc.Sleep(1000); Activity.Verify.Message("message", "No open cycle counts available"); Activity.Click.ByClassName("widget.Button"); //Verifies app titles Activity.Verify.Title("widget.TextView", "CYCLE COUNT"); Activity.Verify.Title("widget.TextView", "Add and Execute"); Activity.Verify.Title("widget.TextView", "Review and Approve", false); //Verifies position of delete and add images Activity.Verify.Images(); //Press Review and Aprrove tab to Verify position of delete and edit images Activity.Click.ByClassName("widget.TextView", "Review and Approve"); Activity.Verify.Message("message", "No counts available to review and approve."); Activity.Click.ByClassName("widget.Button"); Activity.Verify.Images(); //Press Add and Execute to process the count Activity.Click.ByClassName("widget.TextView", "Add and Execute"); Activity.Verify.Message("message", "No open cycle counts available"); Activity.Click.ByClassName("widget.Button"); Activity.Click.ByClassName("widget.Button", "Execute Count"); Activity.Misc.Sleep(500); Activity.Verify.Message("message", "No row selected"); Activity.Click.ById("button2", "android"); GlobalVar.AndroidDriver.CloseApp(); }
internal void StopFile(bool ClearImage) { Dialogs.LogWindow.Append("Stop"); MC.MediaStateButton.MediaState = MVPUC.Buttons.MediaStateButton.State.Play; DisposeRenderer(); if (ClearImage) { Utils.Animation.SwitchVisibility sv = new Utils.Animation.SwitchVisibility(); if (MediaInformationRoot.Visibility == Visibility.Visible) { sv.Animate(Config.Current.Animation[Enums.Animation.Default], LibraryRoot, MediaInformationRoot); } if (bgImage.Image != null) { Utils.Animation.Visible va = new Utils.Animation.Visible(); EventHandler handler = null; handler = (sender, e) => { bgImage.Image = null; Dialogs.LogWindow.Append("Image Removed"); va.AnimationCompleted -= handler; }; va.AnimationCompleted += handler; va.Animate(Config.Current.Animation[Enums.Animation.Default], bgImage, Visibility.Hidden); } MC.HideStatus(); SetPlaybackState(NAudio.Wave.PlaybackState.Stopped); } SeekBar.Value = SeekBar.Minimum; if (TaskbarManager != null) { TaskbarManager.HideButtons(); } }
public void LiveThreadProc() { MC.SIGNALINFO sigInfo = new MC.SIGNALINFO(); while (m_RunLoop) { //Get Signal Information try { MC.WaitSignal(channel, MC.SIG_ANY, 10000, out sigInfo); HandleSignal(ref sigInfo); } catch (Euresys.MultiCamException exc) { // An exception has occurred in the try {...} block. // Retrieve its description and display it in a message box. MessageBox.Show(exc.Message, "MultiCam Exception"); Close(); } } Console.WriteLine("worker thread: terminating gracefully."); }
/// <summary> /// 获取当前点的坐标系坐标 0 - NO COMPENSATION;1 - AFFINITY COMPENSATION; /// </summary> /// <param name="type"></param> /// 0 - NO COMPENSATION /// 1 - AFFINITY COMPENSATION /// 2 - LINE COMPENSATION /// <returns></returns> public Vector Get_Coordinate(int type) { Vector Result = new Vector(0, 0); Vector Tem_Pos = new Vector(0, 0); /***********人为单轴拆分***************/ double Current_Pos_X, Current_Pos_Y; MC.GT_GetPrfPos(1, out Current_Pos_X, 1, out uint pXClock); //读取X轴当前位置 MC.GT_GetPrfPos(2, out Current_Pos_Y, 1, out uint pYClock); //读取Y轴当前位置 Tem_Pos = new Vector(Program.SystemContainer.SysPara.Work.X - (decimal)Current_Pos_X / Program.SystemContainer.SysPara.Gts_Pos_reference, Program.SystemContainer.SysPara.Work.Y - (decimal)Current_Pos_Y / Program.SystemContainer.SysPara.Gts_Pos_reference); /***********输出结果***************/ if (type == 0) { Result = new Vector(Tem_Pos); } else { Result = new Vector(Gts_Cal_Data_Resolve.Get_Affinity_Point(1, Tem_Pos.X, Tem_Pos.Y)); } return(Result); }
public void TestLicenseplatelenght() { //Arrange string licenseplate = "1234567"; DateTime datetime = new DateTime(2014, 12, 7); bool brobizz = true; int discount = 5; bool Oresundbron = false; //var MC = new MC(licenseplate, datetime); //Act //string result = MC.VehicleType(); //Assert try { var MC = new MC(licenseplate, datetime, brobizz, discount, Oresundbron); } catch (ArgumentException) { Assert.Fail(); } }
/// <summary> /// Gts控制卡初始化 /// </summary> public void Reset() { //复位运动控制器 Gts_Return = MC.GT_Reset(); LogErr?.Invoke("Gts_Initial---GT_Reset", Gts_Return); //延时 Thread.Sleep(200); //配置运动控制器 Gts_Return = MC.GT_LoadConfig("Axis.cfg"); LogErr?.Invoke("Gts_Initial--GT_LoadConfig", Gts_Return); //清除各轴的报警和限位 Gts_Return = MC.GT_ClrSts(1, 4); LogErr?.Invoke("Gts_Initial--清除各轴的报警和限位", Gts_Return); //轴使能 Gts_Return = MC.GT_AxisOn(1); Gts_Return = MC.GT_AxisOn(2); //延时 Thread.Sleep(200); //设置X轴误差带 Gts_Return = MC.GT_SetAxisBand(1, Program.SystemContainer.SysPara.Axis_X_Band, 4 * Program.SystemContainer.SysPara.Axis_X_Time);//20-0.1um,4*2-250us LogErr?.Invoke("X轴到位误差带", Gts_Return); //设置Y轴误差带 Gts_Return = MC.GT_SetAxisBand(2, Program.SystemContainer.SysPara.Axis_Y_Band, 4 * Program.SystemContainer.SysPara.Axis_Y_Time);//20-0.1um,4*2-250us LogErr?.Invoke("Y轴到位误差带", Gts_Return); //设置X轴软件限位 Gts_Return = MC.GT_SetSoftLimit(1, Program.SystemContainer.SysPara.AxisXSoftLimitPositive * (int)Program.SystemContainer.SysPara.Gts_Pos_reference, Program.SystemContainer.SysPara.AxisXSoftLimitNegative * (int)Program.SystemContainer.SysPara.Gts_Pos_reference); LogErr?.Invoke("设置X轴软件限位", Gts_Return); //设置Y轴软件限位 Gts_Return = MC.GT_SetSoftLimit(2, Program.SystemContainer.SysPara.AxisYSoftLimitPositive * (int)Program.SystemContainer.SysPara.Gts_Pos_reference, Program.SystemContainer.SysPara.AxisYSoftLimitNegative * (int)Program.SystemContainer.SysPara.Gts_Pos_reference); LogErr?.Invoke("设置Y轴软件限位", Gts_Return); //轴回零完成信号 Axis01_Homed = false; Axis02_Homed = false; }
private void MoveObjectsOnMap <UC, MC>() where UC : UserControl, ICellItem where MC : ICellModel { var list = new List <UC>(MAP.Children.Cast <UIElement>() .Where(l => l is UC) .Cast <UC>()); if (list.Count > 0) { foreach (var v in list) { MC mc = (MC)v.DataContext; if (mc != null) { Canvas.SetLeft(v, mc.Location.X * CellSize); Canvas.SetTop(v, mc.Location.Y * CellSize); } v.CellSizeChanged(CellSize); } } }
public void CheckInterestOnePersonTwoWallets(double balance) { // 1 person has 2 wallets Wallet 1 has a Visa and Discover , wallet 2 a MC -each card has $100 balance - // calculate the total interest(simple interest) for this person and interest per wallet var InterestCalcService = CreateDefaultInterestCalcService(); Visa cardVisa = new Visa(balance); MC cardMC = new MC(balance); Discover cardDiscover = new Discover(balance); List <CreditCard> Cards1 = new List <CreditCard> { cardVisa, cardDiscover }; List <CreditCard> Cards2 = new List <CreditCard> { cardMC }; Wallet wallet1 = new Wallet(Cards1); Wallet wallet2 = new Wallet(Cards2); List <Wallet> Wallets = new List <Wallet> { wallet1, wallet2 }; Person person = new Person(Wallets); double totalInterestPerson = InterestCalcService.CalcInterestByPerson(person); double totalInterestWallet1 = InterestCalcService.CalcInterestByWallet(wallet1); double totalInterestWallet2 = InterestCalcService.CalcInterestByWallet(wallet2); Assert.True(totalInterestPerson == 16, $"{totalInterestPerson} should be 16"); Assert.True(totalInterestWallet1 == 11, $"{totalInterestWallet1} should be 11"); Assert.True(totalInterestWallet2 == 5, $"{totalInterestWallet2} should be 5"); }
public static void CreateVehicleObject() { switch (SelectedTicketType) { case Constants.TicketType.GENERIC_TICKET: if (SelectedVehicleType == Constants.VehicleType.CAR) { VehicleObject = new Car(); } else if (SelectedVehicleType == Constants.VehicleType.MOTORCYCLE) { VehicleObject = new MC(); } break; case Constants.TicketType.STOREBAELT_TICKET: if (SelectedVehicleType == Constants.VehicleType.CAR) { VehicleObject = new Car(); } if (SelectedVehicleType == Constants.VehicleType.MOTORCYCLE) { VehicleObject = new MC(); } break; case Constants.TicketType.ORESUND_TICKET: if (SelectedVehicleType == Constants.VehicleType.CAR) { VehicleObject = new OresundCar(); } else if (SelectedVehicleType == Constants.VehicleType.MOTORCYCLE) { VehicleObject = new OresundMC(); } break; } }
private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { try { Stop_Click(sender, e); // Whait that the channel has finished the last acquisition while (channelactive == true) { Thread.Sleep(10); } // Delete the channel if (channel != 0) { MC.Delete(channel); channel = 0; } } catch (Euresys.MultiCamException exc) { MessageBox.Show(exc.Message, "MultiCam Exception"); } }
/// <summary> /// 设置轴运行参数 /// </summary> /// <param name="Axis"></param> /// <param name="acc"></param> /// <param name="dcc"></param> /// <param name="smoothTime"></param> /// <param name="pos"></param> /// <param name="vel"></param> public void SetAxisPara(short Axis, decimal acc, decimal dcc, short smoothTime, decimal pos, decimal vel) { //定义点位运动参数变量 MC.TTrapPrm trapPrm = new MC.TTrapPrm(); //定义当前位置变量 double prfpos; //定义时钟 uint pclock; //定义轴状态 int sts; //将轴设置为点位运动模式 Gts_Return = MC.GT_PrfTrap(Axis); LogErr?.Invoke("Motion--将轴设置为点位运动模式", Gts_Return); //读取点位运动运动参数 Gts_Return = MC.GT_GetTrapPrm(Axis, out trapPrm); LogErr?.Invoke("Motion--读取轴点位运动运动参数", Gts_Return); //设置要修改的参数 trapPrm.acc = Convert.ToDouble(acc / Program.SystemContainer.SysPara.Gts_Acc_reference); trapPrm.dec = Convert.ToDouble(dcc / Program.SystemContainer.SysPara.Gts_Acc_reference); trapPrm.smoothTime = smoothTime; //设置点位运动参数 Gts_Return = MC.GT_SetTrapPrm(Axis, ref trapPrm); LogErr?.Invoke("Motion--读取轴设置点位运动参数", Gts_Return); //读取当前规划位置 Gts_Return = MC.GT_GetPrfPos(Axis, out prfpos, 1, out pclock); LogErr?.Invoke("Motion--读取轴当前规划位置", Gts_Return); //设置目标位置 Gts_Return = MC.GT_SetPos(Axis, Convert.ToInt32(pos)); LogErr?.Invoke("Motion--设置目标位置", Gts_Return); //设置目标速度 Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(vel / Program.SystemContainer.SysPara.Gts_Vel_reference)); LogErr?.Invoke("Motion--设置目标速度", Gts_Return); }
/// <summary> /// 建立直角坐标系 /// </summary> /// <param name="X_original"></param> /// <param name="Y_original"></param> public static void Coordination(decimal X_original, decimal Y_original) { //结构体变量,用于定义坐标系 //初始化结构体变量 MC.TCrdPrm crdPrm = new MC.TCrdPrm { dimension = 2, // 建立三维的坐标系 synVelMax = Convert.ToDouble(Para_List.Parameter.Syn_MaxVel / Para_List.Parameter.Gts_Vel_reference), // 坐标系的最大合成速度是: 500 pulse/ms (0-32767)/ms synAccMax = Convert.ToDouble(Para_List.Parameter.Syn_MaxAcc / Para_List.Parameter.Gts_Acc_reference), // 坐标系的最大合成加速度是: 2 pulse/ms^2 (0-32767)/ms evenTime = Convert.ToInt16(Para_List.Parameter.Syn_EvenTime), // 坐标系的最小匀速时间为0 profile1 = 1, // 规划器1对应到X轴 profile2 = 2, // 规划器2对应到Y轴 profile3 = 0, profile4 = 0, profile5 = 0, profile6 = 0, profile7 = 0, profile8 = 0, setOriginFlag = 1, // 需要设置加工坐标系原点位置 originPos1 = Convert.ToInt32(X_original * Para_List.Parameter.Gts_Pos_reference), // 加工坐标系原点位置在(0,0),即与机床坐标系原点重合 originPos2 = Convert.ToInt32(Y_original * Para_List.Parameter.Gts_Pos_reference), originPos3 = 0, originPos4 = 0, originPos5 = 0, originPos6 = 0, originPos7 = 0, originPos8 = 0 }; //停止轴规划运动,停止坐标系运动 Gts_Return = MC.GT_Stop(783, 0);//783--1-4轴全停止,坐标系1、2均停止;0-平滑停止运动,783-急停运动 Log.Commandhandler("Establish_Coordinationg--GT_Stop", Gts_Return); //建立坐标系 Gts_Return = MC.GT_SetCrdPrm(1, ref crdPrm); Log.Commandhandler("Establish_Coordinationg--GT_SetCrdPrm", Gts_Return); }
/// <summary> /// XY平台运动到配合振镜切割准备点 坐标矫正4 /// </summary> /// <param name="x"></param> /// <param name="y"></param> public static void Gts_Ready_Correct(decimal x, decimal y) { //数据矫正 Vector Tmp_Point = new Vector(); //定义处理的变量 decimal Tmp_X = 0.0m; decimal Tmp_Y = 0.0m; if (Para_List.Parameter.Gts_Affinity_Type == 2) { Tmp_Point = new Vector(Gts_Cal_Data_Resolve.Get_Line_Fit_Coordinate_AM(x, y, Fit_Matrices_AM)); Tmp_X = Tmp_Point.X; Tmp_Y = Tmp_Point.Y; } else { //数据矫正 Tmp_Point = new Vector(Gts_Cal_Data_Resolve.Get_Affinity_Point(0, x, y, affinity_Matrices)); Tmp_X = Tmp_Point.X; Tmp_Y = Tmp_Point.Y; } #if !DEBUG //清除FIFO 0 Clear_FIFO(); //初始化FIFO 0前瞻模块 Gts_Return = MC.GT_InitLookAhead(1, 0, Convert.ToDouble(Para_List.Parameter.LookAhead_EvenTime), Convert.ToDouble(Para_List.Parameter.LookAhead_MaxAcc), 4096, ref crdData[0]); Log.Commandhandler("Line_Interpolation--初始化FIFO 0前瞻模块", Gts_Return); //直线插补定位 Line_FIFO(Tmp_X, Tmp_Y);//将直线插补数据写入 //将前瞻数据压入控制器 Gts_Return = MC.GT_CrdData(1, Crd_IntPtr, 0); Log.Commandhandler("Line_Interpolation--将前瞻数据压入控制器", Gts_Return); #endif //启动定位 Interpolation_Start(); }
public MC Talk(MC mc) { if (this.name.Equals("Bart")) { if (mc.encounteredBart == 0) { System.Console.WriteLine("\nBart:\n" + "You must be new around here, certainly don't look \nfamiliar... \n\n" + "Well, if you didn't know already, you can always type \n" + "\"help\" to be given a list of commands.\n" + "*Press Enter to continue*"); mc.encounteredBart++; } else { System.Console.WriteLine("\nBart:\n" + "Hey! You should come check out my other shop on the other \n" + "side of town! That is, when the path is finally clear... \n" + "*Press Enter to continue*"); } } return(mc); }
private void Go_Click(object sender, System.EventArgs e) { // + MulticamAdvancedWaitSignal Sample Program // Start an acquisition sequence by activating the channel String channelState; MC.GetParam(channel, "ChannelState", out channelState); m_RunLoop = true; Thread workerThread = new Thread(LiveThreadProc); workerThread.Start(); if (channelState != "ACTIVE") { MC.SetParam(channel, "ChannelState", "ACTIVE"); } Refresh(); // - MulticamAdvancedWaitSignal Sample Program }
public void SetActive(bool LiveFlag) { String channelState; MC.SetParam(channel, MC.SignalEnable + MC.SIG_SURFACE_PROCESSING, "OFF"); MC.SetParam(channel, "ChannelState", "IDLE"); if (LiveFlag) { //MC.SetParam(channel, "ChannelState", "IDLE"); MC.SetParam(channel, "TrigMode", "IMMEDIATE"); //MC.SetParam(channel, "NextTrigMode", "REPEAT"); MC.SetParam(channel, "NextTrigMode", "SAME"); MC.GetParam(channel, "ChannelState", out channelState); if (channelState != "ACTIVE") { MC.SetParam(channel, "ChannelState", "ACTIVE"); } } else { if (channel != 0) { MC.SetParam(channel, "TrigMode", "HARD"); //MC.SetParam(channel, "NextTrigMode", "COMBINED"); MC.SetParam(channel, "NextTrigMode", "SAME"); //MC.SetParam(channel, "ForceTrig", "TRIG"); MC.SetParam(channel, "ChannelState", "IDLE"); MC.SetParam(channel, "ChannelState", "ACTIVE"); } } MC.SetParam(channel, MC.SignalEnable + MC.SIG_SURFACE_PROCESSING, "ON"); }
public void GrabImage(bool isLeft) { lock (lockerStart) { // + GrablinkSnapshotTrigger Sample Program // Start an acquisition sequence by activating the channel String channelState = null; if (isLeft) { MC.GetParam(channel, "ChannelState", out channelState); } else { MC.GetParam(channelR, "ChannelState", out channelState); } if (channelState != "ACTIVE") { if (isLeft) { MC.SetParam(channel, "ChannelState", "ACTIVE"); // Generate a soft trigger event MC.SetParam(channel, "ForceTrig", "TRIG"); FrmMain.T.queueIn(DateTime.Now.ToString("yy-MM-dd HH:mm:ss fff-") + "左相机启动成功"); } else { MC.SetParam(channelR, "ChannelState", "ACTIVE"); // Generate a soft trigger event MC.SetParam(channelR, "ForceTrig", "TRIG"); FrmMain.T.queueIn(DateTime.Now.ToString("yy-MM-dd HH:mm:ss fff-") + "右相机启动成功"); } } // Refresh(); // - GrablinkSnapshotTrigger Sample Program } }
public void AsyncLoadingScript(GameObject myReturnValue) { #region 读取模型 transform.position += StartPointOffSet; InstanceMesh = Instantiate(myReturnValue) as GameObject; InstanceMesh.transform.SetParent(this.transform); InstanceMesh.transform.localPosition = Vector3.zero; InstanceMesh.transform.localEulerAngles = Vector3.zero; #endregion #if UNITY_EDITOR && UNITY_ANDROID foreach (MeshRenderer meshRenderer in InstanceMesh.GetComponentsInChildren <MeshRenderer>()) { meshRenderer.sharedMaterial.shader = Shader.Find("Standard"); } #endif #region 设置网络状态 if (_InstanceNetType != InstanceNetType.GarageTank && !isBot(_InstanceNetType) && _InstanceNetType != InstanceNetType.GameNetWorkOffline) { } #endregion //模块加载 dontDestroyManager = new VehicleDontDestroyManagerModule(); referenceManager = InstanceMesh.GetComponent <VehicleComponentsReferenceManager>(); #region 加载完毕游戏资源加载脚本 TankPrefabs = gameObject; TurretTransform = InstanceMesh.transform.Find("TurretTransform").gameObject; MainHitBox = InstanceMesh.transform.Find("MainHitBox").gameObject; TankTransform = InstanceMesh.transform.Find("TankTransform").gameObject; GunTransform = TurretTransform.transform.Find("GunTransform").gameObject; FFPoint = GunTransform.transform.Find("FFPoint").gameObject; EffectStart = GunTransform.transform.Find("EffectStart").gameObject; TurretHitBox = TurretTransform.transform.Find("TurretHitBox").gameObject; GameObject TankScript = null, TankCrossHair = null, MainCamera = null; Rigidbody TankPhysic = null; TurretController mt = null; // SyncGroundVehicle _syncGroundVehicle = null; PlayerTracksController PTC = null; PlayerState PS = null; PTC = InstanceMesh.AddComponent <PlayerTracksController> (); #region 物理效果 TankPhysic = GetComponentInChildren <Rigidbody> (); TankPhysic.mass = PTCParameter.Mass; TankPhysic.drag = 0.1f; //PTCParameter.Drag; TankPhysic.angularDrag = 2.5f; //PTCParameter.AirDrag; TankPhysic.useGravity = false; BoxCollider[] collisions = PTC.GetComponentsInChildren <BoxCollider> (); foreach (Collider collision in collisions) { if (collision.isTrigger != true) { collision.material = StaticResourcesReferences.Instance.VehiclePhysicMaterial; } } #endregion if (_InstanceNetType != InstanceNetType.GarageTank) { if (isLocalPlayer(_InstanceNetType)) { TankCrossHair = Instantiate((GameObject)Resources.Load("TankCrossHair"), Vector3.zero, Quaternion.identity) as GameObject; MainCamera = Instantiate((GameObject)Resources.Load("MainCamera"), Vector3.zero, Quaternion.identity) as GameObject; TankCrossHair.transform.parent = TankPrefabs.transform; MainCamera.transform.parent = InstanceMesh.transform; MainCamera.transform.name = "MainCamera"; } TankScript = Instantiate((GameObject)Resources.Load("TankScript"), Vector3.zero, Quaternion.identity) as GameObject; TankScript.transform.name = "TankScript"; TankScript.transform.parent = TankPrefabs.transform; TankPhysic.useGravity = true; #region PlayerState 脚本设置 if (!isBot(_InstanceNetType)) { PS = InstanceMesh.AddComponent <PlayerState>(); PS.tankInitSystem = this; foreach (HitBox HB in GetComponentsInChildren <HitBox>()) { HB.SetTarget(PS); } PS.playerStateParameter = PSParameter; PS.netType = _InstanceNetType; PS.Turret = TurretTransform; PS.TankScript = TankScript; PS.DiedDestoryObjects = new Object[] { MainHitBox, TurretHitBox }; PS.TankName = VehicleName; PS.Health = PSParameter.Health; PS.engineType = PSParameter.engineType; PS.IsMobile = isMobile; } #endregion if (isBot(_InstanceNetType)) { EnemyAiState enemyState = InstanceMesh.AddComponent <EnemyAiState>(); foreach (HitBox HB in GetComponentsInChildren <HitBox>()) { HB.SetTarget(enemyState); } enemyState.TankScript = TankScript; enemyState.Health = PSParameter.Health; enemyState.TankName = VehicleName; enemyState.MyTeam = ownerTeam; } #region TankScript 脚本设置 mt = TankScript.GetComponent <TurretController>(); if (isLocalPlayer(_InstanceNetType)) { mt.target = MainCamera.transform.Find("CameraTarget"); } mt.gun = GunTransform.transform; mt.Turret = TurretTransform.transform; mt.DownMaxDegree = MTParameter.DownMaxDegree; mt.UpMaxDegree = MTParameter.UpMaxDegree; mt.maxTurretAngle = MTParameter.maxTurretAngle; mt.gunDegreesPerSecond = MTParameter.gunDegreesPerSecond; mt.turretDegreesPerSecond = MTParameter.turretDegreesPerSecond; mt.isMobile = isMobile; #endregion #region 主摄像机设置 if (isLocalPlayer(_InstanceNetType)) { MainCamera.GetComponent <VehicleCamera>().target = referenceManager.MainCameraFollowTarget.transform; MainCamera.GetComponent <VehicleCamera>().mainCameraFollowTarget = referenceManager.MainCameraFollowTarget.transform; MainCamera.GetComponent <VehicleCamera>().mainCameraGunner = referenceManager.MachineGunFFPoint.transform; referenceManager.MachineGunFFPoint.transform.position = referenceManager.FFPoint.transform.position; MainCamera.GetComponent <VehicleCamera>().IsMobile = isMobile; if (PSParameter.vehicleType == VehicleType.SPG) { MainCamera.GetComponent <VehicleCamera>().isVehicleSPG = true; } } #endregion #region 瞄准射线 if (isLocalPlayer(_InstanceNetType)) { RayManager rayManager = TankScript.AddComponent <RayManager>(); rayManager.Init(FFPoint.transform); } #endregion #region 瞄准镜设置 if (isLocalPlayer(_InstanceNetType)) { TankCrossHair.GetComponent <CrossHair>().MainCamera = MainCamera.GetComponent <Camera>(); TankCrossHair.GetComponent <CrossHair>().tankCamera = MainCamera.GetComponent <VehicleCamera>(); TankCrossHair.GetComponent <CrossHair>().FFPoint = EffectStart.transform; } #endregion #region 坦克发射器脚本设置 TankFire tf = TankScript.GetComponent <TankFire>(); tf.tankFireParameter = TFParameter; tf.tankInitSystem = this; tf.MachineGunFFPoint = referenceManager.MachineGunFFPoint.transform; tf.FFPoint = referenceManager.FFPoint.transform; tf.FireRecoilPoint = referenceManager.FireForceFeedbackPoint.transform; tf.FireEffectPoint = referenceManager.EffectStart.transform; tf.BulletCountList = BulletCountList; tf.GunDym = GunTransform.transform.Find("GunDym").GetComponent <Animator>(); tf.MainBody = InstanceMesh.transform; tf.netType = _InstanceNetType; if (PSParameter.vehicleType == VehicleType.SPG) { tf.isAutoCaclulateGravity = true; } #endregion #region 引擎音效控制 EngineSoundModule engineSoundModule = InstanceMesh.AddComponent <EngineSoundModule>(); engineSoundModule.tankInitSystem = this; engineSoundModule.engineData = PTCParameter.vehicleEngineSoundData; engineSoundModule.Init(referenceManager.EngineSound.transform); #endregion GameObject EngineSmoke = Instantiate <GameObject>(Resources.Load <GameObject>("EngineSmoke")); EngineSmoke.transform.SetParent(referenceManager.EngineSmoke.transform); EngineSmoke.transform.localPosition = Vector3.zero; EngineSmoke.transform.localEulerAngles = Vector3.zero; //GameObject grounddust = Instantiate(Resources.Load<GameObject>("TrackEffect")); //grounddust.transform.SetParent(InstanceMesh..transform); //grounddust.transform.localPosition = Vector3.zero; //grounddust.transform.localEulerAngles = Vector3.zero; VehicleState vehicleState = InstanceMesh.AddComponent <VehicleState>(); vehicleState.engineSoundModule = engineSoundModule; vehicleState.tankTracksController = PTC; } #region 坦克控制器设置 PTC.tankInitSystem = this; PTC.rightTrackUpperWheels = GetAllChilds(TankTransform.transform.Find("RightUpperWheel")); PTC.leftTrackUpperWheels = GetAllChilds(TankTransform.transform.Find("LeftUpperWheel")); PTC.rightTrackWheels = GetAllChilds(TankTransform.transform.Find("RightWheel")); PTC.leftTrackWheels = GetAllChilds(TankTransform.transform.Find("LeftWheel")); PTC.leftTrack = referenceManager.LeftTrack; PTC.rightTrack = referenceManager.RightTrack; //PTC.leftTrackBones = CreateTrack (true, TankTransform.transform, ref PTC); //PTC.rightTrackBones = CreateTrack (false, TankTransform.transform, ref PTC); PTC.tankTransform = TankTransform.transform; PTC.maxAngularVelocity = PTCParameter.MaxAngularVelocity; PTC.MaxSpeed = PTCParameter.MaxSpeed; PTC.MinSpeed = PTCParameter.MinSpeed; PTC.COM = PTCParameter.CenterOfGravity; PTC.PushSpeed = PTCParameter.PushSpeed; PTC.BackSpeed = PTCParameter.BackSpeed; PTC.sidewaysFrictionAsymptoteFactor = PTCParameter.SideWaysFrictionAsymptoteFactor; PTC.sidewaysFrictionExtremumFactor = PTCParameter.SideWaysFrictionExtremumFactor; PTC.wheelCollider = PTCParameter.TankWheelCollider; PTC.wheelsAndBonesAxisSettings = new PlayerTracksController.WheelsAxisSettings(); PTC.wheelsAndBonesAxisSettings.bonesPositionAxis = TankTracksController.Axis.Z; PTC.wheelsAndBonesAxisSettings.wheelsPositionAxis = TankTracksController.Axis.Z; PTC.wheelsAndBonesAxisSettings.wheelsRotationAxis = TankTracksController.Axis.X; PTC.accelerationConfiguration = PTCParameter.VAconfigSetting; PTC.rotationOnAccelerationConfiguration = PTCParameter.HAconfigSetting; PTC.rotationOnStayConfiguration = PTCParameter.HAconfigSetting; #endregion #region 车库状态 if (_InstanceNetType == InstanceNetType.GarageTank) { PTC.enabled = false; TankPhysic.isKinematic = true; if (ShowHitBoxInspecter) { foreach (HitBox HB in GetComponentsInChildren <HitBox>()) { HB.StartCoroutine(HB.ShowArmorInfo()); } } foreach (MeshCollider MC in transform.root.GetComponentsInChildren <MeshCollider>()) { if (MC.GetComponent <HitBox> () == null) { MC.enabled = false; } } //EventManager.StartListening ("TankInitSystem.InitTankShader", GarageInitTankShaderPreView); return; } #endregion if (ExtraTF && !isBot(_InstanceNetType)) { for (int i = 0; i < multiTurrets.Length; i++) { GameObject TankScriptExtra = Instantiate((GameObject)Resources.Load("TankScript"), Vector3.zero, Quaternion.identity) as GameObject; TankScriptExtra.transform.name = "TankScriptExtra"; TankScriptExtra.transform.parent = TankPrefabs.transform; TurretController mouseTurretExtra = TankScriptExtra.GetComponent <TurretController> (); if (isLocalPlayer(_InstanceNetType)) { mouseTurretExtra.target = MainCamera.transform.Find("CameraTarget"); } Transform ExtraTurret = InstanceMesh.transform.Find(multiTurrets [i].ObjectPath); Transform ExtraGun = ExtraTurret.transform.Find("GunTransform"); mouseTurretExtra.gun = ExtraGun; mouseTurretExtra.Turret = ExtraTurret; mouseTurretExtra.DownMaxDegree = multiTurrets [i].MTParameter.DownMaxDegree; mouseTurretExtra.UpMaxDegree = multiTurrets [i].MTParameter.UpMaxDegree; mouseTurretExtra.maxTurretAngle = multiTurrets [i].MTParameter.maxTurretAngle; mouseTurretExtra.gunDegreesPerSecond = multiTurrets [i].MTParameter.gunDegreesPerSecond; mouseTurretExtra.turretDegreesPerSecond = multiTurrets [i].MTParameter.turretDegreesPerSecond; mouseTurretExtra.isMobile = isMobile; TankFire tfExtra = TankScriptExtra.GetComponent <TankFire> (); Transform ExtraFFPoint = ExtraGun.Find("FFPoint"); Transform ExtraFireEffect = ExtraGun.Find("FireEffect"); tfExtra.FFPoint = ExtraFFPoint; tfExtra.FireRecoilPoint = FFPoint.transform; tfExtra.FireEffectPoint = ExtraFireEffect; tfExtra.MainBody = InstanceMesh.transform; //tfExtra.FireRecoil = multiTurrets [i].tankFireParameter.FireRecoil; //tfExtra.ReloadTime = multiTurrets [i].tankFireParameter.ReloadTime; //tfExtra.AmmoCount = multiTurrets [i].tankFireParameter.AmmoCount; //tfExtra.HasMahineGun = multiTurrets [i].tankFireParameter.HasMachineGun; //tfExtra.muzzleFire = multiTurrets [i].tankFireParameter.MuzzleFire; //tfExtra.advanceFireClass = multiTurrets [i].tankFireParameter.advanceFireClass; //tfExtra.fireState = multiTurrets [i].tankFireParameter.FireState; //tfExtra.netType = InstanceNetType; } } #endregion InstanceMesh.AddComponent <Identity> (); if (isLocalPlayer(_InstanceNetType)) { GameEvent.InitPlayer(InstanceMesh.GetComponent <Identity>()); } #region 初始化玩家网络 if (!GameDataManager.OfflineMode) { if (_InstanceNetType == InstanceNetType.GameNetworkOthers) { PTC.enableUserInput = false; //PTC.AdvanceTrackSystem = false; PTC.OnlyReceiveControlActions = true; } if (_InstanceNetType == InstanceNetType.GameNetworkMaster) { PTC.enableUserInput = false; } if (_InstanceNetType == InstanceNetType.GameNetworkClient) { PTC.enableUserInput = true; PTC.OnlyReceiveControlActions = true; } if (isBot(_InstanceNetType)) { PTC.enableUserInput = false; if (_InstanceNetType == InstanceNetType.GameNetWorkBotClient) { PTC.OnlyReceiveControlActions = true; } else { PTC.OnlyReceiveControlActions = false; } } //_syncGroundVehicle = InstanceMesh.AddComponent<SyncGroundVehicle> (); //_syncGroundVehicle.tankInitSystem = this; //_syncGroundVehicle.Init (PTC, mt, _InstanceNetType); } #region 设置离线标识 if (GameDataManager.OfflineMode) { if (_InstanceNetType == InstanceNetType.GameNetWorkOffline) { Identity MyIdentity = InstanceMesh.GetComponent <Identity> (); MyIdentity.Init(ownerTeam, InstanceNetType.GameNetWorkOffline); MyIdentity.SetOwnerInfo("LocalPlayer", VehicleName, 0); } } #endregion #endregion if (!isBot(_InstanceNetType)) { StartCoroutine(PS.Init()); } if (GameEventManager.onNewVehicleSpawned != null) { GameEventManager.onNewVehicleSpawned(this); } if (onVehicleLoaded != null) { onVehicleLoaded(); } }
public int MCPris() { var mc = new MC(); return(mc.Pris()); }
private void Start() { main = c.GetComponent <MC>(); }
public CEuresysManager(string _CamInfo = "VCC-G20S20_P15RA", int _CamExposure = 1000) { try { // Open MultiCam driver MC.OpenDriver(); // Enable error logging MC.SetParam(MC.CONFIGURATION, "ErrorLog", "error.log"); // Create a channel and associate it with the first connector on the first board MC.Create("CHANNEL", out channel); MC.SetParam(channel, "DriverIndex", 0); // For all Domino boards except Domino Symphony MC.SetParam(channel, "Connector", "X"); // For Domino Symphony //MC.SetParam(channel, "Connector", "A"); // Choose the CAM file //MC.SetParam(channel, "CamFile", "XC-HR50_P60RA"); //MC.SetParam(channel, "CamFile", "VCC-G20S20_P15RA"); //MC.SetParam(channel, "CamFile", "CV-A1_P16RA"); if (_CamInfo == "") { _CamInfo = "VCC-G20S20_P15RA"; } MC.SetParam(channel, "CamFile", _CamInfo); // Choose the camera expose duration MC.SetParam(channel, "Expose_us", _CamExposure); // Choose the pixel color format MC.SetParam(channel, "ColorFormat", "Y8"); // Choose the way the first acquisition is triggered //MC.SetParam(channel, "TrigMode", "IMMEDIATE"); MC.SetParam(channel, "TrigMode", "HARD"); // Choose the triggering mode for subsequent acquisitions //MC.SetParam(channel, "NextTrigMode", "REPEAT"); MC.SetParam(channel, "NextTrigMode", "SAME"); // Choose the number of images to acquire //MC.SetParam(channel, "TrigLine", "NOM"); //MC.SetParam(channel, "TrigEdge", "GOHIGH"); //MC.SetParam(channel, "TrigFilter", "ON"); //MC.SetParam(channel, "TrigCtl", "LVDS"); MC.SetParam(channel, "TrigCtl", "TTL"); MC.SetParam(channel, "TrigLine", "NOM"); MC.SetParam(channel, "TrigEdge", "GOLOW"); MC.SetParam(channel, "TrigFilter", "ON"); MC.SetParam(channel, "StrobeCtl", "OPTO"); //MC.SetParam(channel, "StrobeCtl", "TTL"); MC.SetParam(channel, "StrobeMode", "AUTO"); MC.SetParam(channel, "StrobeLevel", "PLSLOW"); //MC.SetParam(channel, "SeqLength_Fr", MC.INDETERMINATE); MC.SetParam(channel, "SeqLength_Fr", -1); // Register the callback function multiCamCallback = new MC.CALLBACK(MultiCamCallback); MC.RegisterCallback(channel, multiCamCallback, channel); // Enable the signals corresponding to the callback functions MC.SetParam(channel, MC.SignalEnable + MC.SIG_SURFACE_PROCESSING, "ON"); MC.SetParam(channel, MC.SignalEnable + MC.SIG_ACQUISITION_FAILURE, "ON"); // Prepare the channel in order to minimize the acquisition sequence startup latency MC.SetParam(channel, "ChannelState", "READY"); MC.SetParam(channel, "ChannelState", "ACTIVE"); } catch (Euresys.MultiCamException ex) { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.ERR, "cEuresysManager() Exception!!", CLogManager.LOG_LEVEL.LOW); } }
public Bitmap Capture() { try { image = null; // Enable error logging MC.SetParam(MC.CONFIGURATION, "ErrorLog", "error.log"); // In order to support a 10-tap camera on Grablink Full // BoardTopology must be set to MONO_DECA // In all other cases the default value will work properly // and the parameter doesn't need to be set // Set the board topology to support 10 taps mode (only with a Grablink Full) // MC.SetParam(MC.BOARD + 0, "BoardTopology", "MONO_DECA"); // In order to use single camera on connector A // MC_Connector must be set to A for Grablink DualBase // For all other Grablink boards the parameter has to be set to M // For all GrabLink boards except Grablink DualBase MC.SetParam(channel, "Connector", "M"); // For Grablink DualBase //MC.SetParam(channel, "Connector", "A"); // Choose the CAM file MC.SetParam(channel, "CamFile", "../../UserData/STC-CL25M_8T freerun"); // Choose the camera expose duration MC.SetParam(channel, "Expose_us", 20000); // Choose the pixel color format MC.SetParam(channel, "ColorFormat", "Y8"); //Set the acquisition mode to Snapshot MC.SetParam(channel, "AcquisitionMode", "SNAPSHOT"); // Choose the way the first acquisition is triggered MC.SetParam(channel, "TrigMode", "IMMEDIATE"); // Choose the triggering mode for subsequent acquisitions MC.SetParam(channel, "NextTrigMode", "REPEAT"); // Choose the number of images to acquire MC.SetParam(channel, "SeqLength_Fr", MC.INDETERMINATE); // Register the callback function multiCamCallback = new MC.CALLBACK(MultiCamCallback); MC.RegisterCallback(channel, multiCamCallback, channel); // Enable the signals corresponding to the callback functions MC.SetParam(channel, MC.SignalEnable + MC.SIG_SURFACE_PROCESSING, "ON"); MC.SetParam(channel, MC.SignalEnable + MC.SIG_ACQUISITION_FAILURE, "ON"); // Prepare the channel in order to minimize the acquisition sequence startup latency MC.SetParam(channel, "ChannelState", "READY"); string channelState; MC.GetParam(channel, "ChannelState", out channelState); if (channelState != "ACTIVE") { MC.SetParam(channel, "ChannelState", "ACTIVE"); } } catch (Euresys.MultiCamException exc) { throw exc; } SpinWait.SpinUntil(() => image != null); MC.SetParam(channel, "ChannelState", "IDLE"); return(image); }
public void Close() { MC.CloseDriver(); }