ConvertHelper.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. using DBEntity;
  2. using IvfTl.Control.Entity.DBEntitys;
  3. using IvfTl.Control.Entity.DTO;
  4. using IvfTl.Control.Entity.DTO.ApiResultDTO;
  5. using IvfTl.Control.Entity.GlobalEntitys;
  6. using IvfTl.Control.Entity.InitEntitys;
  7. namespace ivf_tl_UtilHelper
  8. {
  9. public static class ConvertHelper
  10. {
  11. public static TLSetting ConvertToTLSetting(tlInfoDTO tlInfo, tlSettingDTO tlSetting)
  12. {
  13. if (tlInfo == null) return null;
  14. TLSetting TLSetting = new TLSetting();
  15. TLSetting.id = tlInfo.id;
  16. TLSetting.tlSn = tlInfo.tlSn;
  17. TLSetting.tlName = tlInfo.tlName;
  18. TLSetting.state = tlInfo.state;
  19. TLSetting.online = tlInfo.online;
  20. TLSetting.softwareVersion = tlInfo.softwareVersion;
  21. TLSetting.protocolAddress = tlInfo.protocolAddress;
  22. TLSetting.installTime = tlInfo.installTime;
  23. TLSetting.address = tlInfo.address;
  24. TLSetting.socketIp = tlInfo.socketIp;
  25. TLSetting.socketPort = tlInfo.socketPort;
  26. TLSetting.alarmIp = tlInfo.alarmIp;
  27. TLSetting.alarmPort = tlInfo.alarmPort;
  28. TLSetting.mqttQueue = tlInfo.mqttQueue;
  29. TLSetting.kafkaTopic = tlInfo.kafkaTopic;
  30. TLSetting.remark = tlInfo.remark;
  31. if (tlSetting == null) return TLSetting;
  32. TLSetting.tmpDir = tlSetting.tmpDir;
  33. TLSetting.autoFocusTime = tlSetting.autoFocusTime;
  34. TLSetting.videoFps = tlSetting.videoFps;
  35. TLSetting.watermarking = tlSetting.watermarking;
  36. TLSetting.bufferBottlerPressureMax = tlSetting.bufferBottlerPressureMax;
  37. TLSetting.bufferBottlerPressureMin = tlSetting.bufferBottlerPressureMin;
  38. TLSetting.pressureAlarmMax = tlSetting.pressureAlarmMax;
  39. TLSetting.pressureAlarmMin = tlSetting.pressureAlarmMin;
  40. TLSetting.temperatureAlarmMax = tlSetting.temperatureAlarmMax;
  41. TLSetting.temperatureAlarmMin = tlSetting.temperatureAlarmMin;
  42. TLSetting.bufferBottlerAerationNum = tlSetting.bufferBottlerAerationNum;
  43. TLSetting.houseAerationNum = tlSetting.houseAerationNum;
  44. TLSetting.ventilationDelay = tlSetting.ventilationDelay;
  45. TLSetting.airSwapFrequency = tlSetting.airSwapFrequency;
  46. TLSetting.airSwapTime = tlSetting.airSwapTime;
  47. TLSetting.valueDelay = tlSetting.valueDelay;
  48. TLSetting.aerationDelay = tlSetting.aerationDelay;
  49. if (tlSetting.newAirSwap == 1)
  50. {
  51. TLSetting.newAirSwap = true;
  52. }
  53. TLSetting.motorDelay = tlSetting.motorDelay;
  54. TLSetting.verticalMotorPulseMax = tlSetting.verticalMotorPulseMax;
  55. TLSetting.photoIntervalPerRound = tlSetting.photoIntervalPerRound;
  56. TLSetting.lightOn = tlSetting.lightOn;
  57. TLSetting.keepDate = tlSetting.keepDate;
  58. TLSetting.heapDate = tlSetting.heapDate;
  59. TLSetting.historyCurveInterval = tlSetting.historyCurveInterval;
  60. TLSetting.mattingAlarmTimes = tlSetting.mattingAlarmTimes;
  61. TLSetting.houseDoorAlarmTime = tlSetting.houseDoorAlarmTime;
  62. TLSetting.temperatureAlarmTime = tlSetting.temperatureAlarmTime;
  63. TLSetting.pressureAlarmTime = tlSetting.pressureAlarmTime;
  64. TLSetting.chartThreshold = tlSetting.chartThreshold;
  65. TLSetting.saveSourcePic = TLSetting.saveSourcePic;
  66. if (tlSetting.compositeVideo == 1)
  67. {
  68. TLSetting.buildVideo = true;
  69. }
  70. // V-047 对焦配置下发链:服务器 init JSON → tlSettingDTO → 运行态 TLSetting
  71. // (喂 PhotoLayerCalculator / 安全门),再经 ConvertToTLSettingDB 落本地 SQLite 缓存。
  72. TLSetting.localAutofocusEnabled = tlSetting.localAutofocusEnabled ?? 0;
  73. TLSetting.focusLayerSpacingPulse = tlSetting.focusLayerSpacingPulse;
  74. TLSetting.focusLayerCount = tlSetting.focusLayerCount;
  75. TLSetting.cleanAutofocusData = tlSetting.cleanAutofocusData; // G4-1:对焦标定保留天数下发
  76. TLSetting.focusLayerDown = tlSetting.focusLayerDown;
  77. TLSetting.focusPeakRatioThreshold = tlSetting.focusPeakRatioThreshold;
  78. // 自动对焦重构:设备级搜索半幅默认 + 对焦曝光二分上下限 服务器下发 → 运行态。
  79. TLSetting.focusHRangeDefault = tlSetting.focusHRangeDefault;
  80. TLSetting.focusVRangeDefault = tlSetting.focusVRangeDefault;
  81. TLSetting.focusExposureMin = tlSetting.focusExposureMin;
  82. TLSetting.focusExposureMax = tlSetting.focusExposureMax;
  83. return TLSetting;
  84. }
  85. public static TLSetting ConvertToTLSetting(TLSettingDB tLSettingDB)
  86. {
  87. if (tLSettingDB == null) return null;
  88. TLSetting TLSetting = new TLSetting();
  89. TLSetting.id = tLSettingDB.id;
  90. TLSetting.tlSn = tLSettingDB.tlSn;
  91. TLSetting.tlName = tLSettingDB.tlName;
  92. TLSetting.state = tLSettingDB.state;
  93. TLSetting.online = tLSettingDB.online;
  94. TLSetting.softwareVersion = tLSettingDB.softwareVersion;
  95. TLSetting.protocolAddress = tLSettingDB.protocolAddress;
  96. TLSetting.installTime = tLSettingDB.installTime;
  97. TLSetting.address = tLSettingDB.address;
  98. TLSetting.socketIp = tLSettingDB.socketIp;
  99. TLSetting.socketPort = tLSettingDB.socketPort;
  100. TLSetting.alarmIp = tLSettingDB.alarmIp;
  101. TLSetting.alarmPort = tLSettingDB.alarmPort;
  102. TLSetting.mqttQueue = tLSettingDB.mqttQueue;
  103. TLSetting.kafkaTopic = tLSettingDB.kafkaTopic;
  104. TLSetting.remark = tLSettingDB.remark;
  105. TLSetting.tmpDir = tLSettingDB.tmpDir;
  106. TLSetting.autoFocusTime = tLSettingDB.autoFocusTime;
  107. TLSetting.videoFps = tLSettingDB.videoFps;
  108. TLSetting.watermarking = tLSettingDB.watermarking;
  109. TLSetting.bufferBottlerPressureMax = tLSettingDB.bufferBottlerPressureMax;
  110. TLSetting.bufferBottlerPressureMin = tLSettingDB.bufferBottlerPressureMin;
  111. TLSetting.pressureAlarmMax = tLSettingDB.pressureAlarmMax;
  112. TLSetting.pressureAlarmMin = tLSettingDB.pressureAlarmMin;
  113. TLSetting.temperatureAlarmMax = tLSettingDB.temperatureAlarmMax;
  114. TLSetting.temperatureAlarmMin = tLSettingDB.temperatureAlarmMin;
  115. TLSetting.bufferBottlerAerationNum = tLSettingDB.bufferBottlerAerationNum;
  116. TLSetting.houseAerationNum = tLSettingDB.houseAerationNum;
  117. TLSetting.ventilationDelay = tLSettingDB.ventilationDelay;
  118. TLSetting.airSwapFrequency = tLSettingDB.airSwapFrequency;
  119. TLSetting.airSwapTime = tLSettingDB.airSwapTime;
  120. TLSetting.valueDelay = tLSettingDB.valueDelay;
  121. TLSetting.aerationDelay = tLSettingDB.aerationDelay;
  122. if (tLSettingDB.newAirSwap == 1)
  123. {
  124. TLSetting.newAirSwap = true;
  125. }
  126. TLSetting.motorDelay = tLSettingDB.motorDelay;
  127. TLSetting.verticalMotorPulseMax = tLSettingDB.verticalMotorPulseMax;
  128. TLSetting.photoIntervalPerRound = tLSettingDB.photoIntervalPerRound;
  129. TLSetting.lightOn = tLSettingDB.lightOn;
  130. TLSetting.keepDate = tLSettingDB.keepDate;
  131. TLSetting.heapDate = tLSettingDB.heapDate;
  132. TLSetting.historyCurveInterval = tLSettingDB.historyCurveInterval;
  133. TLSetting.mattingAlarmTimes = tLSettingDB.mattingAlarmTimes;
  134. TLSetting.houseDoorAlarmTime = tLSettingDB.houseDoorAlarmTime;
  135. TLSetting.temperatureAlarmTime = tLSettingDB.temperatureAlarmTime;
  136. TLSetting.pressureAlarmTime = tLSettingDB.pressureAlarmTime;
  137. TLSetting.chartThreshold = tLSettingDB.chartThreshold;
  138. // M2-06 场景B本地自动对焦安全门(设备级开关;0关闭降级/1启用本地对焦,默认安全)。
  139. TLSetting.localAutofocusEnabled = tLSettingDB.localAutofocusEnabled;
  140. // V-047 取数链:设备级拍照层配置 本地缓存 → 运行时(喂 PhotoLayerCalculator)。
  141. TLSetting.focusLayerSpacingPulse = tLSettingDB.focusLayerSpacingPulse;
  142. TLSetting.focusLayerCount = tLSettingDB.focusLayerCount;
  143. TLSetting.cleanAutofocusData = tLSettingDB.cleanAutofocusData; // G4-1:本地缓存回读保留天数
  144. TLSetting.focusLayerDown = tLSettingDB.focusLayerDown;
  145. TLSetting.focusPeakRatioThreshold = tLSettingDB.focusPeakRatioThreshold;
  146. // 自动对焦重构:设备级搜索半幅默认 + 对焦曝光二分上下限 本地缓存 → 运行时。
  147. TLSetting.focusHRangeDefault = tLSettingDB.focusHRangeDefault;
  148. TLSetting.focusVRangeDefault = tLSettingDB.focusVRangeDefault;
  149. TLSetting.focusExposureMin = tLSettingDB.focusExposureMin;
  150. TLSetting.focusExposureMax = tLSettingDB.focusExposureMax;
  151. TLSetting.saveSourcePic = TLSetting.saveSourcePic;
  152. if (tLSettingDB.compositeVideo == 1)
  153. {
  154. TLSetting.buildVideo = true;
  155. }
  156. return TLSetting;
  157. }
  158. public static TLSettingDB ConvertToTLSettingDB(TLSetting tLSetting)
  159. {
  160. if (tLSetting == null) return null;
  161. TLSettingDB tLSettingDB = new TLSettingDB();
  162. tLSettingDB.id = tLSetting.id;
  163. tLSettingDB.tlSn = tLSetting.tlSn;
  164. tLSettingDB.tlName = tLSetting.tlName;
  165. tLSettingDB.state = tLSetting.state;
  166. tLSettingDB.online = tLSetting.online;
  167. tLSettingDB.softwareVersion = tLSetting.softwareVersion;
  168. tLSettingDB.protocolAddress = tLSetting.protocolAddress;
  169. tLSettingDB.installTime = tLSetting.installTime;
  170. tLSettingDB.address = tLSetting.address;
  171. tLSettingDB.socketIp = tLSetting.socketIp;
  172. tLSettingDB.socketPort = tLSetting.socketPort;
  173. tLSettingDB.alarmIp = tLSetting.alarmIp;
  174. tLSettingDB.alarmPort = tLSetting.alarmPort;
  175. tLSettingDB.mqttQueue = tLSetting.mqttQueue;
  176. tLSettingDB.kafkaTopic = tLSetting.kafkaTopic;
  177. tLSettingDB.remark = tLSetting.remark;
  178. tLSettingDB.tmpDir = tLSetting.tmpDir;
  179. tLSettingDB.autoFocusTime = tLSetting.autoFocusTime;
  180. tLSettingDB.videoFps = tLSetting.videoFps;
  181. tLSettingDB.watermarking = tLSetting.watermarking;
  182. tLSettingDB.bufferBottlerPressureMax = tLSetting.bufferBottlerPressureMax;
  183. tLSettingDB.bufferBottlerPressureMin = tLSetting.bufferBottlerPressureMin;
  184. tLSettingDB.pressureAlarmMax = tLSetting.pressureAlarmMax;
  185. tLSettingDB.pressureAlarmMin = tLSetting.pressureAlarmMin;
  186. tLSettingDB.temperatureAlarmMax = tLSetting.temperatureAlarmMax;
  187. tLSettingDB.temperatureAlarmMin = tLSetting.temperatureAlarmMin;
  188. tLSettingDB.bufferBottlerAerationNum = tLSetting.bufferBottlerAerationNum;
  189. tLSettingDB.houseAerationNum = tLSetting.houseAerationNum;
  190. tLSettingDB.ventilationDelay = tLSetting.ventilationDelay;
  191. tLSettingDB.airSwapFrequency = tLSetting.airSwapFrequency;
  192. tLSettingDB.airSwapTime = tLSetting.airSwapTime;
  193. tLSettingDB.valueDelay = tLSetting.valueDelay;
  194. tLSettingDB.aerationDelay = tLSetting.aerationDelay;
  195. tLSettingDB.historyCurveInterval = tLSetting.historyCurveInterval;
  196. if (tLSetting.newAirSwap)
  197. {
  198. tLSettingDB.newAirSwap = 1;
  199. }
  200. else
  201. {
  202. tLSettingDB.newAirSwap = 0;
  203. }
  204. tLSettingDB.motorDelay = tLSetting.motorDelay;
  205. tLSettingDB.verticalMotorPulseMax = tLSetting.verticalMotorPulseMax;
  206. tLSettingDB.photoIntervalPerRound = tLSetting.photoIntervalPerRound;
  207. tLSettingDB.lightOn = tLSetting.lightOn;
  208. tLSettingDB.keepDate = tLSetting.keepDate;
  209. tLSettingDB.heapDate = tLSetting.heapDate;
  210. tLSettingDB.mattingAlarmTimes = tLSetting.mattingAlarmTimes;
  211. tLSettingDB.houseDoorAlarmTime = tLSetting.houseDoorAlarmTime;
  212. tLSettingDB.temperatureAlarmTime = tLSetting.temperatureAlarmTime;
  213. tLSettingDB.pressureAlarmTime = tLSetting.pressureAlarmTime;
  214. tLSettingDB.chartThreshold = tLSetting.chartThreshold;
  215. // M2-06 场景B本地自动对焦安全门(设备级开关)回写本地缓存,跨重启保留。
  216. tLSettingDB.localAutofocusEnabled = tLSetting.localAutofocusEnabled;
  217. // V-047 取数链:设备级拍照层配置 运行时 → 本地缓存,跨重启保留。
  218. tLSettingDB.focusLayerSpacingPulse = tLSetting.focusLayerSpacingPulse;
  219. tLSettingDB.focusLayerCount = tLSetting.focusLayerCount;
  220. tLSettingDB.cleanAutofocusData = tLSetting.cleanAutofocusData; // G4-1:保留天数写入本地缓存
  221. tLSettingDB.focusLayerDown = tLSetting.focusLayerDown;
  222. tLSettingDB.focusPeakRatioThreshold = tLSetting.focusPeakRatioThreshold;
  223. // 自动对焦重构:设备级搜索半幅默认 + 对焦曝光二分上下限 运行时 → 本地缓存,跨重启保留。
  224. tLSettingDB.focusHRangeDefault = tLSetting.focusHRangeDefault;
  225. tLSettingDB.focusVRangeDefault = tLSetting.focusVRangeDefault;
  226. tLSettingDB.focusExposureMin = tLSetting.focusExposureMin;
  227. tLSettingDB.focusExposureMax = tLSetting.focusExposureMax;
  228. tLSettingDB.saveSourcePic = tLSetting.saveSourcePic;
  229. if (tLSetting.buildVideo)
  230. {
  231. tLSettingDB.compositeVideo = 1;
  232. }
  233. else
  234. {
  235. tLSettingDB.compositeVideo = 0;
  236. }
  237. return tLSettingDB;
  238. }
  239. public static House ConvertToHouse(houseDTO houseDTO)
  240. {
  241. if (houseDTO == null) return null;
  242. House house = new House();
  243. house.tlSn = houseDTO.tlSn;
  244. house.houseSn = houseDTO.houseSn;
  245. house.houseName = houseDTO.houseName;
  246. house.housePort = houseDTO.housePort;
  247. house.ccdId = houseDTO.ccdId;
  248. house.ccdSn = houseDTO.ccdSn;
  249. house.ccdHeight = houseDTO.ccdHeight;
  250. house.ccdWidth = houseDTO.ccdWidth;
  251. house.targetHeight = houseDTO.targetHeight;
  252. house.targetWidth = houseDTO.targetWidth;
  253. house.verticalMotorSpacePulse = houseDTO.verticalMotorSpacePulse;
  254. house.ccdExposure = houseDTO.ccdExposure;
  255. house.autoFocusNumber = houseDTO.autoFocusNumber;
  256. house.photographPictureNumber = houseDTO.photographPictureNumber;
  257. house.updateFocusNumber = houseDTO.updateFocusNumber;
  258. house.updateClearestNumber = houseDTO.updateClearestNumber;
  259. house.openCcd = houseDTO.openCcd;
  260. house.openPort = houseDTO.openPort;
  261. house.autoFocus = houseDTO.autoFocus == 1;
  262. house.noImagePreview = houseDTO.noImagePreview == 1;
  263. house.inletValveOpeningTime = houseDTO.inletValveOpeningTime;
  264. house.temperatureLowerHeatingPlate = houseDTO.temperatureLowerHeatingPlate;
  265. return house;
  266. }
  267. public static House ConvertToHouse(HouseDB houseDB)
  268. {
  269. if (houseDB == null) return null;
  270. House house = new House();
  271. house.tlSn = houseDB.tlSn;
  272. house.houseSn = houseDB.houseSn;
  273. house.houseName = houseDB.houseName;
  274. house.housePort = houseDB.housePort;
  275. house.ccdId = houseDB.ccdId;
  276. house.ccdSn = houseDB.ccdSn;
  277. house.ccdHeight = houseDB.ccdHeight;
  278. house.ccdWidth = houseDB.ccdWidth;
  279. house.targetHeight = houseDB.targetHeight;
  280. house.targetWidth = houseDB.targetWidth;
  281. house.verticalMotorSpacePulse = houseDB.verticalMotorSpacePulse;
  282. house.ccdExposure = houseDB.ccdExposure;
  283. house.autoFocusNumber = houseDB.autoFocusNumber;
  284. house.photographPictureNumber = houseDB.photographPictureNumber;
  285. house.updateFocusNumber = houseDB.updateFocusNumber;
  286. house.updateClearestNumber = houseDB.updateClearestNumber;
  287. house.openCcd = houseDB.openCcd;
  288. house.openPort = houseDB.openPort;
  289. house.autoFocus = houseDB.autoFocus == 1;
  290. house.noImagePreview = houseDB.noImagePreview == 1;
  291. house.inletValveOpeningTime = houseDB.inletValveOpeningTime;
  292. house.temperatureLowerHeatingPlate = houseDB.temperatureLowerHeatingPlate;
  293. return house;
  294. }
  295. public static HouseDB ConvertToHouseDB(House house)
  296. {
  297. if (house == null) return null;
  298. HouseDB houseDB = new HouseDB();
  299. houseDB.tlSn = house.tlSn;
  300. houseDB.houseSn = house.houseSn;
  301. houseDB.houseName = house.houseName;
  302. houseDB.housePort = house.housePort;
  303. houseDB.ccdId = house.ccdId;
  304. houseDB.ccdSn = house.ccdSn;
  305. houseDB.ccdHeight = house.ccdHeight;
  306. houseDB.ccdWidth = house.ccdWidth;
  307. houseDB.targetHeight = house.targetHeight;
  308. houseDB.targetWidth = house.targetWidth;
  309. houseDB.verticalMotorSpacePulse = house.verticalMotorSpacePulse;
  310. houseDB.ccdExposure = house.ccdExposure;
  311. houseDB.autoFocusNumber = house.autoFocusNumber;
  312. houseDB.photographPictureNumber = house.photographPictureNumber;
  313. houseDB.updateFocusNumber = house.updateFocusNumber;
  314. houseDB.updateClearestNumber = house.updateClearestNumber;
  315. houseDB.openCcd = house.openCcd;
  316. houseDB.openPort = house.openPort;
  317. houseDB.autoFocus = house.autoFocus ? 1 : 0;
  318. houseDB.noImagePreview = house.noImagePreview ? 1 : 0;
  319. houseDB.inletValveOpeningTime = house.inletValveOpeningTime;
  320. houseDB.temperatureLowerHeatingPlate = house.temperatureLowerHeatingPlate;
  321. return houseDB;
  322. }
  323. public static HouseWellSetting ConvertToHouseWellSetting(houseWellSettingDTO houseWellSettingDTO)
  324. {
  325. if (houseWellSettingDTO == null) return null;
  326. HouseWellSetting houseWellSetting = new HouseWellSetting();
  327. houseWellSetting.tlSn = houseWellSettingDTO.tlSn;
  328. houseWellSetting.houseSn = houseWellSettingDTO.houseSn;
  329. houseWellSetting.wellSn = houseWellSettingDTO.wellSn;
  330. houseWellSetting.leftOffset = houseWellSettingDTO.leftOffset;
  331. houseWellSetting.bottomOffset = houseWellSettingDTO.bottomOffset;
  332. houseWellSetting.moveDownLayer = houseWellSettingDTO.moveDownLayer;
  333. houseWellSetting.horizontalMotorPosition = houseWellSettingDTO.horizontalMotorPosition;
  334. houseWellSetting.eepromClearPosition = houseWellSettingDTO.eepromClearPosition;
  335. // V-047 对焦配置下发链:well 级覆盖 服务器 init JSON → DTO → 运行态(空=继承设备级)。
  336. houseWellSetting.focusLayerSpacingPulse = houseWellSettingDTO.focusLayerSpacingPulse;
  337. houseWellSetting.focusLayerCount = houseWellSettingDTO.focusLayerCount;
  338. // 自动对焦重构:well 级搜索半幅覆盖 服务器下发 → 运行态(空=继承设备级)。
  339. houseWellSetting.horizontalFocusRange = houseWellSettingDTO.horizontalFocusRange;
  340. houseWellSetting.verticalFocusRange = houseWellSettingDTO.verticalFocusRange;
  341. return houseWellSetting;
  342. }
  343. public static HouseWellSetting ConvertToHouseWellSetting(HouseWellSettingDB houseWellSettingDB)
  344. {
  345. if (houseWellSettingDB == null) return null;
  346. HouseWellSetting houseWellSetting = new HouseWellSetting();
  347. houseWellSetting.tlSn = houseWellSettingDB.tlSn;
  348. houseWellSetting.houseSn = houseWellSettingDB.houseSn;
  349. houseWellSetting.wellSn = houseWellSettingDB.wellSn;
  350. houseWellSetting.leftOffset = houseWellSettingDB.leftOffset;
  351. houseWellSetting.bottomOffset = houseWellSettingDB.bottomOffset;
  352. houseWellSetting.moveDownLayer = houseWellSettingDB.moveDownLayer;
  353. houseWellSetting.horizontalMotorPosition = houseWellSettingDB.horizontalMotorPosition;
  354. houseWellSetting.eepromClearPosition = houseWellSettingDB.eepromClearPosition;
  355. // V-047 取数链:well 级拍照层覆盖 本地缓存 → 运行时(空=继承设备级,喂 PhotoLayerCalculator)。
  356. houseWellSetting.focusLayerSpacingPulse = houseWellSettingDB.focusLayerSpacingPulse;
  357. houseWellSetting.focusLayerCount = houseWellSettingDB.focusLayerCount;
  358. // 自动对焦重构:well 级搜索半幅覆盖 本地缓存 → 运行时(空=继承设备级)。
  359. houseWellSetting.horizontalFocusRange = houseWellSettingDB.horizontalFocusRange;
  360. houseWellSetting.verticalFocusRange = houseWellSettingDB.verticalFocusRange;
  361. return houseWellSetting;
  362. }
  363. public static HouseWellSettingDB ConvertToHouseWellSettingDB(HouseWellSetting houseWellSetting)
  364. {
  365. if (houseWellSetting == null) return null;
  366. HouseWellSettingDB houseWellSettingDB = new HouseWellSettingDB();
  367. houseWellSettingDB.tlSn = houseWellSetting.tlSn;
  368. houseWellSettingDB.houseSn = houseWellSetting.houseSn;
  369. houseWellSettingDB.wellSn = houseWellSetting.wellSn;
  370. houseWellSettingDB.leftOffset = houseWellSetting.leftOffset;
  371. houseWellSettingDB.bottomOffset = houseWellSetting.bottomOffset;
  372. houseWellSettingDB.moveDownLayer = houseWellSetting.moveDownLayer;
  373. houseWellSettingDB.horizontalMotorPosition = houseWellSetting.horizontalMotorPosition;
  374. houseWellSettingDB.eepromClearPosition = houseWellSetting.eepromClearPosition;
  375. // V-047 取数链:well 级拍照层覆盖 运行时 → 本地缓存,跨重启保留。
  376. houseWellSettingDB.focusLayerSpacingPulse = houseWellSetting.focusLayerSpacingPulse;
  377. houseWellSettingDB.focusLayerCount = houseWellSetting.focusLayerCount;
  378. // 自动对焦重构:well 级搜索半幅覆盖 运行时 → 本地缓存,跨重启保留。
  379. houseWellSettingDB.horizontalFocusRange = houseWellSetting.horizontalFocusRange;
  380. houseWellSettingDB.verticalFocusRange = houseWellSetting.verticalFocusRange;
  381. return houseWellSettingDB;
  382. }
  383. public static HouseWellPhoto ConvertToHouseWellPhoto(positionResultDTO autoFocusPositionDTO)
  384. {
  385. if (autoFocusPositionDTO == null) return null;
  386. HouseWellPhoto houseWellPhoto = new HouseWellPhoto();
  387. houseWellPhoto.tlSn = autoFocusPositionDTO.tlSn;
  388. houseWellPhoto.houseSn = autoFocusPositionDTO.houseSn;
  389. houseWellPhoto.wellSn = autoFocusPositionDTO.wellSn;
  390. houseWellPhoto.verticalMotorPosition = autoFocusPositionDTO.verticalMotorPosition;
  391. houseWellPhoto.clearest = autoFocusPositionDTO.layerNum;
  392. houseWellPhoto.positionType = autoFocusPositionDTO.positionType;
  393. return houseWellPhoto;
  394. }
  395. public static HouseWellPhoto ConvertToHouseWellPhoto(HouseWellPhotoDB houseWellPhotoDb)
  396. {
  397. if (houseWellPhotoDb == null) return null;
  398. HouseWellPhoto houseWellPhoto = new HouseWellPhoto();
  399. houseWellPhoto.tlSn = houseWellPhotoDb.tlSn;
  400. houseWellPhoto.houseSn = houseWellPhotoDb.houseSn;
  401. houseWellPhoto.wellSn = houseWellPhotoDb.wellSn;
  402. houseWellPhoto.verticalMotorPosition = houseWellPhotoDb.verticalMotorPosition;
  403. houseWellPhoto.clearest = houseWellPhotoDb.clearest;
  404. houseWellPhoto.positionType = houseWellPhotoDb.positionType;
  405. return houseWellPhoto;
  406. }
  407. public static HouseWellPhotoDB ConvertToHouseWellPhotoDB(HouseWellPhoto houseWellPhoto)
  408. {
  409. if (houseWellPhoto == null) return null;
  410. HouseWellPhotoDB houseWellPhotoDB = new HouseWellPhotoDB();
  411. houseWellPhotoDB.tlSn = houseWellPhoto.tlSn;
  412. houseWellPhotoDB.houseSn = houseWellPhoto.houseSn;
  413. houseWellPhotoDB.wellSn = houseWellPhoto.wellSn;
  414. houseWellPhotoDB.verticalMotorPosition = houseWellPhoto.verticalMotorPosition;
  415. houseWellPhotoDB.clearest = houseWellPhoto.clearest;
  416. houseWellPhotoDB.positionType = houseWellPhoto.positionType;
  417. return houseWellPhotoDB;
  418. }
  419. public static Embryo ConvertToEmbryo(embryoDTO embryoDTO)
  420. {
  421. if (embryoDTO == null) return null;
  422. Embryo embryo=new Embryo();
  423. embryo.id = embryoDTO.id;
  424. embryo.dishId = embryoDTO.dishId;
  425. embryo.tlSn = embryoDTO.tlSn;
  426. embryo.houseSn= embryoDTO.houseSn;
  427. embryo.wellSn = embryoDTO.wellSn;
  428. embryo.startTime = embryoDTO.startTime;
  429. embryo.state= embryoDTO.state;
  430. embryo.stateTime = embryoDTO.stateTime;
  431. return embryo;
  432. }
  433. public static Embryo ConvertToEmbryo(EmbryoDB embryoDB)
  434. {
  435. if (embryoDB == null) return null;
  436. Embryo embryo = new Embryo();
  437. embryo.id = embryoDB.id;
  438. embryo.dishId = embryoDB.dishId;
  439. embryo.tlSn = embryoDB.tlSn;
  440. embryo.houseSn = embryoDB.houseSn;
  441. embryo.wellSn = embryoDB.wellSn;
  442. embryo.startTime = embryoDB.startTime;
  443. embryo.state = embryoDB.state;
  444. embryo.stateTime = embryoDB.stateTime;
  445. return embryo;
  446. }
  447. public static EmbryoDB ConvertToEmbryoDB(Embryo embryo)
  448. {
  449. if (embryo == null) return null;
  450. EmbryoDB embryoDB = new EmbryoDB();
  451. embryoDB.id = embryo.id;
  452. embryoDB.dishId = embryo.dishId;
  453. embryoDB.tlSn = embryo.tlSn;
  454. embryoDB.houseSn = embryo.houseSn;
  455. embryoDB.wellSn = embryo.wellSn;
  456. embryoDB.startTime = embryo.startTime;
  457. embryoDB.state = embryo.state;
  458. embryoDB.stateTime = embryo.stateTime;
  459. return embryoDB;
  460. }
  461. public static Dish ConvertToDish(dishDTO dishDTO)
  462. {
  463. if (dishDTO == null) return null;
  464. Dish dish = new Dish();
  465. dish.id=dishDTO.id;
  466. dish.tlSn= dishDTO.tlSn;
  467. dish.houseSn= dishDTO.houseSn;
  468. dish.startTime = dishDTO.startTime;
  469. dish.embryoCount = dishDTO.embryoCount;
  470. dish.Embryo = new List<Embryo>();
  471. foreach (var item in dishDTO.embryo)
  472. {
  473. dish.Embryo.Add(ConvertToEmbryo(item));
  474. }
  475. return dish;
  476. }
  477. public static Dish ConvertToDish(DishDB dishDB)
  478. {
  479. if (dishDB == null) return null;
  480. Dish dish = new Dish();
  481. dish.id = dishDB.id;
  482. dish.tlSn = dishDB.tlSn;
  483. dish.houseSn = dishDB.houseSn;
  484. dish.startTime = dishDB.startTime;
  485. dish.embryoCount = dishDB.embryoCount;
  486. dish.Embryo = new List<Embryo>();
  487. dish.endTime = dishDB.endTime;
  488. return dish;
  489. }
  490. public static DishDB ConvertToDishDB(Dish dish)
  491. {
  492. if (dish == null) return null;
  493. DishDB dishDB = new DishDB();
  494. dishDB.id = dish.id;
  495. dishDB.tlSn = dish.tlSn;
  496. dishDB.houseSn = dish.houseSn;
  497. dishDB.startTime = dish.startTime;
  498. dishDB.embryoCount = dish.embryoCount;
  499. dishDB.endTime = dish.endTime;
  500. return dishDB;
  501. }
  502. public static Balance ConvertToBalance(balanceDTO balanceDTO)
  503. {
  504. if (balanceDTO == null) return null;
  505. Balance balance = new Balance();
  506. balance.id=balanceDTO.id;
  507. balance.tlSn = balanceDTO.tlSn;
  508. balance.houseSn = balanceDTO.houseSn;
  509. balance.startTime = balanceDTO.startTime;
  510. return balance;
  511. }
  512. public static Balance ConvertToBalance(BalanceDB balanceDB)
  513. {
  514. if (balanceDB == null) return null;
  515. Balance balance = new Balance();
  516. balance.id = balanceDB.id;
  517. balance.tlSn = balanceDB.tlSn;
  518. balance.houseSn = balanceDB.houseSn;
  519. balance.startTime = balanceDB.startTime;
  520. balance.endTime = balanceDB.endTime;
  521. return balance;
  522. }
  523. public static BalanceDB ConvertToBalanceDB(Balance balance)
  524. {
  525. if (balance == null) return null;
  526. BalanceDB balanceDB = new BalanceDB();
  527. balanceDB.id = balance.id;
  528. balanceDB.tlSn = balance.tlSn;
  529. balanceDB.houseSn = balance.houseSn;
  530. balanceDB.startTime = balance.startTime;
  531. balanceDB.endTime = balance.endTime;
  532. return balanceDB;
  533. }
  534. public static PictureDB ConvertToPictureDB(ImageDTO imageDTO)
  535. {
  536. if (imageDTO == null) return null;
  537. PictureDB pictureDB = new PictureDB();
  538. pictureDB.CCDSN = imageDTO.CcdSn;
  539. pictureDB.Clearest = imageDTO.Clearest;
  540. pictureDB.dishId = (long)imageDTO.EmbryoCultureRecordId;
  541. pictureDB.EmbryoId = (long)imageDTO.EmbryoId;
  542. pictureDB.End = imageDTO.End;
  543. pictureDB.FertilizationTime = imageDTO.FertilizationTime;
  544. pictureDB.HorizontalPosition= imageDTO.HorizontalPosition;
  545. pictureDB.HouseSn = imageDTO.HouseSn;
  546. pictureDB.ImageTime = imageDTO.ImageTime;
  547. pictureDB.PhotographType = imageDTO.PhotographType;
  548. pictureDB.PictureLayer = imageDTO.PictureLayer;
  549. pictureDB.ShootingPosition = imageDTO.ShootingPosition;
  550. pictureDB.SourceImageName = imageDTO.SourceImageName;
  551. pictureDB.SourceImagePath = imageDTO.SourceImagePath;
  552. pictureDB.SourceImageWidth = imageDTO.SourceImageWidth;
  553. pictureDB.SourceImageHeight = imageDTO.SourceImageHeight;
  554. pictureDB.TlSn = imageDTO.TlSn;
  555. pictureDB.WellSn = imageDTO.WellSn;
  556. pictureDB.TotalLayer= imageDTO.TotalLayer;
  557. return pictureDB;
  558. }
  559. public static ImageDTO ConvertToPictureDB(PictureDB pictureDB)
  560. {
  561. if (pictureDB == null) return null;
  562. ImageDTO imageDTO = new ImageDTO();
  563. imageDTO.CcdSn = pictureDB.CCDSN;
  564. imageDTO.Clearest = pictureDB.Clearest;
  565. imageDTO.EmbryoCultureRecordId = (ulong)pictureDB.dishId;
  566. imageDTO.EmbryoId = (ulong)pictureDB.EmbryoId;
  567. imageDTO.End = pictureDB.End;
  568. imageDTO.FertilizationTime = pictureDB.FertilizationTime;
  569. imageDTO.HorizontalPosition = pictureDB.HorizontalPosition;
  570. imageDTO.HouseSn = pictureDB.HouseSn;
  571. imageDTO.ImageTime = pictureDB.ImageTime;
  572. imageDTO.PhotographType = pictureDB.PhotographType;
  573. imageDTO.PictureLayer = pictureDB.PictureLayer;
  574. imageDTO.ShootingPosition = pictureDB.ShootingPosition;
  575. imageDTO.SourceImageName = pictureDB.SourceImageName;
  576. imageDTO.SourceImagePath = pictureDB.SourceImagePath;
  577. imageDTO.SourceImageWidth = pictureDB.SourceImageWidth;
  578. imageDTO.SourceImageHeight = pictureDB.SourceImageHeight;
  579. imageDTO.TlSn = pictureDB.TlSn;
  580. imageDTO.WellSn = pictureDB.WellSn;
  581. imageDTO.TotalLayer = pictureDB.TotalLayer;
  582. return imageDTO;
  583. }
  584. }
  585. }