public void clearTransmitterBufferTest() { TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), new ISIStrxvuFrameLengths(), ISIStrxvuBitrate.trxvu_bitrate_1200); trx.clearTransmitterBuffer(); Assert.AreEqual(trx.transmitter.getAvailbleSpace(), 40); }
private string insertURL(string longURL) { libCommon.clsDB objDB = new libCommon.clsDB(); System.Data.SqlClient.SqlConnection dbCon = libMyUtil.clsCmnDB.getConnection("sa", "rhksflwk", "urlShorten", "192.168.10.10"); System.Data.SqlClient.SqlTransaction TRX; Random objRandom = new Random(); byte[] shortURL_byte; string shortURL; string Result; shortURL_byte = System.BitConverter.GetBytes(new UInt32()); objRandom.NextBytes(shortURL_byte); shortURL = libMyUtil.clsFile.toBase62(System.BitConverter.ToUInt32(shortURL_byte, 0)); dbCon.Open(); TRX = dbCon.BeginTransaction(); Result = libMyUtil.clsCmnDB.INSERT_DB(dbCon, TRX, "tb_URL", "longURL|shortURL", longURL + "|" + shortURL); if (Result.Equals("FAIL")) { TRX.Rollback(); shortURL = ""; } else { TRX.Commit(); } dbCon.Close(); return(shortURL); }
public void clearReceiverBufferTest() { TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), new ISIStrxvuFrameLengths(), ISIStrxvuBitrate.trxvu_bitrate_1200); trx.clearReceiverBuffer(); Assert.AreEqual(trx.receiver.GetNumberOfFramesInReceiverBuffer(), 0); }
public void IsisTrxvu_tcSetAx25BeaconOvrClSignTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); int res = trx.IsisTrxvu_tcSetAx25BeaconOvrClSign(new char[7], new char[7], new byte[30], 30, 100); Assert.AreEqual(Constants.E_TRXUV_FRAME_LENGTH, res); TRX trx2 = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); byte[] data = Encoding.ASCII.GetBytes("data"); char[] from = "fromSig".ToCharArray(); char[] to = "toCalli".ToCharArray(); int res2 = trx2.IsisTrxvu_tcSetAx25BeaconOvrClSign(from, to, data, 15, 100); Assert.AreEqual(Constants.E_NO_SS_ERR, res2); byte[] fromm = Encoding.UTF8.GetBytes(from); byte[] too = Encoding.UTF8.GetBytes(to); Assert.AreEqual(fromm.Length, trx2.Beacon.Header.Src.Length); Assert.AreEqual(too.Length, trx2.Beacon.Header.Dest.Length); for (int i = 0; i < fromm.Length; i++) { Assert.AreEqual(fromm[i], trx2.Beacon.Header.Src[i]); } for (int i = 0; i < too.Length; i++) { Assert.AreEqual(too[i], trx2.Beacon.Header.Dest[i]); } Assert.AreEqual(data, trx2.Beacon.infoFeild); Assert.AreEqual(trx2.beaconInterval, 100); }
/// <summary> /// 오류는 FAIL, 중복은 DUPE 리턴 /// </summary> public string insertUser(System.Data.SqlClient.SqlConnection dbCon, clsUserInfo objUserInfo, string loginID) { System.Data.SqlClient.SqlTransaction TRX; string tb_Name = "tb_user"; string Result = ""; TRX = dbCon.BeginTransaction(); Result = chkUserID(dbCon, TRX, objUserInfo.user_id); if (Result.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, tb_Name, objUserInfo.getICols(), objUserInfo.getIVals(loginID)); if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog("FAIL INSERT USER : " + objUserInfo.user_id); } else { TRX.Commit(); } } else { TRX.Rollback(); } return(Result); }
/// <summary> /// tb_aURLresult 테이블 결과 업데이트 /// </summary> /// <param name="Result">전달받은 결과값</param> private void UpdateResult(libMyUtil.pageCallingInfo callingInfo, string Result) { libCommon.clsDB objDB = new libCommon.clsDB(); System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string updateResult; if (System.Text.Encoding.Default.GetByteCount(Result) > 1000) { Result = Result.Substring(0, 500); } try { dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); updateResult = libMyUtil.clsCmnDB.UPDATE_DB(dbCon, TRX, "tb_aURLresult", "RESULT", Result, "aURLidx|FKEY", callingInfo.aURLset_Idx + "|" + callingInfo.FKEY); if (updateResult.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL UPDATE URL RESULT\r\nFKEY:{0}\r\nResult:{1}", callingInfo.FKEY, Result)); } else { TRX.Commit(); } dbCon.Close(); } catch (Exception ex) { objUtil.writeLog("ERR UPDATE URL CALL RESULT : " + ex.ToString()); } }
//RSS URL 추가 public string insertURL(System.Data.SqlClient.SqlConnection dbCon, string URL, string loginID) { System.Data.SqlClient.SqlTransaction TRX; string tb_Name = "tb_RSSsite"; string Result = ""; int idx; string Cols = "user_id|RSS_name|RSS_state|reg_date|update_date"; string Vals = loginID + "||" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "|" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); TRX = dbCon.BeginTransaction(); Result = objCmnDB.INSERT_DB(dbCon, TRX, tb_Name, Cols, Vals); if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog("FAIL INSERT URL : " + URL); } else { TRX.Commit(); } return(Result); }
public void IsisTrxvu_tcSetDefFromClSignTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); char[] from = "fromCal".ToCharArray(); trx.IsisTrxvu_tcSetDefFromClSign(from); Assert.AreEqual(TRXConfiguration.FromDefClSign, from); }
private void updateData(string fileName, string data) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; libCommon.clsDB objDB = new libCommon.clsDB(); dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); libMyUtil.clsCmnDB.UPDATE_DB(dbCon, TRX, "tb_EXIFdata", "model", data, "filePath", fileName); TRX.Commit(); dbCon.Close(); }
private void insertData(string fileName, string date, string model, string width, string height) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; libCommon.clsDB objDB = new libCommon.clsDB(); dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); libMyUtil.clsCmnDB.INSERT_DB(dbCon, TRX, "tb_EXIFdata", "filePath|fileName|date|model|width|height", fileName + "|" + Path.GetFileName(fileName) + "|" + date + "|" + model + "|" + width + "|" + height); TRX.Commit(); dbCon.Close(); }
private void HandleCollisions(IEnumerable<int> collisions, FrequencyHandlerWithTabu frequencyHandler) { TRX[] frequencies = frequencyHandler.GetFrequencyArray(); Parallel.ForEach(collisions, collisionIndex => { if (collisionIndex > -1) { int newFrequency = RandomizeChannelIndex(frequencies[collisionIndex], frequencyHandler.TabuList); frequencies[collisionIndex] = new TRX(newFrequency); } } ); }
public void IsisTrxvu_tcClearBeaconTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); byte[] data = Encoding.ASCII.GetBytes("data"); int res2 = trx.IsisTrxvu_tcSetAx25BeaconDefClSign(data, 15, 100); trx.IsisTrxvu_tcClearBeacon(); Assert.IsNull(trx.Beacon); }
public void IsisTrxvu_tcSetIdlestateTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); trx.IsisTrxvu_tcSetIdlestate(ISIStrxvuIdleState.trxvu_idle_state_off); Assert.AreEqual(trx.transmitter.state, ISIStrxvuIdleState.trxvu_idle_state_off); trx.IsisTrxvu_tcSetIdlestate(ISIStrxvuIdleState.trxvu_idle_state_on); Assert.AreEqual(trx.transmitter.state, ISIStrxvuIdleState.trxvu_idle_state_on); }
private void EnsureUniqueFrequenciesWithinCell(FrequencyHandler freqHandler) { Random r = new Random(); for (int i = 0; i < freqHandler.Length; i++) { if (freqHandler.Count(f => f == freqHandler[i]) > 1) { int newFrequency = r.Next(0,Channels.Length); while (freqHandler.Contains(newFrequency)) { newFrequency = r.Next(0,Channels.Length); } freqHandler[i] = new TRX(newFrequency); } } }
public void IsisTrxvu_tcSetAx25BitrateTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); trx.IsisTrxvu_tcSetAx25Bitrate(ISIStrxvuBitrate.trxvu_bitrate_1200); Assert.AreEqual(trx.default_bitrates, ISIStrxvuBitrate.trxvu_bitrate_1200); Assert.AreEqual(trx.transmitter.bitrate, TRX.MapBitrateToState[ISIStrxvuBitrate.trxvu_bitrate_1200]); Assert.AreEqual(trx.receiver.bitrate, TRX.MapBitrateToState[ISIStrxvuBitrate.trxvu_bitrate_1200]); trx.IsisTrxvu_tcSetAx25Bitrate(ISIStrxvuBitrate.trxvu_bitrate_2400); Assert.AreEqual(trx.default_bitrates, ISIStrxvuBitrate.trxvu_bitrate_2400); Assert.AreEqual(trx.transmitter.bitrate, TRX.MapBitrateToState[ISIStrxvuBitrate.trxvu_bitrate_2400]); Assert.AreEqual(trx.receiver.bitrate, TRX.MapBitrateToState[ISIStrxvuBitrate.trxvu_bitrate_2400]); }
/// <summary> /// RSS사이트 인서트, 실패/오류시 FAIL 리턴 /// </summary> public string insertRSSsite(string URL, string user_id) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string Cols; string Vals; string flag; string Result = "FAIL"; setSiteInfo(URL); if (siteURL.Trim().Length > 0 && siteTitle.Trim().Length > 0) { Cols = "user_id|RSS_name|RSS_url"; Vals = user_id + "|" + siteTitle + "|" + siteURL; dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); flag = isDupeSite(dbCon, TRX, user_id, URL); if (flag.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, "tb_RSSsite", Cols, Vals); } else if (flag.Equals("DUPE")) { Result = toggleSiteState(dbCon, TRX, user_id, URL, "AA"); } if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL INSERT RSS SITE INFO : {0}-{1}({2})", user_id, siteTitle, siteURL)); } else { TRX.Commit(); } dbCon.Close(); } return(Result); }
/// <summary> /// 관심기사 인서트 실패/오류시 FAIL 리턴 /// </summary> /// <param name="RSS_idx">RSS사이트 idx</param> /// <param name="Item_desc">요약정보</param> /// <param name="Item_date">yyyy-MM-dd HH:mm:ss</param> public string insertFavorItem(string RSS_idx, string Item_title, string Item_url, string Item_desc, string Item_date, string user_id) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string strDate; string Cols; string Vals; string Result = "FAIL"; string flag; strDate = Convert.ToDateTime(Item_date).ToString("yyyy-MM-dd HH:mm:ss"); Cols = "RSS_idx|user_id|Item_title|Item_url|Item_desc|Item_date"; Vals = RSS_idx + "|" + user_id + "|" + Item_title.Replace("|", "") + "|" + Item_url + "|" + Item_desc.Replace("|", "") + "|" + strDate; dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); flag = isDupeItem(dbCon, TRX, user_id, Item_url, "tb_favorite"); if (flag.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, "tb_favorite", Cols, Vals); } else if (flag.Equals("DUPE")) { Result = toggleFavorState(dbCon, TRX, Item_url, user_id, "AA"); } if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL INSERT FAVORITE : {0}-{1}({2})", user_id, RSS_idx, Item_url)); } else { TRX.Commit(); } dbCon.Close(); return(Result); }
public void IsisTrxvu_tcSendAX25DefClSignTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); int res = trx.IsisTrxvu_tcSendAX25DefClSign(new byte[30], 30, new Output <byte>()); Assert.AreEqual(Constants.E_TRXUV_FRAME_LENGTH, res); TRX trx2 = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); Output <byte> avail = new Output <byte>(); byte[] data = Encoding.ASCII.GetBytes("data"); int res2 = trx2.IsisTrxvu_tcSendAX25DefClSign(data, 15, avail); Assert.AreEqual(Constants.E_NO_SS_ERR, res2); Assert.AreEqual(avail.output, 39); Assert.AreEqual(data, ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).infoFeild); }
public void IsisTrxvu_tcSetAx25BeaconDefClSignTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); int res = trx.IsisTrxvu_tcSetAx25BeaconDefClSign(new byte[30], 30, 100); Assert.AreEqual(Constants.E_TRXUV_FRAME_LENGTH, res); TRX trx2 = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); Output <byte> avail = new Output <byte>(); byte[] data = Encoding.ASCII.GetBytes("data"); int res2 = trx2.IsisTrxvu_tcSetAx25BeaconDefClSign(data, 15, 100); Assert.AreEqual(Constants.E_NO_SS_ERR, res2); Assert.AreEqual(trx2.beaconInterval, 100); Assert.AreEqual(trx2.Beacon.infoFeild, data); }
/** * @brief Initialize the ISIS TRXVU with the corresponding i2cAddress from the array of TRXVU I2C Address structure. * @note This function can only be called once. * @param[in] address array of TRXVU I2C Address structure. * @param[in] maxFrameLengths array of maximum frame length structures for TRXVU. * @param[in] default_bitrates initial default bitrate. * @param[in] number of attached TRXVU in the system to be initialized. * @return Error code according to <hal/errors.h> */ public int IsisTrxvu_initialize(ISIStrxvuI2CAddress[] address, ISIStrxvuFrameLengths[] maxFrameLengths, ISIStrxvuBitrate default_bitrates, byte number) { logs.Add(DateTime.Now + " IsisTrxvu_initialize"); if (tRXes == null) { tRXes = new TRX[number]; for (int i = 0; i < number; i++) { logs.Add("address: " + address[i].ToString() + ", maxFrameLength: " + maxFrameLengths[i].ToString() + " ,default bitrates: " + default_bitrates + " ,index: " + i); TRX trx = new TRX(i, address[i], maxFrameLengths[i], default_bitrates) { Name = i.ToString() }; tRXes[i] = trx; tRXesCollection.Add(trx); } logs.Add(DateTime.Now + " Exit Status: No Error"); return(Constants.E_NO_SS_ERR); } logs.Add(DateTime.Now + " ERROR: IsisTRXVU allready initiallized"); return(Constants.E_IS_INITIALIZED); }
public void IsisTrxvu_tcSendAX25OvrClSignTest() { ISIStrxvuFrameLengths len = new ISIStrxvuFrameLengths(); len.maxAX25frameLengthRX = 20; len.maxAX25frameLengthTX = 20; TRX trx = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); int res = trx.IsisTrxvu_tcSendAX25OvrClSign(new char[7], new char[7], new byte[30], 30, new Output <byte>()); Assert.AreEqual(Constants.E_TRXUV_FRAME_LENGTH, res); TRX trx2 = new TRX(0, new ISIStrxvuI2CAddress(), len, ISIStrxvuBitrate.trxvu_bitrate_1200); Output <byte> avail = new Output <byte>(); byte[] data = Encoding.ASCII.GetBytes("data"); char[] from = "fromSig".ToCharArray(); char[] to = "toCalli".ToCharArray(); int res2 = trx2.IsisTrxvu_tcSendAX25OvrClSign(from, to, data, 15, avail); Assert.AreEqual(Constants.E_NO_SS_ERR, res2); Assert.AreEqual(avail.output, 39); byte[] fromm = Encoding.UTF8.GetBytes(from); byte[] too = Encoding.UTF8.GetBytes(to); Assert.AreEqual(fromm.Length, ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).Header.Src.Length); Assert.AreEqual(too.Length, ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).Header.Dest.Length); for (int i = 0; i < fromm.Length; i++) { Assert.AreEqual(fromm[i], ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).Header.Src[i]); } for (int i = 0; i < too.Length; i++) { Assert.AreEqual(too[i], ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).Header.Dest[i]); } Assert.AreEqual(data, ((AX25Frame)trx2.transmitter.txFrameBuffer.frames.peek()).infoFeild); }
private int RandomizeChannelIndex(TRX tRX, Queue<TRXTabu> tabuList) { bool isUnique = false; Random r = new Random(); int uniqueIndex = 0; int count = 0; while (isUnique == false) { int randomIndex = r.Next(0, Channels.Length); if ((randomIndex != tRX.Value) && (tabuList.Contains(new TRXTabu(new TRX(randomIndex), -1)) == false)) { uniqueIndex = randomIndex; isUnique = true; } count++; if (count > 50) { uniqueIndex = randomIndex; isUnique = true; } } System.Threading.Thread.Sleep(10); return uniqueIndex; }
private void InitializeFrequenciesTRXObjects(TRX[] frequencies) { for (int i = 0; i < frequencies.Length; i++) { frequencies[i] = new TRX(-1,-1); } }
public PSK(CWExpert form) { MainForm = form; AudioEvent1 = new AutoResetEvent(false); AudioEvent2 = new AutoResetEvent(false); iq_buffer = new ComplexF[2048]; ch1_buffer = new float[2048]; ch2_buffer = new float[2048]; buffer_ch1 = new float[2048]; buffer_ch2 = new float[2048]; display_timer = new HiPerfTimer(); trx = new TRX(); trx.modem = new psk[MODEM_NR]; trx.outbuf = new ComplexF[819]; trx.outbuf1 = new ComplexF[8192]; trx.mon_outbuf = new ComplexF[8192]; iq_balancer = new IQBalancer(form); cs_audio = (void*)0x0; cs_audio = NewCriticalSection(); if (InitializeCriticalSectionAndSpinCount(cs_audio, 0x00000080) == 0) { Debug.WriteLine("CriticalSection Failed"); } fft = new Fourier(); }
public RTTY(CWExpert form) { MainForm = form; output_ch1 = new string(' ', 1); output_ch2 = new string(' ', 1); AudioEventRX1 = new AutoResetEvent(false); AudioEventRX2 = new AutoResetEvent(false); iq_buffer = new ComplexF[2048]; ch1_buffer = new float[2048]; ch2_buffer = new float[2048]; ch3_buffer = new float[2048]; ch4_buffer = new float[2048]; ch1_buf = new float[2048]; ch2_buf = new float[2048]; ch3_buf = new float[2048]; ch4_buf = new float[2048]; Mag_mark = new float[2, 2048]; Mag_space = new float[2, 2048]; display_timer = new HiPerfTimer(); trx = new TRX(); trx.modem = new rtty[MODEM_NR]; cs_audio = (void*)0x0; cs_audio = NewCriticalSection(); if (InitializeCriticalSectionAndSpinCount(cs_audio, 0x00000080) == 0) { MessageBox.Show("CriticalSection Failed", "Error!"); } for (int i = 0; i < 2048; i++) { zero_buffer[i].Re = 0.0f; zero_buffer[i].Im = 0.0f; } }
public TRXTabu(TRX trx, int index) { TRX = trx; Index = index; }