SignalEmulation.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. #pragma once
  2. #ifndef _WIN32 //linux
  3. #ifndef DECL_EXPORT
  4. # define DECL_EXPORT __attribute__((visibility("default")))
  5. #endif
  6. #ifndef DECL_IMPORT
  7. # define DECL_IMPORT __attribute__((visibility("default")))
  8. #endif
  9. #else //Windows
  10. #ifndef DECL_EXPORT
  11. # define DECL_EXPORT __declspec(dllexport)
  12. #endif
  13. #ifndef DECL_IMPORT
  14. # define DECL_IMPORT __declspec(dllimport)
  15. #endif
  16. #endif
  17. #ifdef SignalEmulation_Lib
  18. #define SignalEmulation_EXPORT DECL_EXPORT
  19. #else
  20. #define SignalEmulation_EXPORT DECL_IMPORT
  21. #endif
  22. extern "C"
  23. {
  24. // 根据卫星 接收站位置 目标位置 推算
  25. // pos1 xyz 3
  26. // pos2 xyz 3
  27. // recv1 lla 3
  28. // recv2 lla 3
  29. // tar lla 3 * n
  30. // tarCount n
  31. // deltaT n
  32. void genDeltaT(double *pos1, double *pos2, double *recv1, double *recv2, double *tar, int tarCount, double *deltaT);
  33. // 生成psk调整信号
  34. // x 输入符号
  35. // len 符号长度
  36. // mode alphabet size 2^N (1,2,3,4)
  37. // phase initial phase
  38. // Amplify 幅度
  39. // N 升采样系数 >= 0
  40. void pskMod(int *x, int len, int mode, double phase, int Amplify, int N, double *y, int &olen);
  41. // 添加高斯白噪声
  42. // sig IQ信号
  43. // len 信号个数
  44. // sigPower signal power in dBW < 0 表示需要进行测量
  45. // reqSNR
  46. void awgn(double *sig, int len, double sigPower, double reqSNR);
  47. // 添加高斯白噪声
  48. // sig IQ信号
  49. // len 信号个数
  50. // sigPower signal power in dBW < 0 表示需要进行测量
  51. // reqSNR
  52. void awgnComplex(double *sig, int len, double sigPower, double reqSNR);
  53. //生成升余弦滤波器
  54. // mode =0 normal
  55. // delay = span*sps/2;
  56. // t = (-delay:delay) / sps;
  57. // denom = (1-(2*beta*t).^2);
  58. // sinc(t(idx1)).*(cos(pi*beta*t(idx1))./denom(idx1))/sps;
  59. // mod = 1 sqrt 暂未实现
  60. //
  61. double *rcosdesign(double beta, int span, int sps, int mode, int &len);
  62. // 根据参数生成一组目标信号
  63. // major_sat 主星星历 xyz
  64. // minor_sat 邻星星历 xyz
  65. // majorRecv 主星接收站 lla
  66. // minorRecv 邻星接收站 lla
  67. // tarPos 目标位置 lla
  68. // ------------------------
  69. // fsample 生成信号采样率
  70. // tlenms 生成信号时长 ms
  71. // fmajor 生成信号主星文件名称
  72. // fminor 生成信号邻星文件名称
  73. //
  74. SignalEmulation_EXPORT void genSatSignal(double majorSat[3], double minorSat[3], double majorRecv[3], double minorRecv[3], double tarPos[3]
  75. , __int64 fsample, int tlenms, char *fmajor, char *fminor, double *res);
  76. // 根据参数生成一组目标信号
  77. // major_sat 主星星历 xyz
  78. // minor_sat1 邻星星历 xyz
  79. // minor_sat2 邻星星历 xyz
  80. // majorRecv 主星接收站 lla
  81. // minorRecv1 邻星接收站 lla
  82. // minorRecv2 邻星接收站 lla
  83. // tarPos 目标位置 lla
  84. // ------------------------
  85. // fsample 生成信号采样率
  86. // tlenms 生成信号时长 ms
  87. // dtErrRange 误差范围, 根据该值 生成一个随机误差 单位us
  88. // fmajor 生成信号主星文件名称
  89. // fminor1 生成信号邻星文件名称
  90. // fminor2 生成信号邻星文件名称
  91. //
  92. SignalEmulation_EXPORT void genSatSignals(double majorSat[3], double minorSat1[3], double minorSat2[3]
  93. , double majorRecv[3], double minorRecv1[3], double minorRecv2[3]
  94. , double tarPos[3], __int64 fsample, int tlenms, int dtErrRange, double df[2]
  95. , char *fmajor, char *fminor1, char *fminor2, double *res);
  96. // 根据参数生成一组目标信号
  97. // major_sat 主星星历 xyz
  98. // minor_sat1 邻星星历 xyz
  99. // minor_sat2 邻星星历 xyz
  100. // majorRecv 主星接收站 lla
  101. // minorRecv1 邻星接收站 lla
  102. // minorRecv2 邻星接收站 lla
  103. // tarPos 目标位置 lla
  104. // refPos 目标位置 lla
  105. // ------------------------
  106. // fsample 生成信号采样率
  107. // tlenms 生成信号时长 ms
  108. // dtErrRange 误差范围, 根据该值 生成一个随机误差 单位us
  109. // fmajor 生成信号主星文件名称
  110. // fminor1 生成信号邻星文件名称
  111. // fminor2 生成信号邻星文件名称
  112. // frmajor 生成参考信号主星文件名称
  113. // frminor1 生成参考信号邻星文件名称
  114. // frminor2 生成参考信号邻星文件名称
  115. // res 长度4 目标参考对应的时差
  116. //
  117. SignalEmulation_EXPORT void genSatSignalsWithRef(double majorSat[3], double minorSat1[3], double minorSat2[3]
  118. , double majorRecv[3], double minorRecv1[3], double minorRecv2[3]
  119. , double tarPos[3], double refPos[3], __int64 fsample, __int64 fsampleref, int tlenms, int dtErrRange, double df[4]
  120. , char *fmajor, char *fminor1, char *fminor2
  121. , char *frmajor, char *frminor1, char *frminor2
  122. , double *res);
  123. ///
  124. /// 根据给定文件生成其对应的时差文件
  125. /// fIn 输入文件
  126. /// fOut 输出文件
  127. /// fsample 采样率
  128. /// dt 时差
  129. /// df 频差
  130. ///
  131. SignalEmulation_EXPORT void genSignalWithDtDf(char *fIn, char *fOut, __int64 fsample, double dt, double df);
  132. ///
  133. /// 根据给定时频差生成信号
  134. /// f1 主星文件
  135. /// f2 邻星文件
  136. /// fsample 采样率
  137. // tlenms 生成信号时长 ms
  138. /// dt 时差
  139. /// df 频差
  140. ///
  141. SignalEmulation_EXPORT void genSignalsWithDtDf(char *file1, char *file2, __int64 fsample, int tlenms, double dt, double df, int snr1, int snr2);
  142. ///
  143. /// 根据给定时频差生成信号
  144. /// f1 主星文件
  145. /// fsample 采样率
  146. // tlenms 生成信号时长 ms
  147. /// Am 最大幅度
  148. ///
  149. SignalEmulation_EXPORT void genNoizes(char *file1, __int64 fsample, int tlenms, int Am);
  150. ///
  151. /// 该函数用于合并两个信号到一个新的文件
  152. /// 两个信号文件必须是相同的采样率, 如果两个文件不一样长,最后生成的数据以较短的文件时长为准
  153. ///
  154. /// infsample: 输出文件的采样率
  155. /// 输入文件为复采样文件
  156. /// sigfile1: 输入文件1
  157. /// outffc1: 输入文件1 在输出文件的中频位置
  158. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  159. /// sigfile2: 输入文件2
  160. /// outffc2: 输入文件2 在输出文件的中频位置
  161. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  162. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] 与 [outffc2 - infsample/2, outffc2 + infsample/2] 无交集 否则将返回错误
  163. /// outfsample: 输出文件采样率
  164. /// 请确保 outfsample = infsample * 2^N (N为正整数)
  165. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  166. /// 输出文件为复采样文件 IQ
  167. /// return: 返回值:0 成功
  168. /// 1 输入/输出文件不合法或者无法打开
  169. /// 2 输入文件太小 必须大于0.1秒对应的数据
  170. /// 3 outffc1,2 不合法
  171. /// 4 outffc1,outffc2 存在交集
  172. /// 5 输入输出采样率不满足规则
  173. ///
  174. SignalEmulation_EXPORT int mergeSignals(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, __int64 outfsample, char *outfile);
  175. ///
  176. /// 该函数用于合并两个信号到一个新的文件
  177. /// 两个信号文件必须是相同的采样率, 如果两个文件不一样长,最后生成的数据以较短的文件时长为准
  178. ///
  179. /// infsample: 输出文件的采样率
  180. /// 输入文件为复采样文件
  181. /// sigfile1: 输入文件1
  182. /// outffc1: 输入文件1 在输出文件的中频位置
  183. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  184. /// sigfile2: 输入文件2
  185. /// outffc2: 输入文件2 在输出文件的中频位置
  186. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  187. /// sigfile3: 输入文件3
  188. /// outffc3: 输入文件3 在输出文件的中频位置
  189. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  190. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  191. /// outfsample: 输出文件采样率
  192. /// 请确保 outfsample = infsample * 2^N (N为正整数)
  193. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  194. /// 输出文件为复采样文件 IQ
  195. /// return: 返回值:0 成功
  196. /// 1 输入/输出文件不合法或者无法打开
  197. /// 2 输入文件太小 必须大于0.1秒对应的数据
  198. /// 3 outffc1,2,3 不合法
  199. /// 4 outffc1,outffc2,outffc3 存在交集
  200. /// 5 输入输出采样率不满足规则
  201. ///
  202. SignalEmulation_EXPORT int mergeSignalsEx(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  203. ///
  204. /// 该函数用于合并两个信号到一个新的文件
  205. /// 三个信号文件必须是相同的采样率, 如果三个文件不一样长,最后生成的数据以较短的文件时长为准
  206. ///
  207. /// infsample: 输出文件的采样率
  208. /// 输入文件为复采样文件
  209. /// sigfile1: 输入文件1
  210. /// outffc1: 输入文件1 在输出文件的中频位置
  211. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  212. /// sigfile2: 输入文件2
  213. /// outffc2: 输入文件2 在输出文件的中频位置
  214. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  215. /// sigfile3: 输入文件3
  216. /// outffc3: 输入文件3 在输出文件的中频位置
  217. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  218. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  219. /// outfsample: 输出文件采样率
  220. /// 请确保 outfsample = infsample * N (N为正整数 and N > 3)
  221. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  222. /// 输出文件为复采样文件 IQ
  223. /// return: 返回值:0 成功
  224. /// 1 输入/输出文件不合法或者无法打开
  225. /// 2 输入文件太小 必须大于0.1秒对应的数据
  226. /// 3 outffc1,2,3 不合法
  227. /// 4 outffc1,outffc2,outffc3 存在交集
  228. /// 5 输入输出采样率不满足规则
  229. ///
  230. SignalEmulation_EXPORT int mergeSignalsEx_MN(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  231. ///
  232. /// 该函数用于合并两个信号到一个新的文件
  233. /// 三个信号文件必须是相同的采样率, 如果三个文件不一样长,最后生成的数据以较短的文件时长为准
  234. ///
  235. /// infsample: 输出文件的采样率
  236. /// 确保infsample %(outfsample / 3062500)==0
  237. /// 输入文件为复采样文件
  238. /// sigfile1: 输入文件1
  239. /// outffc1: 输入文件1 在输出文件的中频位置
  240. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  241. /// sigfile2: 输入文件2
  242. /// outffc2: 输入文件2 在输出文件的中频位置
  243. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  244. /// sigfile3: 输入文件3
  245. /// outffc3: 输入文件3 在输出文件的中频位置
  246. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  247. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  248. /// outfsample: 输出文件采样率 3062500 的倍数
  249. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  250. /// 输出文件为复采样文件 IQ
  251. /// return: 返回值:0 成功
  252. /// 1 输入/输出文件不合法或者无法打开
  253. /// 2 输入文件太小 必须大于0.1秒对应的数据
  254. /// 3 outffc1,2,3 不合法
  255. /// 4 outffc1,outffc2,outffc3 存在交集
  256. /// 5 输入输出采样率不满足规则
  257. /// 1.outfsample % 3062500 == 0
  258. /// 2.infsample %(outfsample / 3062500)==0
  259. /// 3.outfsample / infsample > 3
  260. ///
  261. SignalEmulation_EXPORT int mergeSignalsEx_M(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  262. };