private void InitializeScreenMode() { if (String.IsNullOrEmpty(m_locationCode)) { // New mode. m_screenMode = eMode.ADD; CtrlUtil.EnabledControl(true, txtDealingCode, txtDealingName, cboDealingType, cboTermOfPayment, chkAllowNegative); CtrlUtil.EnabledControl(true, txtAddr1Address1, txtAddr1Address2, txtAddr1Address3, txtAddr1Tel, txtAddr1Fax, txtAddr1Email, txtAddr1ContactPerson, txtAddr1Remark); CtrlUtil.EnabledControl(true, txtAddr2Address1, txtAddr2Address2, txtAddr2Address3, txtAddr2Tel, txtAddr2Fax, txtAddr2Email, txtAddr2ContactPerson, txtAddr2Remark); CtrlUtil.EnabledControl(true, txtAddr3Address1, txtAddr3Address3, txtAddr3Address3, txtAddr3Tel, txtAddr3Fax, txtAddr3Email, txtAddr3ContactPerson, txtAddr3Remark); LookupData(); tbShipTo.SelectedTab = tpAddress1; tsbSaveAndNew.Enabled = true; tsbSaveAndClose.Enabled = true; } else { // Edit mode. m_screenMode = eMode.EDIT; CtrlUtil.EnabledControl(true, txtDealingName, cboDealingType, cboTermOfPayment, chkAllowNegative); CtrlUtil.EnabledControl(true, txtAddr1Address1, txtAddr1Address2, txtAddr1Address3, txtAddr1Tel, txtAddr1Fax, txtAddr1Email, txtAddr1ContactPerson, txtAddr1Remark); CtrlUtil.EnabledControl(true, txtAddr2Address1, txtAddr2Address2, txtAddr2Address3, txtAddr2Tel, txtAddr2Fax, txtAddr2Email, txtAddr2ContactPerson, txtAddr2Remark); CtrlUtil.EnabledControl(true, txtAddr3Address1, txtAddr3Address3, txtAddr3Address3, txtAddr3Tel, txtAddr3Fax, txtAddr3Email, txtAddr3ContactPerson, txtAddr3Remark); CtrlUtil.EnabledControl(false, txtDealingCode); tsbSaveAndNew.Enabled = true; tsbSaveAndClose.Enabled = true; } }
/// <summary> /// Checks for notes to avoid before a key change /// </summary> /// <param name="scaleIN"></param> /// <param name="keyChange"></param> /// <param name="chord"></param> /// <param name="modeIN"></param> /// <returns></returns> private bool CheckKeyChangeAvoid(eScale scaleIN, int keyChange, int chord, eMode modeIN) { // Musically, this could be more robust, but essentially checks to make sure a given chord will not sound // bad when changing keys. We change the key early in the generator, so, for example, we don't // want to play the 4th chord in the new key if we're descending, that chord is not shared // between the two keys. // TODO: more intelligent key changes :P int mode = (int)modeIN; //if we're not changing keys, there's nothing to avoid: if (keyChange == 0) { return(true); } bool isNotAvoidNote = true; if (scaleIN == eScale.Major || scaleIN == eScale.HarmonicMajor) { if ((keyChange > 0 && chord == 7 - mode) || (keyChange < 0 && chord == 4 - mode)) { isNotAvoidNote = false; } } else if (scaleIN != 0) { if ((keyChange > 0 && chord == 2 - mode) || (keyChange < 0 && chord == 6 - mode)) { isNotAvoidNote = false; } } return(isNotAvoidNote); }
private void waitForReset() { currentMode = eMode.WAITING; setMode(currentMode); // wait for bootloader timeout for (int i = 3; i > 0; i--) { lblMode.Text = string.Format("WAIT {0}", i); Application.DoEvents(); Thread.Sleep(1000); } // clear out startup message // Grbl 0.7d // '$' to dump current settings while (comPort.BytesToRead > 0) { ReadSerial(); Application.DoEvents(); } currentMode = eMode.READY; setMode(currentMode); }
public void hardReset() { // no actions enabled timerStatusQuery.Enabled = false; customPanel3.Enabled = false; currentMode = eMode.DISCONNECTED; setMode(currentMode); if (workThread != null) { terminateThread(); } cancelled = true; Progress.Value = 0; comPort.DtrEnable = true; Thread.Sleep(100); comPort.DtrEnable = false; waitForReset(); // restore actions customPanel3.Enabled = true; currentMode = eMode.CONNECTED; setMode(currentMode); }
public FormDefineAnalysisCasePallet(eMode mode, double length, double width, double height) { InitializeComponent(); uCtrlCase.Visible = (mode == eMode.PACK_CASE); uCtrlBundle.Visible = (mode == eMode.PACK_BUNDLE); switch (mode) { case eMode.PACK_CASE: { Text = Resources.ID_DEFINECASEPALLETANALYSIS; _uctrlPackable = uCtrlCase; uCtrlCase.Dimensions = new double[] { length, width, height }; uCtrlCase.Weight = 1.0; } break; case eMode.PACK_BUNDLE: { Text = Resources.ID_DEFINEBUNDLEPALLETANALYSIS; _uctrlPackable = uCtrlBundle; uCtrlBundle.Dimensions = new double[] { length, width, height }; uCtrlBundle.UnitWeight = 0.1; uCtrlBundle.NoFlats = 10; } break; default: break; } }
void OnCollisionEnter(Collision coll) { if (invincible) { return; } DamageEffect dEf = coll.gameObject.GetComponent <DamageEffect>(); if (dEf == null) { return; } health -= dEf.damage; invincible = true; invincibleDone = Time.time + invincibleDuration; if (dEf.knockback) { Vector3 delta = transform.position - coll.transform.position; if (Mathf.Abs(delta.x) >= Mathf.Abs(delta.y)) { delta.x = (delta.x > 0) ? 1 : -1; delta.y = 0; } else { delta.x = 0; delta.y = (delta.y > 0) ? 1 : -1; } knockbackVel = delta * knockbackSpeed; rigid.velocity = knockbackVel; mode = eMode.knockback; knockbackDone = Time.time + knockbackDuration; } }
/// <summary> /// Step the state machine /// </summary> public virtual void Step() { // If not in Pause mode, forces pause mode Mode = eMode.Pause; //if (!_bw.IsBusy) //{ // _bw.RunWorkerAsync(); //} if (_workerTask.Status == TaskStatus.RanToCompletion) { _workerTask.Dispose(); _workerTaskCancelSource.Dispose(); _workerTaskCancelSource = new CancellationTokenSource(); _workerTask = new Task(() => RunThread(), _workerTaskCancelSource.Token, TaskCreationOptions.LongRunning); } if (_workerTask.Status == TaskStatus.Created && _workerTask.Status != TaskStatus.Running) { _workerTask.Start(); } else { // Free up current flowItem block _waitHandle.Set(); } }
public Form_EnterData_to_SalesBookInvoice(usrc_FVI_SLO xusrc_FVI_SLO, long Invoice_ID,int FiscalYear, int InvoiceNumber, string xSerialNaumber, string xSetNumber,string xInvoiceNumber, eMode xEmode) { InitializeComponent(); m_usrc_FVI_SLO = xusrc_FVI_SLO; lngRPM.s_SalesBookInvoice.Text(this); m_SerialNumber = xSerialNaumber; m_eMode = xEmode; switch (m_eMode) { case eMode.WRITE: this.lbl_Msg.Text = "Vpišete podatke iz vezane knjige računov za račun:" + FiscalYear.ToString() + "/" + InvoiceNumber.ToString(); txt_SerialNumber.Text = Properties.Settings.Default.Last_SalesBookInvoice_SerialNumber; nm_UpDown_SetNumber.Value = Convert.ToDecimal(Properties.Settings.Default.Last_SalesBookInvoice_SetNumber); txt_InvoiceNumber.Text = m_usrc_FVI_SLO.FURS_InvoiceNumber(InvoiceNumber); this.btn_Write.Text = "Zapiši"; break; case eMode.UPDATE: txt_SerialNumber.Text = m_SerialNumber; try { nm_UpDown_SetNumber.Value = Convert.ToDecimal(xSetNumber); } catch { nm_UpDown_SetNumber.Value = 0; } txt_InvoiceNumber.Text = xInvoiceNumber; this.btn_Write.Text = "Popravi"; this.lbl_Msg.Text = "Popravite podatke iz vezane knjige računov za račun:" + FiscalYear.ToString() + "/" + InvoiceNumber.ToString(); break; } }
public RFEConfiguration(RFEConfiguration objSource) { fStartMHZ = objSource.fStartMHZ; fStepMHZ = objSource.fStepMHZ; fAmplitudeTopDBM = objSource.fAmplitudeTopDBM; fAmplitudeBottomDBM = objSource.fAmplitudeBottomDBM; nFreqSpectrumSteps = objSource.nFreqSpectrumSteps; bExpansionBoardActive = objSource.bExpansionBoardActive; eMode = objSource.eMode; fMinFreqMHZ = objSource.fMinFreqMHZ; fMaxFreqMHZ = objSource.fMaxFreqMHZ; fMaxSpanMHZ = objSource.fMaxSpanMHZ; fRBWKHZ = objSource.fRBWKHZ; fOffset_dB = objSource.fOffset_dB; eCalculator = objSource.eCalculator; nBaudrate = objSource.nBaudrate; eModulation = objSource.eModulation; fThresholdDBM = objSource.fThresholdDBM; bRFEGenHighPowerSwitch = objSource.bRFEGenHighPowerSwitch; nRFEGenPowerLevel = objSource.nRFEGenPowerLevel; fRFEGenCWFreqMHZ = objSource.fRFEGenCWFreqMHZ; nRFEGenSweepWaitMS = objSource.nRFEGenSweepWaitMS; bRFEGenPowerON = objSource.bRFEGenPowerON; bRFEGenStartHighPowerSwitch = objSource.bRFEGenStartHighPowerSwitch; bRFEGenStopHighPowerSwitch = objSource.bRFEGenStopHighPowerSwitch; nRFEGenStartPowerLevel = objSource.nRFEGenStartPowerLevel; nRFEGenStopPowerLevel = objSource.nRFEGenStopPowerLevel; nRFGenSweepPowerSteps = objSource.nRFGenSweepPowerSteps; }
void Update () { if(mode!=before_mode){ Debug.Log ("mode="+mode); switch(mode){ case eMode.Halt: break; case eMode.Fadein: Animation_Standby(); ActionFadeIn();//Fade in break; case eMode.Playing: Animation_PauseOff(); break; case eMode.Fadeout: ActionFadeOut();//Fade out break; default: break; } before_mode = mode; } animinfo = animator.GetCurrentAnimatorStateInfo(0);//Layer 0 if (animinfo.nameHash == Animator.StringToHash("Base Layer.003_NOT01_Final")){ } if(mode==eMode.Playing){ if(animinfo.normalizedTime >1.0f){ mode = eMode.Fadeout; } } }
private void InitializeScreenMode() { if (String.IsNullOrEmpty(m_MasterNo)) { // New mode. m_screenMode = eMode.ADD; CtrlUtil.EnabledControl(true, btnSearchMasterNo, txtPartNo, txtMasterNo, dtStartEffDate, numPrice, cboCurrency, txtRemark); CtrlUtil.EnabledControl(false, txtCustomerName, txtPartNo); LookupData(); tsbSaveAndNew.Enabled = true; tsbSaveAndClose.Enabled = true; CtrlUtil.FocusControl(txtMasterNo); } else { // Edit mode. m_screenMode = eMode.EDIT; CtrlUtil.EnabledControl(true, numPrice, txtRemark); CtrlUtil.EnabledControl(false, btnSearchMasterNo, txtPartNo, txtMasterNo, txtCustomerName, dtStartEffDate, txtPartNo, cboCurrency); tsbSaveAndNew.Enabled = true; tsbSaveAndClose.Enabled = true; CtrlUtil.FocusControl(numPrice); } }
// デバイスをスキャンして接続 public void Connecting(string Address, BLEMgr.Callback Success, BLEMgr.Callback Error, BLEMgr.Callback DisConnectCallback) { m_ConnectSuccess = Success; m_ConnectError = Error; m_DisConnectCallback = DisConnectCallback; m_Mode = eMode.Connecting; m_API.connectBtDevice(Address, () => { m_Mode = eMode.InitSetting; StartCoroutine(InitSetting()); m_API.setCommStsChangedEventHandler(onCommStsChanged); }, () => { m_Mode = eMode.ConnectError; if (m_ConnectError != null) { m_ConnectError(); } m_ConnectSuccess = null; m_ConnectError = null; }); m_connectAddress = Address; }
// private void RunThread(object sender, DoWorkEventArgs e) private void RunThread() { if (!IsRunning) { U.AddThread("State Machine '{0}'", Text); } try { if (!IsRunning) { SetPropValueNoDirty(() => IsRunning, true); Run(); } Mode = eMode.Pause; SetPropValueNoDirty(() => IsRunning, false); } catch (Exception ex) { U.LogPopup(ex, "State Machine '{0}' error", Text); } finally { U.RemoveThread(); } }
private void connect() { if (cbxComPort.Text == "NOPORTS") { MessageBox.Show( "No serial ports are currently available on this system.\n\n" + "1. Connect Grbl controller\n" + "2. Wait a few seconds\n" + "3. Press 'OK'\n" + "4. Choose COM port in dropdown box in statusbar\n" + "5. Retry connect\n", "Serial", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); getSerialPorts(); return; } comPort.PortName = cbxComPort.Text; comPort.BaudRate = 9600; comPort.DtrEnable = false; comPort.NewLine = "\n"; comPort.Open(); currentMode = eMode.CONNECTED; setMode(currentMode); }
void Start() { mode = eMode.ADD_FORCE; start = transform.position; body = GetComponent <Rigidbody>(); }
void Update_ChangeScene() { switch (m_Step) { case eChangeSceneStep.CallVoidScene: //SaveDataMgr.Instance.Save(); SceneManager.LoadScene("SceneChange", LoadSceneMode.Single); m_Step = eChangeSceneStep.UnloadAsset; break; case eChangeSceneStep.UnloadAsset: if (SceneManager.GetActiveScene().name != "SceneChange") { return; } CanvasMgr.Instance.SceneChange(); SpriteBankMgr.Instance.UnloadBankSceneEnd(); Resources.UnloadUnusedAssets(); //AssetBundleMgr.Instance.UnloadUnuseAll(false); //TextureMgr.Instance.UnloadUnuseAll(false); m_Step = eChangeSceneStep.GC; break; case eChangeSceneStep.GC: System.GC.Collect(); m_Step = eChangeSceneStep.End; break; case eChangeSceneStep.End: SceneManager.LoadScene(GameDefine.SceneNameTbl[(int)m_NextScene], LoadSceneMode.Single); m_Mode = eMode.ReadyScene; break; } }
void FixedUpdate() { if (Input.GetKeyDown(KeyCode.Escape)) { mode = eMode.NONE; transform.position = start; body.velocity = Vector3.zero; body.angularVelocity = Vector3.zero; } switch (mode) { case eMode.VELOCITY: body.velocity = 100 * Time.deltaTime * new Vector3( Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); break; case eMode.ADD_FORCE: if (Input.GetButtonDown("Jump")) { body.AddForce(20000 * Time.deltaTime * Vector3.up, ForceMode.Impulse); } Vector3 force = new Vector3( Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); body.AddForce(1000 * Time.deltaTime * force, ForceMode.Impulse); break; case eMode.ADD_TORQUE: Vector3 torque = 10000 * Time.deltaTime * Vector3.up; body.AddTorque(torque); break; } }
override protected void Update() { base.Update(); switch (mode) { case eMode.search: // Check whether Dray is in the same room if (dray.roomNum != inRm.roomNum) { return; } float moveAmt; if (Mathf.Abs(dray.roomPos.x - inRm.roomPos.x) < sensorRange) { // Attack Vertically moveAmt = dray.roomPos.y - inRm.roomPos.y; p1 = p0 = transform.position; p1.y += moveAmt; mode = eMode.attack; } if (Mathf.Abs(dray.roomPos.y - inRm.roomPos.y) < sensorRange) { // Attack Horizontally moveAmt = dray.roomPos.x - inRm.roomPos.x; p1 = p0 = transform.position; p1.x += moveAmt; mode = eMode.attack; } break; } }
public RFEConfiguration() { fStartMHZ = 0.0; fStepMHZ = 0.0; fAmplitudeTopDBM = 0.0; fAmplitudeBottomDBM = 0.0; nFreqSpectrumSteps = 0; bExpansionBoardActive = false; eMode = eMode.MODE_NONE; fMinFreqMHZ = 0.0; fMaxFreqMHZ = 0.0; fMaxSpanMHZ = 0.0; fRBWKHZ = 0.0; fOffset_dB = 0.0f; nBaudrate = 0; eModulation = eModulation.MODULATION_NONE; fThresholdDBM = 0.0f; nRFEGenSweepWaitMS = 0; bRFEGenHighPowerSwitch = false; nRFEGenPowerLevel = 0; fRFEGenCWFreqMHZ = 0.0; bRFEGenPowerON = false; bRFEGenStartHighPowerSwitch = false; bRFEGenStopHighPowerSwitch = false; nRFEGenStartPowerLevel = 0; nRFEGenStopPowerLevel = 1; nRFGenSweepPowerSteps = 0; eCalculator = eCalculator.UNKNOWN; }
public void Scan(BLEMgr.Callback Success, BLEMgr.Callback Error) { m_Mode = eMode.Scan; m_ScanSuccess = Success; m_ScanError = Error; m_API.scanBtDevice(() => { m_Mode = eMode.ScanOK; if (m_ScanSuccess != null) { m_ScanSuccess(); } m_ScanSuccess = null; m_ScanError = null; }, () => { m_Mode = eMode.ScanError; if (m_ScanError != null) { m_ScanError(); } m_ScanSuccess = null; m_ScanError = null; }); }
private void BtnRunClick(object sender, EventArgs e) { // need to have a loaded gcode file if (listBoxGcode.Items.Count == 0) { return; } // copy of gcode for use in thread gcode = new List <object>(); foreach (object o in listBoxGcode.Items) { // TODO fix this better // any other modal codes to be checked here? if (o.ToString().Contains("G20")) { // use inches in UpdatePositionLEDS() // G20set = true; } gcode.Add(o); } currentMode = eMode.RUNNING; setMode(currentMode); }
public DialogFile(eMode mode, string defaultFolderPath, string defaultFileName, string title, int titlefontsize = 16) { Mode = mode; Title = title; TitleFontSize = titlefontsize; DefaultFolderPath = defaultFolderPath; DefaultFileName = defaultFileName; }
void LateUpdate() { // Get the half-grid location of this GameObject Vector2 rPos = GetRoomPosOnGrid(0.5f); // Forces half-grid // Check to see whether we're in a Door tile int doorNum; for (doorNum = 0; doorNum < 4; doorNum++) { if (rPos == InRoom.DOORS[doorNum]) { break; } } if (doorNum > 3 || doorNum != facing) { return; } // Move to the next room Vector2 rm = roomNum; switch (doorNum) { case 0: rm.x += 1; break; case 1: rm.y += 1; break; case 2: rm.x -= 1; break; case 3: rm.y -= 1; break; } // Make sure that the rm we want to jump to is valid if (rm.x >= 0 && rm.x <= InRoom.MAX_RM_X) { if (rm.y >= 0 && rm.y <= InRoom.MAX_RM_Y) { roomNum = rm; transitionPos = InRoom.DOORS[(doorNum + 2) % 4]; roomPos = transitionPos; lastSafeLoc = transform.position; lastSafeFacing = facing; mode = eMode.transition; transitionDone = Time.time + transitionDelay; } } }
private void FixedUpdate() { if (!Mathf.Approximately(nav.speed, speed) || !Mathf.Approximately(nav.angularSpeed, angularSpeed)) { nav.speed = speed; nav.angularSpeed = angularSpeed; } pathTime += Time.fixedDeltaTime; Vector3 preTurnRight = transform.right; switch (mode) { case eMode.idle: break; case eMode.wait: // Are we still waiting? if (pathTime < waitUntil) { break; } // We've waited long enough, move on to the next Waypoint. MoveToNextWaypoint(); break; case eMode.preMoveRot: Vector3 goalPos = waypoints[wpNum].pos; if (RotateTowards(goalPos, angularSpeed * Time.fixedDeltaTime)) { nav.isStopped = false; nav.updatePosition = true; mode = eMode.move; } break; case eMode.move: // Navigate towards the waypoint. if (!nav.pathPending && nav.remainingDistance <= nav.stoppingDistance) { mode = eMode.postMoveRot; } break; case eMode.postMoveRot: if (RotateTowards(transform.position + waypoints[wpNum].fwd, angularSpeed * Time.fixedDeltaTime)) { waitUntil = pathTime + waypoints[wpNum].waitTime; mode = eMode.wait; } break; default: break; } }
void LateUpdate() { // Get the half-grid location of this GameObject Vector2 rPos = GetRoomPosOnGrid(0.5f); // Forces half-grid // c // Check to see whether we're in a Door tile int doorNum; for (doorNum = 0; doorNum < 4; doorNum++) { if (rPos == InRoom.DOORS[doorNum]) { break; // d } } if (doorNum > 3 || doorNum != facing) { return; // e } // Move to the next room Vector2 rm = roomNum; switch (doorNum) { // f case 0 : rm.x += 1; break; case 1: rm.y += 1; break; case 2: rm.x -= 1; break; case 3: rm.y -= 1; break; } // Make sure that the rm we want to jump to is valid if(rm.x >= 0 && rm.x <= InRoom.MAX_RM_X) { // g if(rm.y >= 0 && rm.y <= InRoom.MAX_RM_Y) { roomNum = rm; transitionPos = InRoom.DOORS[(doorNum + 2) % 4]; // h roomPos = transitionPos; mode = eMode.transition; // i transitionDone = Time.time + transitionDelay; } } }
public void Attack() { if (Time.time >= timeAttackNext) { mode = eMode.attack; timeAttackDone = Time.time + attackDuration; timeAttackNext = Time.time + attackDelay; } }
void MoveToWaypoint(int num) { //wpNum = num; //nav.SetDestination(waypoints[wpNum].pos); //nav.isStopped = true; //nav.updatePosition = false; mode = eMode.move; }
void MoveToWaypoint(int num) { wpNum = num; nav.SetDestination(waypoints[wpNum].pos); nav.isStopped = true; nav.updatePosition = false; mode = eMode.preMoveRot; }
public bool ProcessReceivedString(string sLine) { bool bOk = true; try { sLineString = sLine; if ((sLine.Length >= 60) && (sLine.Substring(0, 6) == "#C2-F:")) { //Spectrum Analyzer mode fStartMHZ = Convert.ToInt32(sLine.Substring(6, 7)) / 1000.0; //note it comes in KHZ fStepMHZ = Convert.ToInt32(sLine.Substring(14, 7)) / 1000000.0; //Note it comes in HZ fAmplitudeTopDBM = Convert.ToInt32(sLine.Substring(22, 4)); fAmplitudeBottomDBM = Convert.ToInt32(sLine.Substring(27, 4)); nFreqSpectrumSteps = Convert.ToUInt16(sLine.Substring(32, 4)); bExpansionBoardActive = (sLine[37] == '1'); eMode = (eMode)Convert.ToUInt16(sLine.Substring(39, 3)); fMinFreqMHZ = Convert.ToInt32(sLine.Substring(43, 7)) / 1000.0; fMaxFreqMHZ = Convert.ToInt32(sLine.Substring(51, 7)) / 1000.0; fMaxSpanMHZ = Convert.ToInt32(sLine.Substring(59, 7)) / 1000.0; if (sLine.Length > 66) { fRBWKHZ = Convert.ToInt32(sLine.Substring(67, 5)); } if (sLine.Length > 72) { fOffset_dB = Convert.ToInt32(sLine.Substring(73, 4)); } } else if ((sLine.Length >= 39) && (sLine.Substring(0, 6) == "#C3-G:")) { //Signal generator mode fStartMHZ = Convert.ToInt32(sLine.Substring(6, 7)) / 1000.0; //note it comes in KHZ fRFEGenCWFreqMHZ = Convert.ToInt32(sLine.Substring(14, 7)) / 1000.0; //Note it comes in KHZ nFreqSpectrumSteps = Convert.ToUInt16(sLine.Substring(22, 4)); fStepMHZ = Convert.ToInt32(sLine.Substring(27, 7)) / 1000.0; //Note it comes in KHZ bRFEGenHighPowerSwitch = (sLine[35] == '1'); nRFEGenPowerLevel = Convert.ToByte(sLine[37] - 0x30); bRFEGenPowerON = (sLine[39] == '1'); nRFEGenSweepWaitMS = 0; eMode = eMode.MODE_NONE; } else { bOk = false; } } catch (Exception) { bOk = false; } return(bOk); }
/// <summary> /// Reset all values to default /// </summary> public void Reset() { _mmX = 0.0; _mmY = 0.0; _mmZ = 0.0; _yaw = 0.0; _xyyawMode = eMode.Relative; _zMode = eMode.Relative; }
void OnTriggerEnter(Collider colld) { Enemy e = colld.GetComponent <Enemy>(); if (e == null) { return; } mode = eMode.gInMiss; }
private void OnTriggerEnter(Collider other) { Enemy e = other.GetComponent <Enemy>(); if (e == null) { return; } mode = eMode.gInMiss; }
public RFEConfiguration(RFEConfiguration objSource) { fStartMHZ = objSource.fStartMHZ; fStepMHZ = objSource.fStepMHZ; fAmplitudeTopDBM = objSource.fAmplitudeTopDBM; fAmplitudeBottomDBM = objSource.fAmplitudeBottomDBM; nFreqSpectrumSteps = objSource.nFreqSpectrumSteps; bExpansionBoardActive = objSource.bExpansionBoardActive; eMode = objSource.eMode; fMinFreqMHZ = objSource.fMinFreqMHZ; fMaxFreqMHZ = objSource.fMaxFreqMHZ; fMaxSpanMHZ = objSource.fMaxSpanMHZ; fRBWKHZ = objSource.fRBWKHZ; fOffset_dB = objSource.fOffset_dB; bRFEGenHighPowerSwitch = objSource.bRFEGenHighPowerSwitch; nRFEGenPowerLevel = objSource.nRFEGenPowerLevel; fRFEGenCWFreqMHZ = objSource.fRFEGenCWFreqMHZ; nRFEGenSweepWaitMS = objSource.nRFEGenSweepWaitMS; bRFEGenPowerON = objSource.bRFEGenPowerON; }
public RFEConfiguration() { fStartMHZ = 0.0; fStepMHZ = 0.0; fAmplitudeTopDBM = 0.0; fAmplitudeBottomDBM = 0.0; nFreqSpectrumSteps = 0; bExpansionBoardActive = false; eMode = eMode.MODE_NONE; fMinFreqMHZ = 0.0; fMaxFreqMHZ = 0.0; fMaxSpanMHZ = 0.0; fRBWKHZ = 0.0; fOffset_dB = 0.0f; nRFEGenSweepWaitMS = 0; bRFEGenHighPowerSwitch=false; nRFEGenPowerLevel = 0; fRFEGenCWFreqMHZ = 0.0; bRFEGenPowerON = false; }
public frmViewer(){ InitializeComponent(); getSerialPorts(); mViewer = this.MG_Viewer1; mProcessor.OnAddBlock += new clsProcessor.OnAddBlockEventHandler(mProcessor_OnAddBlock); MG_CS_BasicViewer.OnSelection += new MG_CS_BasicViewer.OnSelectionEventHandler(mViewer_OnSelection); MG_CS_BasicViewer.MouseLocation += new MG_CS_BasicViewer.MouseLocationEventHandler(mViewer_MouseLocation); mSetup.MachineActivated+=new clsSettings.MachineActivatedEventHandler(mSetup_MachineActivated); mSetup.LoadAllMachines(System.IO.Directory.GetCurrentDirectory() + "\\Data"); mProcessor.Init(mSetup.Machine); cancelled = false; workThread = null; sw = new Stopwatch(); currentMode = eMode.DISCONNECTED; setMode(currentMode); UpdateInterval = 200; // 5 updates sec doStatusUpdates = false; // when enabled feedHold = false; }
private void but_Bill_Click(object sender, EventArgs e) { //checkout mode mode = eMode.eCheckout; //clear tea and waiter tea_status = eTea.eClear; waiter_status = eWaiter.eClear; teaWaiterStatusCheck(); DialogResult result= MessageBox.Show(this,"The system is now in checkout mode. To exist checkout mode, press OK.", "Checkout Mode"); if (result == DialogResult.OK) { mode = eMode.eOperational; } }
private void CancelButtont_Click(object sender, EventArgs e) { CancelButton.BackColor = Color.DarkGray; t = new System.Timers.Timer(5000); t.Elapsed += new ElapsedEventHandler(t_Elapsed); t.AutoReset = false; t.Enabled = true; mode = eMode.eCancel; }
private void waitForReset() { currentMode = eMode.WAITING; setMode(currentMode); // wait for bootloader timeout for(int i=3; i> 0; i--) { lblMode.Text = string.Format("WAIT {0}", i); Application.DoEvents(); Thread.Sleep(1000); } // clear out startup message // Grbl 0.7d // '$' to dump current settings while(comPort.BytesToRead > 0) { ReadSerial(); Application.DoEvents(); } currentMode = eMode.READY; setMode(currentMode); }
private void AccessForm( string action, string formText, Color textColor ) { switch ( action ) { case "AppendToMonitorTextBox": // Append text to the rtbMonitor textbox using the color for received data. //rtbMonitor.AppendText(formText); str_rfid += formText; if (str_rfid.Length > 13) { switch (mode) { //operational mode case eMode.eOperational: if (str_rfid.Contains("4B00DA17F573")) { DisplayStatus("", textColor); Order new_item = new Order(Order.eSize.eSmall, quantity, orderID); order_list.Add(new_item); // OrderListBox.SelectedIndex = OrderListBox.Items.Count - 1; // rtbMonitor.AppendText(DSSmall.getQuantity() + "\t" + DSSmall.getSizeString() // + "\t\t" + new_item.getPrice() + "\n"); // stack.Push(DSSmall); } else if (str_rfid.Contains("4800E50372DC")) { DisplayStatus("", textColor); Order new_item = new Order(Order.eSize.eMedium, quantity, orderID); order_list.Add(new_item); //OrderListBox.SelectedIndex = OrderListBox.Items.Count -1; //rtbMonitor.AppendText(new_item.getQuantity() + "\t" + new_item.getSizeString() // + "\t" + new_item.getPrice() + "\n"); // stack.Push(new_item); } else if (str_rfid.Contains("4B00DA60DB2A")) { DisplayStatus("", textColor); Order new_item = new Order(Order.eSize.eLarge, quantity, orderID); order_list.Add(new_item); // OrderListBox.SelectedIndex = OrderListBox.Items.Count - 1; //probably don't need this line //rtbMonitor.AppendText(new_item.getQuantity() + "\t" + new_item.getSizeString() // + "\t\t" + new_item.getPrice() + "\n"); //stack.Push(new_item); } else { DisplayStatus("Invalid Card. Please scan again.\n" + str_rfid, textColor); } orderID++; OrderListBox.DataSource = order_list.toStringList(); if (order_list.Count != 0) { OrderListBox.SetSelected(0, false); } OrderListBox.Refresh(); break; //cancel mode case eMode.eCancel: string card_of_interest = ""; int i = 0; int del = order_list.Count-1; foreach (Order n in order_list) { if (OrderListBox.GetSelected(i)) { switch (n.getSize()) { case Order.eSize.eSmall: card_of_interest = "4B00DA17F573"; break; case Order.eSize.eMedium: card_of_interest = "4800E50372DC"; break; case Order.eSize.eLarge: card_of_interest = "4B00DA60DB2A"; break; default: Console.WriteLine("ERROR: INVALID CARD"); break; } if (str_rfid.Contains("4B00DA47EA3C")|| str_rfid.Contains(card_of_interest)) { CancelButton.BackColor = Color.LightGray; mode = eMode.eOperational; if (quantity < n.getQuantity()) { n.setQuantity(n.getQuantity() - quantity); } else { order_list.RemoveAt(del); } OrderListBox.DataSource = order_list.toStringList(); OrderListBox.Refresh(); if (order_list.Count != 0) { OrderListBox.SetSelected(0, false); } break; } else { DisplayStatus("Invalid Card. Please scan again.\n", textColor); return; } } i++; del--; } break; case eMode.eCheckout: //disable all use break; default: Console.WriteLine("INVALID MODE"); break; } //reset text str_rfid = ""; txtQuantity.Clear(); quantity = 1; sub_total = order_list.getTotalPrice(); bill_total = sub_total*1.13; item_total = order_list.getTotalQuantity(); Console.WriteLine("TOTAL: " + bill_total); Console.WriteLine("SUBTOTAL: " + sub_total); Console.WriteLine("Total Item: " + item_total); totalSum.Text = "Subtotal: $" + sub_total + "\n" + "Total:$" + bill_total.ToString("0.00") + "\n" + "Total # of Items: " + item_total; } // Return to the default color. //rtbMonitor.SelectionColor = colorTransmit; // Trim the textbox's contents if needed. /* if ( rtbMonitor.TextLength > maximumTextBoxLength ) { TrimTextBoxContents(); } */ break; case "DisplayStatus": // Add text to the rtbStatus textbox using the specified color. DisplayStatus( formText, textColor ); break; case "DisplayCurrentSettings": // Display the current port settings in the ToolStripStatusLabel. DisplayCurrentSettings(); break; default: break; } }
private void BtnRunClick(object sender, EventArgs e) { // need to have a loaded gcode file if(listBoxGcode.Items.Count == 0) return; // copy of gcode for use in thread gcode = new List<object>(); foreach(object o in listBoxGcode.Items) { // TODO fix this better // any other modal codes to be checked here? if(o.ToString().Contains("G20")) { // use inches in UpdatePositionLEDS() // G20set = true; } gcode.Add(o); } currentMode = eMode.RUNNING; setMode(currentMode); }
private void SwitchMode(eMode mode) { mTicks = DateTime.Now; mMode = mode; switch (mMode) { case eMode.MODE_NULL: // do nothing break; case eMode.MODE_INIT: mSupportedPids = 0; mNeedInit = true; if (mPrefs.Interface == eInterface.INTERFACE_MULTIPLEX) SwitchMode(eMode.MODE_READ_PIDS); else SendAsciiElm("ATZ\r"); OBDSensor.GetSingleton().SensorUpdateStatus("Initializing..."); break; case eMode.MODE_SET_TIMEOUT: SendSetTimeout(); break; case eMode.MODE_ECHO_OFF: SendAsciiElm("ATE0\r"); break; case eMode.MODE_LINEFEED_OFF: SendAsciiElm("ATL0\r"); break; case eMode.MODE_READ_PIDS: SendPidQuery(); break; case eMode.MODE_READ_SENSORS: break; case eMode.MODE_READ_MIL: break; case eMode.MODE_READ_ACTIVE_CODES: SendActiveCodeQuery(); break; case eMode.MODE_READ_PENDING_CODES: SendPendingCodeQuery(); break; case eMode.MODE_CLEAR_CODES: SendClearCodesCommand(); break; } }
private void connect() { if(cbxComPort.Text == "NOPORTS") { MessageBox.Show( "No serial ports are currently available on this system.\n\n" + "1. Connect Grbl controller\n" + "2. Wait a few seconds\n" + "3. Press 'OK'\n" + "4. Choose COM port in dropdown box in statusbar\n" + "5. Retry connect\n", "Serial", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); getSerialPorts(); return; } comPort.PortName = cbxComPort.Text; comPort.BaudRate = 9600; comPort.DtrEnable = false; comPort.NewLine = "\n"; comPort.Open(); currentMode = eMode.CONNECTED; setMode(currentMode); }
private void Set_Item_Mode(eMode xeMode) { Mode = xeMode; switch (Mode) { case eMode.STOCK_AND_FACTORY: m_Arrangement.Set(0, btn_Stock, nmUpDn_StockQuantity, true); m_Arrangement.Set(1, btn_NoStock, nmUpDn_FactoryQuantity, true); this.BackColor = DefaultColor; break; case eMode.STOCK: m_Arrangement.Set(0, btn_Stock, nmUpDn_StockQuantity, true); m_Arrangement.Set(1, btn_NoStock, nmUpDn_FactoryQuantity, false); this.BackColor = DefaultColor; break; case eMode.FACTORY: m_Arrangement.Set(0, btn_Stock, nmUpDn_StockQuantity, false); m_Arrangement.Set(0, btn_NoStock, nmUpDn_FactoryQuantity, true); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192))))); break; } }
void cb_FadeOut_Complete(){ mode = eMode.Fadein; Debug.Log ("Fadeout Complete."); }
public void hardReset() { // no actions enabled timerStatusQuery.Enabled = false; customPanel3.Enabled = false; currentMode = eMode.DISCONNECTED; setMode(currentMode); if(workThread != null) terminateThread(); cancelled = true; Progress.Value = 0; comPort.DtrEnable = true; Thread.Sleep(100); comPort.DtrEnable = false; waitForReset(); // restore actions customPanel3.Enabled = true; currentMode = eMode.CONNECTED; setMode(currentMode); }
void cb_FadeIn_Complete(){ mode = eMode.Playing; }
public void SetMode( eMode mode ) { Logger.Write("setMode: " + mode.ToString()); Mode = mode; SetSwapByCurrentMode(); }
//Mode - Figure Select private void tsSelect_Click(object sender, EventArgs e) { tsCross.Checked = false; tsLine.Checked = false; tsCircle.Checked = false; tsSelect.Checked = true; tsRect.Checked = false; mode = eMode.modeSelect; }
void t_Elapsed(object sender, ElapsedEventArgs e) { CancelButton.BackColor = Color.LightGray; mode = eMode.eOperational; if (t != null) { t.Dispose(); } }
private void BtnDisconnectClick(object sender, EventArgs e) { disconnect(); currentMode = eMode.DISCONNECTED; setMode(currentMode); }
public bool ProcessReceivedString(bool bProcessAllEvents, out string sReceivedString) { bool bDraw = false; sReceivedString = ""; try { do { bool bWrongFormat = false; object objNew = null; long nCount = 0; try { Monitor.Enter(m_arrReceivedData); nCount = m_arrReceivedData.Count; if (nCount == 0) break; objNew = m_arrReceivedData.Dequeue(); } catch (Exception obEx) { ReportLog("m_arrReceivedStrings processing: " + obEx.ToString()); } finally { Monitor.Exit(m_arrReceivedData); } if (objNew.GetType() == typeof(RFEConfiguration)) { RFEConfiguration objConfiguration = (RFEConfiguration)objNew; ReportLog("Received configuration: " + objConfiguration.sLineString); if (m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB == null) { //request internal calibration data, if available SendCommand("Cq"); } if (IsGenerator()) { //signal generator RFGenStartFrequencyMHZ = objConfiguration.fStartMHZ; RFGenStepFrequencyMHZ = objConfiguration.fStepMHZ; RFGenCWFrequencyMHZ = objConfiguration.fRFEGenCWFreqMHZ; RFGenSweepSteps = objConfiguration.nFreqSpectrumSteps; RFGenStopFrequencyMHZ = RFGenStartFrequencyMHZ + RFGenSweepSteps * RFGenStepFrequencyMHZ; RFGenPowerON = objConfiguration.bRFEGenPowerON; RFGenPowerLevel = objConfiguration.nRFEGenPowerLevel; RFGenHighPowerSwitch = objConfiguration.bRFEGenHighPowerSwitch; MaxFreqMHZ = 6000; MinFreqMHZ = 23.438; RFGenStepWaitMS = objConfiguration.nRFEGenSweepWaitMS; OnReceivedConfigurationData(new EventArgs()); } else { //spectrum analyzer if ((Math.Abs(StartFrequencyMHZ - objConfiguration.fStartMHZ) >= 0.001) || (Math.Abs(StepFrequencyMHZ - objConfiguration.fStepMHZ) >= 0.001)) { StartFrequencyMHZ = objConfiguration.fStartMHZ; StepFrequencyMHZ = objConfiguration.fStepMHZ; ReportLog("New Freq range - buffer cleared."); } AmplitudeTopDBM = objConfiguration.fAmplitudeTopDBM; AmplitudeBottomDBM = objConfiguration.fAmplitudeBottomDBM; FreqSpectrumSteps = objConfiguration.nFreqSpectrumSteps; m_bExpansionBoardActive = objConfiguration.bExpansionBoardActive; if (m_bExpansionBoardActive) { m_eActiveModel = m_eExpansionBoardModel; if (ExpansionBoardModel == RFECommunicator.eModel.MODEL_WSUB3G) { //If it is a MODEL_WSUB3G, make sure we use the MAX HOLD mode to account for proper DSP Thread.Sleep(500); if (m_bUseMaxHold) { ReportLog("Updated remote mode to Max Hold for reliable DSP calculations with fast signals"); SendCommand_SetMaxHold(); } else { ReportLog("Remote mode is not Max Hold, some fast signals may not be detected"); SendCommand_Realtime(); } } } else { m_eActiveModel = m_eMainBoardModel; } m_eMode = objConfiguration.eMode; MinFreqMHZ = objConfiguration.fMinFreqMHZ; MaxFreqMHZ = objConfiguration.fMaxFreqMHZ; MaxSpanMHZ = objConfiguration.fMaxSpanMHZ; m_fRBWKHZ = objConfiguration.fRBWKHZ; m_fOffset_dB = objConfiguration.fOffset_dB; if ((m_eActiveModel == eModel.MODEL_2400) || (m_eActiveModel == eModel.MODEL_6G)) { MinSpanMHZ = 2.0; } else { MinSpanMHZ = 0.112; } if (objConfiguration.nFreqSpectrumSteps == 13) { m_eMode = RFECommunicator.eMode.MODE_WIFI_ANALYZER; } else { m_eMode = RFECommunicator.eMode.MODE_SPECTRUM_ANALYZER; } OnReceivedConfigurationData(new EventArgs()); } } else if (objNew.GetType() == typeof(RFESweepData)) { if (m_eMode == eMode.MODE_TRACKING) { if (m_bTrackingNormalizing) { if (m_SweepTrackingNormalizedContainer == null) m_SweepTrackingNormalizedContainer = new RFESweepDataCollection(3,true); RFESweepData objSweep=(RFESweepData)objNew; m_SweepTrackingNormalizedContainer.Add(objSweep); bool bWrongData=objSweep.GetAmplitudeDBM(objSweep.GetMinStep())<=MIN_AMPLITUDE_TRACKING_NORMALIZE; if (bWrongData || ((m_nAutoStopSNATrackingCounter != 0) && (m_SweepTrackingNormalizedContainer.Count >= m_nAutoStopSNATrackingCounter))) { StopTracking(); if (bWrongData) //invalid data, end so it can be restarted m_SweepTrackingNormalized = objSweep; else //if all samples collected, end and get average among them m_SweepTrackingNormalized = m_SweepTrackingNormalizedContainer.GetAverage(0, m_SweepTrackingNormalizedContainer.Count - 1); OnUpdateDataTrakingNormalization(new EventArgs()); } } else { RFESweepData objSweep = (RFESweepData)objNew; m_TrackingDataContainer.Add(objSweep); bDraw = true; OnUpdateDataTraking(new EventArgs()); if ((m_nAutoStopSNATrackingCounter != 0) && (m_nTrackingPass > m_nAutoStopSNATrackingCounter)) { StopTracking(); } } } else { if (!HoldMode) { RFESweepData objSweep = (RFESweepData)objNew; m_SweepDataContainer.Add(objSweep); bDraw = true; if (m_SweepDataContainer.IsFull()) { HoldMode = true; OnUpdateFeedMode(new EventArgs()); ReportLog("RAM Buffer is full."); } m_sSweepInfoText = "Captured:" + objSweep.CaptureTime.ToString("yyyy-MM-dd HH:mm:ss\\.fff"); TimeSpan objSpan = new TimeSpan(); objSpan = objSweep.CaptureTime - m_LastCaptureTime; if (objSpan.TotalSeconds < 60) { //if time between captures is less than 60 seconds, we can assume we are getting realtime data //and therefore can provide average sweep/seconds information, otherwise we were in hold or something //and data could not be used for these calculations. m_nAverageSweepSpeedIterator++; m_spanAverageSpeedAcumulator += (objSweep.CaptureTime - m_LastCaptureTime); if (m_fAverageSweepTime > 0.0) { m_sSweepInfoText += "\nSweep time: " + m_fAverageSweepTime.ToString("0.000") + " seconds - Avg Sweeps/second: " + (1.0 / m_fAverageSweepTime).ToString("0.0"); } if (m_nAverageSweepSpeedIterator >= 10) { m_fAverageSweepTime = m_spanAverageSpeedAcumulator.TotalSeconds / m_nAverageSweepSpeedIterator; m_nAverageSweepSpeedIterator = 0; m_spanAverageSpeedAcumulator = m_LastCaptureTime - m_LastCaptureTime; //set it to zero and start average all over again } } m_LastCaptureTime = objSweep.CaptureTime; OnUpdateData(new EventArgs()); } else { //if in hold mode, we just record last time came here to make sure we start from most reliable point in time m_LastCaptureTime = DateTime.Now; } } } else if (objNew.GetType() == typeof(RFEScreenData)) { if ((CaptureRemoteScreen) && (m_ScreenDataContainer.IsFull() == false)) { RFEScreenData objScreen = (RFEScreenData)objNew; objScreen.Model = ActiveModel; m_ScreenDataContainer.Add(objScreen); ScreenIndex = (UInt16)m_ScreenDataContainer.UpperBound; OnUpdateRemoteScreen(new EventArgs()); } else { //receiving Screen Dump data but it was intended to be disabled, resend a disable command now SendCommand("D0"); } } else { //received a string, so use it along to parse parameters string sLine = (string)objNew; sReceivedString = sLine; if ((sLine.Length > 3) && (sLine.Substring(0, 4) == _Acknowldedge)) { m_bAcknowledge = true; } else if ((sLine.Length > 16) && (sLine.Substring(0, 3) == "#Sn")) { m_sSerialNumber = sLine.Substring(3, 16); ReportLog("Device serial number: " + SerialNumber); } else if((sLine.Length > 2) && (sLine.Substring(0, 2) == "$q")) { //calibration data UInt16 nSize=Convert.ToUInt16(sLine[2]); if (IsGenerator()) { //signal generator uses a different approach for storing absolute amplitude value offset over an ideal -30dBm response if ((m_arrSignalGeneratorEmbeddedCalibrationActual30DBM == null) || (m_arrSignalGeneratorEmbeddedCalibrationActual30DBM.Length != nSize)) { m_arrSignalGeneratorEmbeddedCalibrationActual30DBM = new double[nSize]; for (int nInd = 0; nInd < nSize; nInd++) { m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd] = -30.0; } //Values using 10*delta from the value delivered when compared with 30dBm. //For instance if value delivered for a frequency is -28.5dBm, that is a +1.5dB difference //therefore a 1.5*10=15 value. If the value delivered is -33.2 that is a -3.2dB difference //therefore a -32 value. string sData = "Embedded calibration Signal Generator data received:"; for (int nInd = 0; nInd < nSize; nInd++) { m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd] = -30.0 + Convert.ToInt16(sLine[nInd + 3]) / 10.0; sData += m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd].ToString(); if (nInd < nSize - 1) sData += ","; } ReportLog(sData); } } else { if ((m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB == null) || (m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB.Length != nSize)) { m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB = new float[nSize]; for (int nInd = 0; nInd < nSize; nInd++) { m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB[nInd] = 0.0f; } } if (m_eActiveModel == eModel.MODEL_6G) { string sData = "Embedded calibration Spectrum Analyzer data received:"; for (int nInd = POS_EMBEDDED_CALIBRATED_6G; nInd < nSize; nInd++) { int nVal = Convert.ToInt32(sLine[nInd + 3]); if (nVal > 127) nVal = -(256 - nVal); //get the right sign m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB[nInd] = nVal / 2.0f; //split by two to get dB sData += m_arrSpectrumAnalyzerEmbeddedCalibrationOffsetDB[nInd].ToString(); if (nInd < nSize - 1) sData += ","; } ReportLog(sData); } } } else if ((sLine.Length > 18) && (sLine.Substring(0, 18) == _ResetString)) { //RF Explorer device was reset for some reason, reconfigure client based on new configuration OnDeviceResetEvent(new EventArgs()); } else if ((sLine.Length > 5) && sLine.Substring(0, 6) == "#C2-M:") { ReportLog("Received RF Explorer device model info:" + sLine); m_eMainBoardModel = (eModel)Convert.ToUInt16(sLine.Substring(6, 3)); m_eExpansionBoardModel = (eModel)Convert.ToUInt16(sLine.Substring(10, 3)); m_sRFExplorerFirmware = (sLine.Substring(14, 5)); OnReceivedDeviceModel(new EventArgs()); } else if ((sLine.Length > 5) && sLine.Substring(0, 6) == "#C3-M:") { ReportLog("Received RF Explorer Generator device info:" + sLine); m_eMainBoardModel = (eModel)Convert.ToUInt16(sLine.Substring(6, 3)); m_eExpansionBoardModel = (eModel)Convert.ToUInt16(sLine.Substring(10, 3)); m_sRFExplorerFirmware = (sLine.Substring(14, 5)); OnReceivedDeviceModel(new EventArgs()); } else if ((sLine.Length > 2) && sLine.Substring(0, 3) == "#K1") { ReportLog("RF Explorer is now in TRACKING mode."); m_eMode = eMode.MODE_TRACKING; } else if ((sLine.Length > 2) && sLine.Substring(0, 3) == "#K0") { ReportLog("RF Explorer is now in ANALYZER mode."); m_eMode = eMode.MODE_SPECTRUM_ANALYZER; } else if ((sLine.Length > 2) && (sLine.Substring(0, 2) == "$S") && (StartFrequencyMHZ > 0.1)) { bWrongFormat = true; } #if SUPPORT_EXPERIMENTAL else if ((sLine.Length > 2) && sLine.Substring(0, 2) == "$R") { if (!HoldMode && m_nRAWSnifferIndex < m_nTotalBufferSize) { if (m_arrRAWSnifferData == null) { //don't allocate memory for this object before actually required as most users may not need this m_arrRAWSnifferData = new string[m_nTotalBufferSize]; } m_nRAWSnifferIndex++; if (m_nRAWSnifferIndex >= m_nTotalBufferSize) { m_nRAWSnifferIndex = m_nTotalBufferSize; HoldMode = true; UpdateFeedMode(); ReportLog("Buffer is full."); } else { m_arrRAWSnifferData[m_nRAWSnifferIndex] = sLine; } m_nMaxRAWSnifferIndex = m_nRAWSnifferIndex; DrawRAWDecoder(); } } #endif else if ((sLine.Length > 5) && (sLine.Substring(0, 6) == "#C2-F:")) { bWrongFormat = true; //parsed on the thread } else if ((sLine.Length > 5) && (sLine.Substring(0, 6) == "#C1-F:")) { bWrongFormat = true; //obsolete firmware } else { ReportLog(sLine); //report any line we don't understand - it is likely a human readable message } if (bWrongFormat) { ReportLog("Received unexpected data from RFExplorer device:" + sLine); ReportLog("Please update your RF Explorer to a recent firmware version and"); ReportLog("make sure you are using the latest version of RF Explorer for Windows."); ReportLog("Visit http://www.rf-explorer/download for latest firmware updates."); OnWrongFormatData(new EventArgs()); } } } while (bProcessAllEvents && (m_arrReceivedData.Count > 0)); } catch (Exception obEx) { ReportLog("ProcessReceivedString: " + sReceivedString + Environment.NewLine + obEx.ToString()); } return bDraw; }
public bool ProcessReceivedString(string sLine) { bool bOk = true; try { sLineString = sLine; if ((sLine.Length >= 60) && (sLine.Substring(0, 6) == "#C2-F:")) { //Spectrum Analyzer mode fStartMHZ = Convert.ToInt32(sLine.Substring(6, 7)) / 1000.0; //note it comes in KHZ fStepMHZ = Convert.ToInt32(sLine.Substring(14, 7)) / 1000000.0; //Note it comes in HZ fAmplitudeTopDBM = Convert.ToInt32(sLine.Substring(22, 4)); fAmplitudeBottomDBM = Convert.ToInt32(sLine.Substring(27, 4)); nFreqSpectrumSteps = Convert.ToUInt16(sLine.Substring(32, 4)); bExpansionBoardActive = (sLine[37] == '1'); eMode = (eMode)Convert.ToUInt16(sLine.Substring(39, 3)); fMinFreqMHZ = Convert.ToInt32(sLine.Substring(43, 7)) / 1000.0; fMaxFreqMHZ = Convert.ToInt32(sLine.Substring(51, 7)) / 1000.0; fMaxSpanMHZ = Convert.ToInt32(sLine.Substring(59, 7)) / 1000.0; if (sLine.Length > 66) { fRBWKHZ = Convert.ToInt32(sLine.Substring(67, 5)); } if (sLine.Length > 72) { fOffset_dB = Convert.ToInt32(sLine.Substring(73, 4)); } } else if ((sLine.Length >= 39) && (sLine.Substring(0, 6) == "#C3-G:")) { //Signal generator mode fStartMHZ = Convert.ToInt32(sLine.Substring(6, 7)) / 1000.0; //note it comes in KHZ fRFEGenCWFreqMHZ = Convert.ToInt32(sLine.Substring(14, 7)) / 1000.0; //Note it comes in KHZ nFreqSpectrumSteps = Convert.ToUInt16(sLine.Substring(22, 4)); fStepMHZ = Convert.ToInt32(sLine.Substring(27, 7)) / 1000.0; //Note it comes in KHZ bRFEGenHighPowerSwitch = (sLine[35] == '1'); nRFEGenPowerLevel = Convert.ToByte(sLine[37]-0x30); bRFEGenPowerON = (sLine[39] == '1'); nRFEGenSweepWaitMS = 0; eMode = eMode.MODE_NONE; } else bOk = false; } catch (Exception) { bOk = false; } return bOk; }
private void disconnect() { comPort.Close(); currentMode = eMode.DISCONNECTED; setMode(currentMode); }
/// <summary> /// Loads a sweep data file, it can be a .RFE sweep data file, a .SNA tracking file or a .SNANORM normalization tracking file /// This is only valid for analyzer objects. A tracking generator will be updated from SNA if linked to the analyzer, but never call this method /// from a generator object itself /// </summary> /// <param name="sFilename"></param> /// <returns></returns> public bool LoadDataFile(string sFilename) { string sConfiguration = ""; string sModel = ""; if (IsGenerator()) return false; //only valid for analyzer if (IsFileExtensionType(sFilename,_RFE_File_Extension)) { //normal sweep data file if (SweepData.LoadFile(sFilename, out sModel, out sConfiguration)) { //This is standard sweep data file with spectrum analyzer info only if (sModel.Contains(_RFEGEN_FILE_MODEL_Mark)) { return false; //found multi model data in a expected normal sweep file } HoldMode = true; double fAmplitudeTop, fAmplitudeBottom; SweepData.GetTopBottomDataRange(out fAmplitudeTop, out fAmplitudeBottom, m_AmplitudeCalibration); AmplitudeBottomDBM = fAmplitudeBottom - 5; AmplitudeTopDBM = fAmplitudeTop + 15; StartFrequencyMHZ = SweepData.GetData(0).StartFrequencyMHZ; StepFrequencyMHZ = SweepData.GetData(0).StepFrequencyMHZ; FreqSpectrumSteps = SweepData.GetData(0).TotalSteps; //Get offset, RBW and other parameters not saved as individual variables UpdateOfflineConfigurationParameters_Analyzer(sConfiguration, sModel); if (SweepData.GetData(0).TotalSteps == 13) { m_eMode = RFECommunicator.eMode.MODE_WIFI_ANALYZER; } else { m_eMode = RFECommunicator.eMode.MODE_SPECTRUM_ANALYZER; } } else return false; } else if (IsFileExtensionType(sFilename,_SNANORM_File_Extension)) { if ((m_objRFEGen == null) || (!m_objRFEGen.PortConnected)) return false; //we can load and update connected generator only return LoadFileSNANormalization(sFilename); } else return false; return true; }
private void BtnResetClick(object sender, EventArgs e) { string command = "\x18\n"; SerialSendWaitACK(command); // signon message while(comPort.BytesToRead > 0) { ReadSerial(); Application.DoEvents(); } currentMode = eMode.SOFTRESET; setMode(currentMode); }
private void setMode(eMode newMode) { switch(newMode) { case eMode.CONNECTED: btnConnect.Enabled = false; cbxComPort.Enabled = false; customPanel1.Enabled = true; tabControl1.Enabled = true; cbxComPort.Enabled = false; btnConnect.BackColor = System.Drawing.Color.LightGreen; btnDisconnect.BackColor = System.Drawing.Color.Coral; btnDisconnect.Enabled = true; btnMDIExecute.Enabled = true; btnZminus.Enabled = true; btnZplus.Enabled = true; btnYminus.Enabled = true; btnYplus.Enabled = true; btnXminus.Enabled = true; btnXplus.Enabled = true; btnReset.Enabled = true; btnRun.Enabled = true; lblMode.BackColor = System.Drawing.Color.LightGreen; lblMode.Text = "CONNECTED"; Cursor = Cursors.Default; break; case eMode.DISCONNECTED: btnDisconnect.Enabled = false; btnDisconnect.BackColor = System.Drawing.Color.DarkGray; btnConnect.Enabled = true; btnConnect.BackColor = System.Drawing.Color.DarkGray; btnRun.Enabled = false; btnMDIExecute.Enabled = false; btnZminus.Enabled = false; btnZplus.Enabled = false; btnYminus.Enabled = false; btnYplus.Enabled = false; btnXminus.Enabled = false; btnXplus.Enabled = false; btnReset.Enabled = false; cbxComPort.Enabled = true; lblMode.BackColor = System.Drawing.Color.Khaki; lblMode.Text = "OFFLINE"; Cursor = Cursors.Default; break; case eMode.RUNNING: Cursor = Cursors.AppStarting; workThread = new Thread(ThreadedCommunication); Progress.Minimum = 0; Progress.Maximum = gcode.Count; btnLoad.Enabled = false; btnDisconnect.Enabled = false; lblMode.BackColor = System.Drawing.Color.Gainsboro; lblMode.Text = "RUNNING"; btnFeedHold.BackColor = System.Drawing.Color.Khaki; btnFeedHold.Text = "Feed Hold"; feedHold = false; btnZeroAll.Enabled = false; btnZeroX.Enabled = false; btnZeroY.Enabled = false; btnZeroZ.Enabled = false; btnFeedHold.Enabled = true; btnCancel.Enabled = true; btnRun.Enabled = false; lblElapsedTime.Text = "00:00:00"; waitingOnACK = true; workThread.Start(); sw.Reset(); sw.Start(); timerStatusQuery.Enabled = true; break; case eMode.FINISHED: btnDisconnect.Enabled = true; btnLoad.Enabled = true; btnZeroAll.Enabled = true; btnZeroX.Enabled = true; btnZeroY.Enabled = true; btnZeroZ.Enabled = true; btnFeedHold.Enabled = false; btnCancel.Enabled = false; Progress.Value = 0; lblRX.BackColor = System.Drawing.Color.DarkGray; btnRun.Enabled = true; lblMode.BackColor = System.Drawing.Color.Chartreuse; lblMode.Text = "FINISHED"; Cursor = Cursors.Default; break; case eMode.ABORTED: cancelled = true; timerStatusQuery.Enabled = false; terminateThread(); sw.Stop(); lblMode.BackColor = System.Drawing.Color.Salmon; lblRX.BackColor = System.Drawing.Color.DarkGray; lblMode.Text = "ABORTED"; Progress.Value = 0; Cursor = Cursors.Default; btnRun.Enabled = true; btnLoad.Enabled = true; btnDisconnect.Enabled = true; btnZeroAll.Enabled = true; btnZeroX.Enabled = true; btnZeroY.Enabled = true; btnZeroZ.Enabled = true; btnFeedHold.Enabled = false; btnCancel.Enabled = false; Cursor = Cursors.Default; comPort.DiscardInBuffer(); comPort.DiscardOutBuffer(); MessageBox.Show("Cancel has been requested", "Run aborted", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); cancelled = false; break; case eMode.WAITING: Cursor = Cursors.WaitCursor; lblMode.BackColor = System.Drawing.Color.Yellow; break; case eMode.READY: lblMode.BackColor = System.Drawing.Color.Gainsboro; lblMode.Text = "READY"; Cursor = Cursors.Default; break; case eMode.LOADING: Cursor = Cursors.AppStarting; listBoxGcode.Items.Clear(); this.Refresh(); lblMode.BackColor = System.Drawing.Color.SkyBlue; lblMode.Text = "LOADING"; break; case eMode.SOFTRESET: lblMode.BackColor = System.Drawing.Color.SkyBlue; lblMode.Text = "SOFT RESET"; break; case eMode.FEEDHOLD: lblMode.BackColor = System.Drawing.Color.Orange; lblMode.Text = "FEED HOLD"; btnFeedHold.BackColor = System.Drawing.Color.Orange; btnFeedHold.Text = "Cycle Start"; break; case eMode.CYCLESTART: lblMode.BackColor = System.Drawing.Color.Gainsboro; lblMode.Text = "RUNNING"; btnFeedHold.BackColor = System.Drawing.Color.Khaki; btnFeedHold.Text = "Feed Hold"; break; } }
private void BtnCancelClick(object sender, System.EventArgs e) { currentMode = eMode.ABORTED; setMode(currentMode); }
private void ThreadFinishActions() { sw.Stop(); timerStatusQuery.Enabled = false; // was cancelled by request inside comm notify by unsupported command if(cancelled) { currentMode = eMode.ABORTED; setMode(currentMode); } else { currentMode = eMode.FINISHED; setMode(currentMode); MessageBox.Show("Normal Completion", "Run completed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } }
internal void SetMode(eMode eMode, string sText) { Mode = eMode; lbl_From_To.Text = sText; }
internal void SetTimeSpanParam(eMode eMode, DateTime xdtStartTime, DateTime xdtEndTime) { Mode = eMode; if (eMode == usrc_InvoiceTable.eMode.All) { lbl_From_To.Text = lngRPM.s_ShowAll.s; sFromTo_Suffix = ""; ExtraCondition = null; lpar_ExtraCondition = null; } else { SetTimeSpanParam_Ex(xdtStartTime, xdtEndTime); switch (eMode) { case usrc_InvoiceTable.eMode.Today: lbl_From_To.Text = lngRPM.s_Today.s + " " + sDate(dtStartTime); sFromTo_Suffix = sDate_Suffix(dtStartTime); break; case usrc_InvoiceTable.eMode.ThisWeek: lbl_From_To.Text = lngRPM.s_ThisWeek.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.LastWeek: lbl_From_To.Text = lngRPM.s_LastWeek.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.ThisMonth: lbl_From_To.Text = lngRPM.s_ThisMonth.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.LastMonth: lbl_From_To.Text = lngRPM.s_LastMonth.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.ThisYear: lbl_From_To.Text = lngRPM.s_ThisYear.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.LastYear: lbl_From_To.Text = lngRPM.s_LastYear.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; case usrc_InvoiceTable.eMode.TimeSpan: lbl_From_To.Text = lngRPM.s_TimeSpan.s + sTimeSpan(); sFromTo_Suffix = sTimeSpan_Suffix(); break; } } }