SignalEmulation.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. /// f2 邻星文件
  146. /// fsample 采样率
  147. // tlenms 生成信号时长 ms
  148. /// dt 时差
  149. /// df 频差
  150. /// snr1 邻1
  151. /// snr2 邻2
  152. /// snrmain 主
  153. ///
  154. SignalEmulation_EXPORT void genSignalsWithDtDfEx(char *file1, char *file2, char *file3, __int64 fsample, int tlenms
  155. , double dt1, double df1, double dt2, double df2, int snr1, int snr2, int snrmain);
  156. ///
  157. /// 根据给定时频差生成信号
  158. /// f1 主星文件
  159. /// fsample 采样率
  160. // tlenms 生成信号时长 ms
  161. /// Am 最大幅度
  162. ///
  163. SignalEmulation_EXPORT void genNoizes(char *file1, __int64 fsample, int tlenms, int Am);
  164. ///
  165. /// 该函数用于合并两个信号到一个新的文件
  166. /// 两个信号文件必须是相同的采样率, 如果两个文件不一样长,最后生成的数据以较短的文件时长为准
  167. ///
  168. /// infsample: 输出文件的采样率
  169. /// 输入文件为复采样文件
  170. /// sigfile1: 输入文件1
  171. /// outffc1: 输入文件1 在输出文件的中频位置
  172. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  173. /// sigfile2: 输入文件2
  174. /// outffc2: 输入文件2 在输出文件的中频位置
  175. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  176. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] 与 [outffc2 - infsample/2, outffc2 + infsample/2] 无交集 否则将返回错误
  177. /// outfsample: 输出文件采样率
  178. /// 请确保 outfsample = infsample * 2^N (N为正整数)
  179. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  180. /// 输出文件为复采样文件 IQ
  181. /// return: 返回值:0 成功
  182. /// 1 输入/输出文件不合法或者无法打开
  183. /// 2 输入文件太小 必须大于0.1秒对应的数据
  184. /// 3 outffc1,2 不合法
  185. /// 4 outffc1,outffc2 存在交集
  186. /// 5 输入输出采样率不满足规则
  187. ///
  188. SignalEmulation_EXPORT int mergeSignals(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, __int64 outfsample, char *outfile);
  189. ///
  190. /// 该函数用于合并两个信号到一个新的文件
  191. /// 两个信号文件必须是相同的采样率, 如果两个文件不一样长,最后生成的数据以较短的文件时长为准
  192. ///
  193. /// infsample: 输出文件的采样率
  194. /// 输入文件为复采样文件
  195. /// sigfile1: 输入文件1
  196. /// outffc1: 输入文件1 在输出文件的中频位置
  197. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  198. /// sigfile2: 输入文件2
  199. /// outffc2: 输入文件2 在输出文件的中频位置
  200. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  201. /// sigfile3: 输入文件3
  202. /// outffc3: 输入文件3 在输出文件的中频位置
  203. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  204. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  205. /// outfsample: 输出文件采样率
  206. /// 请确保 outfsample = infsample * 2^N (N为正整数)
  207. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  208. /// 输出文件为复采样文件 IQ
  209. /// return: 返回值:0 成功
  210. /// 1 输入/输出文件不合法或者无法打开
  211. /// 2 输入文件太小 必须大于0.1秒对应的数据
  212. /// 3 outffc1,2,3 不合法
  213. /// 4 outffc1,outffc2,outffc3 存在交集
  214. /// 5 输入输出采样率不满足规则
  215. ///
  216. SignalEmulation_EXPORT int mergeSignalsEx(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  217. ///
  218. /// 该函数用于合并两个信号到一个新的文件
  219. /// 三个信号文件必须是相同的采样率, 如果三个文件不一样长,最后生成的数据以较短的文件时长为准
  220. ///
  221. /// infsample: 输出文件的采样率
  222. /// 输入文件为复采样文件
  223. /// sigfile1: 输入文件1
  224. /// outffc1: 输入文件1 在输出文件的中频位置
  225. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  226. /// sigfile2: 输入文件2
  227. /// outffc2: 输入文件2 在输出文件的中频位置
  228. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  229. /// sigfile3: 输入文件3
  230. /// outffc3: 输入文件3 在输出文件的中频位置
  231. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  232. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  233. /// outfsample: 输出文件采样率
  234. /// 请确保 outfsample = infsample * N (N为正整数 and N > 3)
  235. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  236. /// 输出文件为复采样文件 IQ
  237. /// return: 返回值:0 成功
  238. /// 1 输入/输出文件不合法或者无法打开
  239. /// 2 输入文件太小 必须大于0.1秒对应的数据
  240. /// 3 outffc1,2,3 不合法
  241. /// 4 outffc1,outffc2,outffc3 存在交集
  242. /// 5 输入输出采样率不满足规则
  243. ///
  244. SignalEmulation_EXPORT int mergeSignalsEx_MN(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  245. ///
  246. /// 该函数用于合并两个信号到一个新的文件
  247. /// 三个信号文件必须是相同的采样率, 如果三个文件不一样长,最后生成的数据以较短的文件时长为准
  248. ///
  249. /// infsample: 输出文件的采样率
  250. /// 确保infsample %(outfsample / 3062500)==0
  251. /// 输入文件为复采样文件
  252. /// sigfile1: 输入文件1
  253. /// outffc1: 输入文件1 在输出文件的中频位置
  254. /// 请确保 outffc1 - infsample/2 >= -outfsample/2 && outffc1 + infsample/2 <= outfsample/2 否则将会返回错误
  255. /// sigfile2: 输入文件2
  256. /// outffc2: 输入文件2 在输出文件的中频位置
  257. /// 请确保 outffc2 - infsample/2 >= -outfsample/2 && outffc2 + infsample/2 <= outfsample/2 否则将会返回错误
  258. /// sigfile3: 输入文件3
  259. /// outffc3: 输入文件3 在输出文件的中频位置
  260. /// 请确保 outffc3 - infsample/2 >= -outfsample/2 && outffc3 + infsample/2 <= outfsample/2 否则将会返回错误
  261. /// 请确保 [outffc1 - infsample/2, outffc1 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2] , [outffc2 - infsample/2, outffc2 + infsample/2]无交集 否则将返回错误
  262. /// outfsample: 输出文件采样率 3062500 的倍数
  263. /// outfile: 输出文件名称,如果输出文件存在将覆盖
  264. /// 输出文件为复采样文件 IQ
  265. /// return: 返回值:0 成功
  266. /// 1 输入/输出文件不合法或者无法打开
  267. /// 2 输入文件太小 必须大于0.1秒对应的数据
  268. /// 3 outffc1,2,3 不合法
  269. /// 4 outffc1,outffc2,outffc3 存在交集
  270. /// 5 输入输出采样率不满足规则
  271. /// 1.outfsample % 3062500 == 0
  272. /// 2.infsample %(outfsample / 3062500)==0
  273. /// 3.outfsample / infsample > 3
  274. ///
  275. SignalEmulation_EXPORT int mergeSignalsEx_M(__int64 infsample, char *sigfile1, __int64 outffc1, char *sigfile2, __int64 outffc2, char *sigfile3, __int64 outffc3, __int64 outfsample, char *outfile);
  276. };