@@ -157,132 +157,7 @@ export async function getDeviceTable(deviceName: string, slaveId: number, pointN
157157 }
158158}
159159
160- export async function editPointData ( deviceName : string , pointCode : string , pointValue : number ) : Promise < boolean > {
161- const data = await requestApi ( '/device/edit_point_data/' , 'post' , {
162- device_name : deviceName ,
163- point_code : pointCode ,
164- point_value : pointValue ,
165- } ) ;
166- return data ;
167- }
168-
169-
170- export async function editPointLimit ( deviceName : string , pointCode : string , minValueLimit : number , maxValueLimit : number ) : Promise < boolean > {
171- try {
172- const data = await requestApi ( '/device/edit_point_limit/' , 'post' , {
173- device_name : deviceName ,
174- point_code : pointCode ,
175- min_value_limit : minValueLimit ,
176- max_value_limit : maxValueLimit ,
177- } ) ;
178- return data ;
179- } catch ( error ) {
180- console . error ( 'Error editing point limit:' , error ) ;
181- throw error ;
182- }
183- }
184-
185- export async function getPointLimit ( deviceName : string , pointCode : string ) : Promise < PointLimit > {
186- const pointLimit = {
187- minValueLimit : 0 ,
188- maxValueLimit : 0 ,
189- } ;
190-
191- try {
192- const data = await requestApi ( '/device/get_point_limit/' , 'post' , {
193- device_name : deviceName ,
194- point_code : pointCode ,
195- } ) ;
196- pointLimit . minValueLimit = data . min_value_limit ;
197- pointLimit . maxValueLimit = data . max_value_limit ;
198- return pointLimit ;
199- } catch ( error ) {
200- console . error ( 'Error getting point limit:' , error ) ;
201- return pointLimit ;
202- }
203- }
204160
205- export async function resetPointData ( deviceName : string ) : Promise < boolean > {
206- try {
207- const data = await requestApi ( '/device/reset_point_data/' , 'post' , {
208- device_name : deviceName ,
209- } ) ;
210- return data ;
211- } catch ( error ) {
212- console . error ( 'Error resetting point data:' , error ) ;
213- throw error ;
214- }
215- }
216-
217- export async function getPointInfo ( deviceName : string , pointCode : string ) : Promise < any > {
218- try {
219- const data = await requestApi ( '/device/get_point_info' , 'post' , {
220- device_name : deviceName ,
221- point_code : pointCode ,
222- } ) ;
223- return data ;
224- } catch ( error ) {
225- console . error ( 'Error getting point info:' , error ) ;
226- throw error ;
227- }
228- }
229-
230- export async function setSinglePointSimulateMethod ( deviceName : string , pointCode : string , simulateMethod : string ) : Promise < boolean > {
231- try {
232- const data = await requestApi ( '/device/set_single_point_simulate_method' , 'post' , {
233- device_name : deviceName ,
234- point_code : pointCode ,
235- simulate_method : simulateMethod ,
236- } ) ;
237- return data ;
238- } catch ( error ) {
239- console . error ( 'Error setting single point simulate method:' , error ) ;
240- throw error ;
241- }
242- }
243-
244- export async function setSinglePointStep ( deviceName : string , pointCode : string , step : number ) : Promise < boolean > {
245- try {
246- const data = await requestApi ( '/device/set_single_point_step' , 'post' , {
247- device_name : deviceName ,
248- point_code : pointCode ,
249- step : step ,
250- } ) ;
251- return data ;
252- } catch ( error ) {
253- console . error ( 'Error setting single point step:' , error ) ;
254- throw error ;
255- }
256- }
257-
258- export async function setPointSimulationRange ( deviceName : string , pointCode : string , minValue : number , maxValue : number ) : Promise < boolean > {
259- try {
260- const data = await requestApi ( '/device/set_point_simulation_range' , 'post' , {
261- device_name : deviceName ,
262- point_code : pointCode ,
263- min_value : minValue ,
264- max_value : maxValue ,
265- } ) ;
266- return data ;
267- } catch ( error ) {
268- console . error ( 'Error setting point simulation range:' , error ) ;
269- throw error ;
270- }
271- }
272-
273- export async function editPointMetadata ( deviceName : string , pointCode : string , metadata : any ) : Promise < boolean > {
274- try {
275- const data = await requestApi ( '/device/edit_point_metadata/' , 'post' , {
276- device_name : deviceName ,
277- point_code : pointCode ,
278- metadata : metadata ,
279- } ) ;
280- return data ;
281- } catch ( error ) {
282- console . error ( 'Error editing point metadata:' , error ) ;
283- throw error ;
284- }
285- }
286161
287162// ===== 自动读取控制 =====
288163
@@ -335,18 +210,6 @@ export async function manualRead(deviceName: string, interval: number = 0): Prom
335210 }
336211}
337212
338- export async function readSinglePoint ( deviceName : string , pointCode : string ) : Promise < number | null > {
339- try {
340- const data = await requestApi ( '/device/read_single_point' , 'post' , {
341- device_name : deviceName ,
342- point_code : pointCode ,
343- } ) ;
344- return data ?. value ?? null ;
345- } catch ( error ) {
346- console . error ( 'Error reading single point:' , error ) ;
347- return null ;
348- }
349- }
350213
351214// ===== 报文捕获 =====
352215
@@ -407,58 +270,6 @@ export async function getAvgTime(deviceName: string): Promise<AvgTimeStats | nul
407270
408271// ===== 动态测点/从机管理 =====
409272
410- export interface PointCreateData {
411- frame_type : number ; // 0=遥测, 1=遥信, 2=遥控, 3=遥调
412- code : string ;
413- name : string ;
414- rtu_addr : number ;
415- reg_addr : string ;
416- func_code : number ;
417- decode_code : string ;
418- mul_coe : number ;
419- add_coe : number ;
420- }
421-
422- export async function addPoint ( deviceName : string , pointData : PointCreateData ) : Promise < boolean > {
423- try {
424- const data = await requestApi ( '/device/add_point' , 'post' , {
425- device_name : deviceName ,
426- ...pointData ,
427- } ) ;
428- return data ;
429- } catch ( error ) {
430- console . error ( 'Error adding point:' , error ) ;
431- throw error ;
432- }
433- }
434-
435- export async function addPointsBatch ( deviceName : string , frameType : number , points : PointCreateData [ ] ) : Promise < boolean > {
436- try {
437- const data = await requestApi ( '/device/add_points_batch' , 'post' , {
438- device_name : deviceName ,
439- frame_type : frameType ,
440- points : points ,
441- } ) ;
442- return data ;
443- } catch ( error ) {
444- console . error ( 'Error adding points batch:' , error ) ;
445- throw error ;
446- }
447- }
448-
449- export async function deletePoint ( deviceName : string , pointCode : string ) : Promise < boolean > {
450- try {
451- const data = await requestApi ( '/device/delete_point' , 'post' , {
452- device_name : deviceName ,
453- point_code : pointCode ,
454- } ) ;
455- return data ;
456- } catch ( error ) {
457- console . error ( 'Error deleting point:' , error ) ;
458- throw error ;
459- }
460- }
461-
462273export async function addSlave ( deviceName : string , slaveId : number ) : Promise < boolean > {
463274 try {
464275 const data = await requestApi ( '/device/add_slave' , 'post' , {
@@ -499,79 +310,4 @@ export async function editSlave(deviceName: string, oldSlaveId: number, newSlave
499310 }
500311}
501312
502- export async function clearPoints ( deviceName : string , slaveId : number ) : Promise < number > {
503- try {
504- const data = await requestApi ( '/device/clear_points' , 'post' , {
505- device_name : deviceName ,
506- slave_id : slaveId ,
507- } ) ;
508- return data ;
509- } catch ( error ) {
510- console . error ( 'Error clearing points:' , error ) ;
511- throw error ;
512- }
513- }
514-
515- // ===== 变更追溯 =====
516-
517- export interface ChangeRecord {
518- source : string ;
519- source_label : string ;
520- old_value : any ;
521- new_value : any ;
522- old_real_value : any ;
523- new_real_value : any ;
524- timestamp : number ;
525- time : string ;
526- detail : string ;
527- client_info ?: string ;
528- }
529313
530- export interface PointChangeHistoryResponse {
531- point_code : string ;
532- tracking_enabled : boolean ;
533- maxlen : number ;
534- history : ChangeRecord [ ] ;
535- count : number ;
536- }
537-
538- export async function getPointChangeHistory ( deviceName : string , pointCode : string ) : Promise < PointChangeHistoryResponse | null > {
539- try {
540- const data = await requestApi ( '/device/get_point_change_history' , 'post' , {
541- device_name : deviceName ,
542- point_code : pointCode ,
543- } ) ;
544- return data ;
545- } catch ( error ) {
546- console . error ( 'Error getting point change history:' , error ) ;
547- return null ;
548- }
549- }
550-
551- export async function setChangeTrackingConfig ( deviceName : string , pointCode : string , enabled : boolean , maxlen ?: number ) : Promise < boolean > {
552- try {
553- const data = await requestApi ( '/device/set_change_tracking' , 'post' , {
554- device_name : deviceName ,
555- point_code : pointCode ,
556- enabled : enabled ,
557- maxlen : maxlen
558- } ) ;
559- return data ;
560- } catch ( error ) {
561- console . error ( 'Error setting change tracking config:' , error ) ;
562- throw error ;
563- }
564- }
565-
566- export async function clearPointChangeHistory ( deviceName : string , pointCode : string ) : Promise < boolean > {
567- try {
568- const data = await requestApi ( '/device/clear_point_change_history' , 'post' , {
569- device_name : deviceName ,
570- point_code : pointCode ,
571- } ) ;
572- return data ;
573- } catch ( error ) {
574- console . error ( 'Error clearing point change history:' , error ) ;
575- return false ;
576- }
577- }
0 commit comments