protected void btnCreate_Click(object sender, EventArgs e) { if (!IsValid) { (Master as Dreadnought_Master).Message("Please make sure the form is valid."); return; } MasterInfo masterInfo = new MasterInfo(txtMaster.Text); if (masterInfo.Exists) { (Master as Dreadnought_Master).Message("This master already exists (<a href=\"EditMaster.aspx?Master=" + masterInfo.RelativePath + "\">Edit it</a>)."); return; } try { masterInfo.Save(); } catch (Dreadnought.InvalidDirectoryException) { (Master as Dreadnought_Master).Message("You cannot create a master in the directory '" + masterInfo.RelativeDirectory + "'."); return; } catch { (Master as Dreadnought_Master).Message("An unexpected error occurred. Please make sure you have sufficent user rights."); return; } if (chkRedirect.Checked) Response.Redirect("EditMaster.aspx?Master=" + masterInfo.RelativePath); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Master"] == null) { (Master as Dreadnought_Master).Message("You have to specify the full relative path of a master using the querystring parameter 'Master'."); DisableAll(); return; } masterInfo = new MasterInfo(Request.QueryString["Master"]); if (!masterInfo.Exists) { (Master as Dreadnought_Master).Message("The specified master does not exist."); DisableAll(); return; } lblPage.Text = masterInfo.RelativePath; }
private async void BindIATAPicker() { MasterInfo mInfo = App.DAUtil.GetMasterInfoByName("Stations"); if (mInfo != null) { var stationsOffline = JsonConvert.DeserializeObject <SPData>(mInfo.content); iataPicker.ItemsSource = stationsOffline.d.results.Select(x => x.IATA_x0020_Code).ToList(); } ToggleBusy(true); var stations = await SPUtility.GetStations(true); iataPicker.ItemsSource = stations.Select(x => x.Value).ToList(); ToggleBusy(false); }
public bool UpdateMasterInfo(MasterInfo data) { SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("@MasterCd", data.Key), new SqlParameter("@DetailCd", data.Id), new SqlParameter("@Value", data.Value), new SqlParameter("@Value2", data.Value2), new SqlParameter("@Value3", data.Value3), new SqlParameter("@Value4", data.Value4), new SqlParameter("@Value5", data.Value5), new SqlParameter("@UpdateUser", UserInfo.UserID) }; this.Context.ExecuteDataFromProcedure("MasterInfoUpdate", sqlParameters); return(true); }
protected void gvMaster_RowUpdating(object sender, GridViewUpdateEventArgs e) { int masterid = Convert.ToInt32(gvMaster.DataKeys[e.RowIndex].Value); TextBox txtMasterName = gvMaster.Rows[e.RowIndex].FindControl("txtMasterName") as TextBox; try { MasterInfo master = new MasterInfo(masterid); master.MasterName = txtMasterName.Text.ToString(); master.Save(); gvMaster.EditIndex = -1; gvDataBind(); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('更新失败:" + Ex.Message + "');", true); } }
protected void btnLogin_Click(object sender, EventArgs e) { string strUserName = Request["textuser"].ToString(); string strUserPsd = Request["password"].ToString(); //Console.WriteLine("ok"); //Console.WriteLine(strUserName + strUserName); //Response.Write("ok"); if (strUserName == "" || strUserPsd == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('Óû§ÃÜÂ벻Ϊ¿Õ!');</script>"); } else { bool IsUserLogin = MasterInfo.IsUser(strUserName, strUserPsd); if (IsUserLogin) { int EmployeeId = Convert.ToInt32(EmployeeInfo.getEmployeeOfMaster(strUserName, strUserPsd)); EmployeeInfo em = new EmployeeInfo(EmployeeId); string strRoleName = DayInfo.getRoleNameOfMaster(strUserName); DepartInfo depart = new DepartInfo(em.DepartId); Session["userName"] = strUserName; Session["userPsd"] = strUserPsd; Session["Employee"] = em; Session["EmployeeId"] = em.EmployeeId; Session["EmployeeName"] = em.EmployeeName; Session["RoleName"] = strRoleName; Session["DepartName"] = depart.DepartName.ToString(); Session["DepartId"] = em.DepartId; Session["PositionId"] = em.PositionId; Response.Redirect("main.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('Óû§ÃÜÂë´íÎó!');</script>"); } } }
private void btnImportBatch_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); //dialog.RestoreDirectory = true; dialog.Filter = "人物数据|*.master"; dialog.Multiselect = true; if (dialog.ShowDialog() == DialogResult.OK && dialog.FileNames.Length > 0) { txtSearch.Text = null; foreach (string fileName in dialog.FileNames) { byte[] data = File.ReadAllBytes(fileName); byte[] bt = new byte[GGCRStaticConfig.MasterUIDLength]; Array.Copy(data, 0, bt, 0, bt.Length); string uid = ByteHelper.ByteArrayToHexString(bt).Trim(); MasterInfo select = null; foreach (MasterInfo info in masters) { if (info.UUID == uid) { select = info; break; } } if (select != null) { select.Replace(data); select.Save(); } } lsMasters.SelectedItem = null; bindAll(); MessageBox.Show("导入成功,已自动保存", "操作提示"); // lsGundam.SelectedIndex = 0; } }
public bool CheckConnection() { if (Application.internetReachability == NetworkReachability.NotReachable) { MsgController.ShowMsg(SFST.T.Sharing_No_Connection); return(false); } this.latestInfo = MasterInfo.Fetch(); if (this.latestInfo == null) { if (Sharing.mgcache0 == null) { Sharing.mgcache0 = new Action <string>(MsgController.ShowMsg); } SyncContext.RunOnUI <string>(Sharing.mgcache0, SFST.T.STP_Request_Timeout); return(false); } int num = VersionHolder.SharingVersion.CompareVersion(this.latestInfo.Version.Sharing.Client); int num2 = VersionHolder.ProtocolVersion.CompareVersion(this.latestInfo.Version.Sharing.Protocol); if (num == -1) { MsgController.ShowMsg(SFST.T.Sharing_Old_Version); return(false); } if (num == 1) { MsgController.ShowMsg(SFST.T.Sharing_New_Version); return(false); } if (num2 == -1) { MsgController.ShowMsg(SFST.T.Sharing_Old_Protocol); return(false); } if (num2 == 1) { MsgController.ShowMsg(SFST.T.Sharing_New_Protocol); return(false); } return(true); }
private static void setupTrackers() { foreach (var detectedDevice in _xda._DetectedDevices) { if (!detectedDevice.deviceId().isWirelessMaster()) { logger.Log($"Not wireless Master ... exiting for device {detectedDevice.deviceId().toInt().ToString()}"); break; } _xda.openPort(detectedDevice); var masterInfo = new MasterInfo(detectedDevice.deviceId()); masterInfo.ComPort = detectedDevice.portName(); masterInfo.BaudRate = detectedDevice.baudrate(); //TODO: Find out what the channel number represents and means _xda.getDevice(detectedDevice.deviceId()).enableRadio(11); logger.Log($"Radio enabled for device {detectedDevice.deviceId().toInt().ToString()}"); } }
protected void btnSend_Click(object sender, EventArgs e) { int roleid = Convert.ToInt32(rblRole.SelectedValue); int masterid = Convert.ToInt32(Request.QueryString["MasterId"].ToString()); try { //添加角色 if (RoleInfo.isRoleMaster(masterid)) { RoleInfo.UpdateRoleMaster(masterid, roleid); } else { RoleMasterInfo rm = new RoleMasterInfo(); rm.RoleId = roleid; rm.MasterId = masterid; rm.IsPass = 0; rm.Save(); } //添加权限 if (RoleInfo.isActionMaster(masterid)) { RoleInfo.DelActionMaster(masterid); AddActionMaster(masterid); } else { AddActionMaster(masterid); } MasterInfo master = new MasterInfo(masterid); master.IsApply = 1; master.State = 1; master.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('您分配的权限发送成功!');</script>"); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('配置失败:" + Ex.Message + "');", true); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); //dialog.RestoreDirectory = true; dialog.Filter = "人物数据|*.master"; if (dialog.ShowDialog() == DialogResult.OK) { txtSearch.Text = null; byte[] data = File.ReadAllBytes(dialog.FileName); byte[] bt = new byte[GGCRStaticConfig.MasterUIDLength]; Array.Copy(data, 0, bt, 0, bt.Length); string uid = ByteHelper.ByteArrayToHexString(bt).Trim(); MasterInfo select = null; foreach (MasterInfo info in masters) { if (info.UUID == uid) { select = info; break; } } if (select == null) { MessageBox.Show("该角色不存在,无法导入", "导入失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { select.Replace(data); lsMasters.SelectedItem = null; lsMasters.SelectedItem = select; tsmiLblState.Text = "请保存"; tsmiLblState.ForeColor = Color.Red; } } }
public void MasterInfoをもとに参照情報を生成できる() { PropertyFactory factory = new PropertyFactory(); var builder = new MasterLoader(factory); var info = new MasterInfo[] { new MasterInfo("Fugas", typeof(Hoge).GetMember(nameof(Hoge.Fugas))[0] as PropertyInfo, new ComplicateCollectionProperty(typeof(Fuga[]), factory)), new MasterInfo("Fuga", typeof(Hoge).GetMember(nameof(Hoge.Fuga))[0] as PropertyInfo, new ClassProperty(typeof(Fuga), factory)) }; var repo = builder.AsDynamic() .GetReferencableMasters(info as IEnumerable <MasterInfo>) as MasterRepository; repo.ContainsKey("Fugas").IsTrue(); repo["Fugas"].Type.Is(typeof(Fuga)); repo.ContainsKey("Fuga").IsFalse(); }
public MasterInfo MasterCopyViewByFormName(int formName) { MasterInfo infoMaster = new MasterInfo(); try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("MasterCopyViewByFormName", base.sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@formName", SqlDbType.Int).Value = formName; SqlDataReader sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { infoMaster.MasterId = int.Parse(((DbDataReader)sqldr)["masterId"].ToString()); infoMaster.FormName = int.Parse(((DbDataReader)sqldr)["formName"].ToString()); infoMaster.IsTwoLineForHedder = bool.Parse(((DbDataReader)sqldr)["isTwoLineForHedder"].ToString()); infoMaster.IsTwoLineForDetails = bool.Parse(((DbDataReader)sqldr)["isTwoLineForDetails"].ToString()); infoMaster.PageSize1 = int.Parse(((DbDataReader)sqldr)["pageSize1"].ToString()); infoMaster.PageSizeOther = int.Parse(((DbDataReader)sqldr)["pageSizeOther"].ToString()); infoMaster.BlankLneForFooter = int.Parse(((DbDataReader)sqldr)["blankLneForFooter"].ToString()); infoMaster.FooterLocation = ((DbDataReader)sqldr)["footerLocation"].ToString(); infoMaster.LineCountBetweenTwo = int.Parse(((DbDataReader)sqldr)["lineCountBetweenTwo"].ToString()); infoMaster.Pitch = ((DbDataReader)sqldr)["pitch"].ToString(); infoMaster.Condensed = ((DbDataReader)sqldr)["condensed"].ToString(); infoMaster.LineCountAfterPrint = int.Parse(((DbDataReader)sqldr)["lineCountAfterPrint"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MasterViewByFormName", MessageBoxButtons.OK, MessageBoxIcon.Hand); } finally { base.sqlcon.Close(); } return(infoMaster); }
public static async Task<Dictionary<string, string>> GetStations(bool isOpen = false) { MasterInfo mInfo = null; if (!SPUtility.IsConnected()) { mInfo = App.DAUtil.GetMasterInfoByName("Stations"); } else { try { var client = await OAuthHelper.GetHTTPClientAsync(); string url = GetListURL(ReportType.SationInfo); if (isOpen) { url += "?$filter=Status eq 'Open'"; } var response = await client.GetStringAsync(url); if (response != null) { mInfo = new MasterInfo { Name = "Stations", content = response }; App.DAUtil.RefreshMasterInfo(mInfo); } } catch (Exception) { mInfo = App.DAUtil.GetMasterInfoByName("Stations"); } } if (mInfo != null) { var stations = JsonConvert.DeserializeObject<SPData>(mInfo.content); return stations.d.results.Select(x => new { Key = x.Id.ToString(), Value = x.IATA_x0020_Code }).ToDictionary(v => v.Key, v => v.Value); } return null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //绑定角色权限 rblRoleBind(); ckblRightBind(); //初始化角色权限 int masterId = Convert.ToInt32(Request.QueryString["MasterId"].ToString()); MasterInfo master = new MasterInfo(masterId); EmployeeInfo em = new EmployeeInfo(master.EmployeeId); lblUser.Text = master.MasterName.ToString(); lblEmployee.Text = em.EmployeeName.ToString(); InitRole(masterId); InitAction(masterId); if (master.State == 1) { btnSend.Enabled = false; } } }
private void ScanForStations() { List <MasterInfo> _stations = new List <MasterInfo>(); _xda.scanPorts(); if (_xda._DetectedDevices.Count > 0) { foreach (XsPortInfo portInfo in _xda._DetectedDevices) { if (portInfo.deviceId().isWirelessMaster() || portInfo.deviceId().isAwindaStation()) { UnityEngine.Debug.Log("found wireless connector"); _xda.openPort(portInfo); MasterInfo ai = new MasterInfo(portInfo.deviceId()); ai.ComPort = portInfo.portName(); ai.BaudRate = portInfo.baudrate(); _stations.Add(ai); break; } } if (_stations.Count > 0) { UnityEngine.Debug.Log("Found station: " + _stations[0].ToString() + " ... creating master device."); _masterDevice = _xda.getDevice(_stations[0].DeviceId); if (!_masterDevice.gotoConfig()) { throw new UnityException("could not enter configuration mode of created master device"); } UnityEngine.Debug.Log("master device created successfully, ready to enable radio"); } else { throw new UnityException("no station could be found, make sure drivers are installed correctly"); } } }
public static string GetLookupIdFromValue(LookupType lType, string value) { string lookup = ""; switch (lType) { case LookupType.AircraftRegistraions: lookup = "AircraftRegistrations"; break; case LookupType.FlightNumbers: lookup = "OperatingPlans"; break; default: break; } MasterInfo mInfo = mInfo = App.DAUtil.GetMasterInfoByName(lookup); var oPlans = JsonConvert.DeserializeObject<SPData>(mInfo.content); int id = 0; Result res = null; switch (lType) { case LookupType.AircraftRegistraions: res = oPlans.d.results.FirstOrDefault(x => x.Aircraft_x0020_Registration == value); break; case LookupType.FlightNumbers: res = oPlans.d.results.FirstOrDefault(x => x.Flight_x0020_Number == value); break; default: break; } if (res != null) { id = res.ID; } return Convert.ToString(id); }
private void GenerateInternal(MasterInfo masterInfo, CsprojSettings csprojSettings) { XDocument?backup = null; XDocument?document = null; try { backup = ReadDocument(masterInfo.ProjectInfo.CsprojPath); document = ReadDocument(masterInfo.ProjectInfo.CsprojPath); ClearFile(masterInfo.ProjectInfo.CsprojPath); ClearDocument(document); FillDocument(document, csprojSettings); WriteDocumentToFile(masterInfo.ProjectInfo.CsprojPath, document); } catch (Exception ex) { document = null; Console.WriteLine("Something goes wrong"); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); throw; } finally { if (backup != null && document == null) { WriteDocumentToFile(masterInfo.ProjectInfo.CsprojPath, backup); } } }
void LoadContentPlaceholders() { drpLoad.Items.Clear(); if (pageInfo.Master.Length > 0) { MasterInfo masterInfo = new MasterInfo(pageInfo.Master); foreach (string contentPlaceholder in masterInfo.GetContentPlaceholders()) { drpLoad.Items.Add(new ListItem("ContentPlaceholder '" + contentPlaceholder + "'", contentPlaceholder)); } } else { drpLoad.Items.Add(new ListItem("Entire page", "")); } }
public int SaveMasterInfo(MasterInfo info) { return(dbConn.Insert(info)); }
public void Start() { if (state != XSensState.NotStarted) { Debug.Log("[XSensGyroscope] Cannot call Start twice! Ignoring...\n"); return; } this.UpdateState(XSensState.Starting); _xda.scanPorts(); Debug.LogFormat("[XSensGyroscope] Found {0} device(s)\n", _xda._DetectedDevices.Count); if (_xda._DetectedDevices.Count > 0) { XsPortInfo portInfo = _xda._DetectedDevices[0]; if (portInfo.deviceId().isMtMk4()) { _xda.openPort(portInfo); MasterInfo ai = new MasterInfo(portInfo.deviceId()); ai.ComPort = portInfo.portName(); ai.BaudRate = portInfo.baudrate(); _measuringDevice = _xda.getDevice(ai.DeviceId); ai.ProductCode = new XsString(_measuringDevice.productCode()); // Print information about detected MTi / MTx / MTmk4 device Debug.LogFormat("[XSensGyroscope] Found a device with id: {0} @ port: {1}, baudrate: {2}\n", _measuringDevice.deviceId().toXsString().toString(), ai.ComPort.toString(), ai.BaudRate); // Create and attach callback handler to device _myMtCallback = new MyMtCallback(); _measuringDevice.addCallbackHandler(_myMtCallback); ConnectedMtData mtwData = new ConnectedMtData(); // connect signals _myMtCallback.DataAvailable += new EventHandler <DataAvailableArgs>(DataAvailable); // Put the device in configuration mode Debug.Log("[XSensGyroscope] Putting device into configuration mode...\n"); if (!_measuringDevice.gotoConfig()) // Put the device into configuration mode before configuring the device { Debug.Log("[XSensGyroscope] Could not put device into configuration mode. Aborting."); this.UpdateState(XSensState.Failed); return; } // Configure the device. Note the differences between MTix and MTmk4 Debug.Log("[XSensGyroscope] Configuring the device...\n"); if (_measuringDevice.deviceId().isMt9c()) { XsOutputMode outputMode = XsOutputMode.XOM_Orientation; // output orientation data XsOutputSettings outputSettings = XsOutputSettings.XOS_OrientationMode_Quaternion; // output orientation data as quaternion XsDeviceMode deviceMode = new XsDeviceMode(100); // make a device mode with update rate: 100 Hz deviceMode.setModeFlag(outputMode); deviceMode.setSettingsFlag(outputSettings); // set the device configuration if (!_measuringDevice.setDeviceMode(deviceMode)) { Debug.Log("[XSensGyroscope] Could not configure MTix device. Aborting."); this.UpdateState(XSensState.Failed); return; } } else if (_measuringDevice.deviceId().isMtMk4()) { XsOutputConfiguration quat = new XsOutputConfiguration(XsDataIdentifier.XDI_Quaternion, 0); XsOutputConfigurationArray configArray = new XsOutputConfigurationArray(); configArray.push_back(quat); if (!_measuringDevice.setOutputConfiguration(configArray)) { Debug.Log("[XSensGyroscope] Could not configure MTmk4 device. Aborting."); this.UpdateState(XSensState.Failed); return; } } else { Debug.Log("[XSensGyroscope] Unknown device while configuring. Aborting."); this.UpdateState(XSensState.Failed); return; } // Put the device in measurement mode Debug.Log("[XSensGyroscope] Putting device into measurement mode...\n"); if (!_measuringDevice.gotoMeasurement()) { Debug.Log("[XSensGyroscope] Could not put device into measurement mode. Aborting."); this.UpdateState(XSensState.Failed); return; } this.UpdateState(XSensState.Started); } } }
private void LoadData(MasterInfo master) { if (master != null) { string name = master.PicName; if (head.ContainsKey(name)) { DDSImage image = new DDSImage(head[name]); pic1.Image = Image.FromHbitmap(image.images[0].GetHbitmap()); } else { if (pic1.Image != null) { pic1.Image.Dispose(); pic1.Image = null; } } txtPic.Text = name; txtId.Text = master.ID.ToString(); txtUnKnow.Text = master.Unknow.ToString(); txtName.Text = master.UnitName; txtAddress.Text = master.Address; txtSheJi.Text = master.SheJi.ToString(); txtGeDou.Text = master.GeDou.ToString(); txtShouBei.Text = master.ShouBei.ToString(); txtFanYin.Text = master.FanYin.ToString(); txtJueXin.Text = master.JueXin.ToString(); txtZhiHui.Text = master.ZhiHui.ToString(); txtFuZuo.Text = master.FuZuo.ToString(); txtTongXun.Text = master.TongXun.ToString(); txtCaoDuo.Text = master.CaoDuo.ToString(); txtWeiXiu.Text = master.WeiXiu.ToString(); txtMeiLi.Text = master.MeiLi.ToString(); txtJinYan.Text = master.JinYan.ToString(); cboGrown.SelectedValue = master.ChengZhang.ToString(); if (cboGrown.SelectedValue == null) { GGCRUtil.AddMasterGrown(master.ChengZhang, "未知" + master.ChengZhang); bindAll(); LoadData(master); return; } cboGuYou1.SelectedValue = master.GuYou1.ToString(); if (cboGuYou1.SelectedValue == null) { GGCRUtil.AddPeopleSkill(master.GuYou1, "未知" + master.GuYou1); bindAll(); LoadData(master); return; } cboGuYou2.SelectedValue = master.GuYou2.ToString(); if (cboGuYou2.SelectedValue == null) { GGCRUtil.AddPeopleSkill(master.GuYou2, "未知" + master.GuYou2); bindAll(); LoadData(master); return; } cboGuYou3.SelectedValue = master.GuYou3.ToString(); if (cboGuYou3.SelectedValue == null) { GGCRUtil.AddPeopleSkill(master.GuYou3, "未知" + master.GuYou3); bindAll(); LoadData(master); return; } cboLast4.SelectedValue = master.Last4.ToString(); if (cboLast4.SelectedValue == null) { GGCRUtil.AddMasterZhaoPin(master.Last4, "未知" + master.Last4); bindAll(); LoadData(master); return; } btnSave.Enabled = true; } else { txtId.Text = null; txtUnKnow.Text = null; txtName.Text = null; txtSheJi.Text = null; txtGeDou.Text = null; txtShouBei.Text = null; txtFanYin.Text = null; txtJueXin.Text = null; txtZhiHui.Text = null; txtFuZuo.Text = null; txtTongXun.Text = null; txtCaoDuo.Text = null; txtWeiXiu.Text = null; txtMeiLi.Text = null; txtJinYan.Text = null; cboGrown.SelectedValue = -1; cboGuYou1.SelectedValue = -1; cboGuYou2.SelectedValue = -1; cboGuYou3.SelectedValue = -1; cboLast4.SelectedValue = -1; btnSave.Enabled = false; } }
public virtual void Initialize(MasterInfo masterInfo, Transform masterObject) { }
public void Generate(MasterInfo masterInfo) { var projectSettings = _csprojSettingsProvider.GenerateProjectSettings(masterInfo); GenerateInternal(masterInfo, projectSettings); }
public MirResult AttackMaster(MasterInfo masterInfo, CancellationTokenSource cancellationTokenSource) { throw new NotImplementedException(); }
public void Start() { if (state != XSensState.NotStarted) { Debug.Log("[XSensGyroscope] Cannot call Start twice! Ignoring...\n"); return; } this.UpdateState(XSensState.Starting); _xda.scanPorts(); Debug.LogFormat("[XSensGyroscope] Found {0} device(s)\n", _xda._DetectedDevices.Count); if (_xda._DetectedDevices.Count > 0) { XsPortInfo portInfo = _xda._DetectedDevices[0]; if (portInfo.deviceId().isMtMk4()) { _xda.openPort(portInfo); MasterInfo ai = new MasterInfo(portInfo.deviceId()); ai.ComPort = portInfo.portName(); ai.BaudRate = portInfo.baudrate(); _measuringDevice = _xda.getDevice(ai.DeviceId); ai.ProductCode = new XsString(_measuringDevice.productCode()); // Print information about detected MTi / MTx / MTmk4 device Debug.LogFormat("[XSensGyroscope] Found a device with id: {0} @ port: {1}, baudrate: {2}\n", _measuringDevice.deviceId().toXsString().toString(), ai.ComPort.toString(), ai.BaudRate); // Create and attach callback handler to device _myMtCallback = new MyMtCallback(); _measuringDevice.addCallbackHandler(_myMtCallback); ConnectedMtData mtwData = new ConnectedMtData(); // connect signals _myMtCallback.DataAvailable += new EventHandler<DataAvailableArgs>(DataAvailable); // Put the device in configuration mode Debug.Log("[XSensGyroscope] Putting device into configuration mode...\n"); if (!_measuringDevice.gotoConfig()) // Put the device into configuration mode before configuring the device { Debug.Log("[XSensGyroscope] Could not put device into configuration mode. Aborting."); this.UpdateState(XSensState.Failed); return; } // Configure the device. Note the differences between MTix and MTmk4 Debug.Log("[XSensGyroscope] Configuring the device...\n"); if (_measuringDevice.deviceId().isMt9c()) { XsOutputMode outputMode = XsOutputMode.XOM_Orientation; // output orientation data XsOutputSettings outputSettings = XsOutputSettings.XOS_OrientationMode_Quaternion; // output orientation data as quaternion XsDeviceMode deviceMode = new XsDeviceMode(100); // make a device mode with update rate: 100 Hz deviceMode.setModeFlag(outputMode); deviceMode.setSettingsFlag(outputSettings); // set the device configuration if (!_measuringDevice.setDeviceMode(deviceMode)) { Debug.Log("[XSensGyroscope] Could not configure MTix device. Aborting."); this.UpdateState(XSensState.Failed); return; } } else if (_measuringDevice.deviceId().isMtMk4()) { XsOutputConfiguration quat = new XsOutputConfiguration(XsDataIdentifier.XDI_Quaternion, 0); XsOutputConfigurationArray configArray = new XsOutputConfigurationArray(); configArray.push_back(quat); if (!_measuringDevice.setOutputConfiguration(configArray)) { Debug.Log("[XSensGyroscope] Could not configure MTmk4 device. Aborting."); this.UpdateState(XSensState.Failed); return; } } else { Debug.Log("[XSensGyroscope] Unknown device while configuring. Aborting."); this.UpdateState(XSensState.Failed); return; } // Put the device in measurement mode Debug.Log("[XSensGyroscope] Putting device into measurement mode...\n"); if (!_measuringDevice.gotoMeasurement()) { Debug.Log("[XSensGyroscope] Could not put device into measurement mode. Aborting."); this.UpdateState(XSensState.Failed); return; } this.UpdateState(XSensState.Started); } } }