public static void FullTune() { byte cmd, b2, b3; byte b4 = 1; int count = 0; FlushBuffer(false); Debug.WriteLine("fulltune start"); FWC.ATUSendCmd((byte)ATURequest.REQ_FULLTUNE, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); Thread.Sleep(10); } while (cmd != 6 && cmd != 10 && count++ < 900); //6 = CMD_SWR (tune success), 10 = CMD_TUNEFAIL if (tune_pass) { Debug.WriteLine("fwd: " + fwd_pwr.ToString("f2") + " ref: " + rev_pwr.ToString("f2") + " swr: " + swr.ToString("f2") + ":1-------------------------------"); } else { Debug.WriteLine("Tune Failed: " + ((ATUTuneFail)tune_fail).ToString()); } FlushBuffer(false); }
public static void FlushBuffer(bool waitForFeedback) { bool feedback = false; int count = 0; uint timeout = 200; if (!waitForFeedback) { timeout = 0; } byte b1, b2, b3, b4; do { count++; FWC.ATUGetResult(out b1, out b2, out b3, out b4, timeout); if (b1 != 255 && b2 != 255 && b3 != 255) { feedback = true; } if ((waitForFeedback && !feedback)) { Thread.Sleep((int)timeout); } } while (b4 > 0 || (waitForFeedback && !feedback) && count < 20); }
public static void DecrementCapacitance() { byte cmd, b2, b3, b4; FWC.ATUSendCmd((byte)ATURequest.REQ_CAPDN, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); } while(b4 > 0); }
public static void IncrementInductance() { byte cmd, b2, b3, b4; FWC.ATUSendCmd((byte)ATURequest.REQ_INDUP, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); } while(b4 > 0); }
//===================================================================== // ke9ns add public static void ReadSWR() { int count = 0; byte cmd, b2, b3, b4; FWC.ATUSendCmd((byte)ATURequest.REQ_ALLUPDATE, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 250); ParseResult(cmd, b2, b3); Thread.Sleep(10); } while (cmd != 255 && count++ < 20); //6 = CMD_SWR (tune success), 10 = CMD_TUNEFAIL } // ReadSWR()
public static void FullTune() { int count = 0; bool done_tuning = false; byte cmd, b2, b3, b4; FWC.ATUSendCmd((byte)ATURequest.REQ_FULLTUNE, 0, 0); while (!done_tuning) { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); switch ((ATUResponse)cmd) { case ATUResponse.CMD_TUNEPASS: case ATUResponse.CMD_TUNEFAIL: done_tuning = true; break; } Thread.Sleep(100); if (count++ > 200) { break; } } for (int i = 0; i < 13; i++) { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); if (cmd == 200 || b4 == 0) { break; } ParseResult(cmd, b2, b3); } if (tune_pass) { Debug.WriteLine("fwd: " + fwd_pwr.ToString("f2") + " ref: " + rev_pwr.ToString("f2") + " swr: " + swr.ToString("f2") + ":1"); } else { Debug.WriteLine("Tune Failed: " + ((ATUTuneFail)tune_fail).ToString()); } }
public static void AutoTuning(bool b) { byte cmd, b2, b3, b4; if (b) { cmd = (byte)ATURequest.REQ_AUTO_ON; } else { cmd = (byte)ATURequest.REQ_AUTO_OFF; } FWC.ATUSendCmd(cmd, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); } while(b4 > 0); }
public static void Activate(bool b) { byte cmd, b2, b3, b4; if (b) { cmd = (byte)ATURequest.REQ_TUNER_ACTIVE; } else { cmd = (byte)ATURequest.REQ_TUNER_STANDBY; } FWC.ATUSendCmd(cmd, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); } while(b4 > 0); }
public static void SetSWRThreshold(double swr_thresh) { byte cmd = 0, b2, b3, b4; if (swr_thresh == 1.1) { cmd = (byte)ATURequest.REQ_SWR11; } else if (swr_thresh == 1.3) { cmd = (byte)ATURequest.REQ_SWR13; } else if (swr_thresh == 1.5) { cmd = (byte)ATURequest.REQ_SWR15; } else if (swr_thresh == 1.7) { cmd = (byte)ATURequest.REQ_SWR17; } else if (swr_thresh == 2.0) { cmd = (byte)ATURequest.REQ_SWR20; } else if (swr_thresh == 2.5) { cmd = (byte)ATURequest.REQ_SWR25; } else if (swr_thresh == 3.0) { cmd = (byte)ATURequest.REQ_SWR30; } FWC.ATUSendCmd(cmd, 0, 0); do { FWC.ATUGetResult(out cmd, out b2, out b3, out b4, 200); ParseResult(cmd, b2, b3); } while(b4 > 0); }