|
- using BPASmartClient.Model;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.Peripheral
- {
- /// <summary>
- /// 外设基类
- /// </summary>
- public abstract class BasePeripheral : IPeripheral
- {
- /// <summary>
- /// 是否已连接
- /// </summary>
- public bool IsConnected { get; set; }
- /// <summary>
- /// 是否工作正常
- /// </summary>
- public bool IsWork { get; set; }
- /// <summary>
- /// 归属设备Id
- /// </summary>
- public int DeviceId { get; set; }
- public CommunicationPar communicationPar { get; set; } = new CommunicationPar();
- public ConcurrentDictionary<string, object> status { get; set; } = new ConcurrentDictionary<string, object>();
- public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>();
-
- /// <summary>q
- /// 外设状态集合
- /// </summary>
- //protected ConcurrentDictionary<string, object> status = new ConcurrentDictionary<string, object>();
-
- /// <summary>
- /// 初始化外设状态
- /// </summary>
- protected abstract void InitStatus();
-
- public object? GetStatus(string statusName)
- {
- if (status.ContainsKey(statusName))
- return status[statusName];
- return null;
- }
-
- public void SetStatus(string statusName, object value)
- {
- if (status.ContainsKey(statusName))
- status[statusName] = value;
- else
- status.TryAdd(statusName, value);
- }
-
- public abstract void Start();
-
- public abstract void Stop();
-
- public abstract void Init();
-
- //public abstract void ReadData(string address);
-
- public abstract void WriteData(string address, object value);
-
- public ConcurrentDictionary<string, object> GetAllStatus()
- {
- return status;
- }
-
- }
- }
|