using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.IOCore; using OpenSEMI.ClientBase.IO; using OpenSEMI.ClientBase.ServiceProvider; namespace VirgoUI.Client.Models.Common.IO { public class IO3Provider : IProvider { private static IO3Provider _Instance = null; public static IO3Provider Instance { get { if (_Instance == null) { _Instance = new IO3Provider(); _Instance.Create(); } return _Instance; } } private const string Provider = "System.io3"; public void Create() { } public Dictionary GetIOData(string type) { //get only value by keys Dictionary da = new Dictionary(); if (type == "PLC1.AIList") { var diList = QueryDataClient.Instance.Service.GetData($"{Provider}.AIList"); if (diList != null) { List di = (List)diList; for (int i = 0; i < di.Count; i++) { if (di[i].Provider != Provider) continue; //bool value = true; //if (value is T) { da[di[i].Name] = (T)(object)di[i].ShortValue; } } } } return da; } public ObservableCollection> InitIOData(string type) { //get the whole informations ObservableCollection> da = new ObservableCollection>(); if (type == "PLC1.AIList") { var diList = QueryDataClient.Instance.Service.GetData($"{Provider}.AIList"); if (diList != null) { List di = (List)diList; for (int i = 0; i < di.Count; i++) { if (di[i].Provider != Provider) continue; //bool value = true; //if (value is T) { da.Add(new IOItem() { Index = di[i].Index, Name = di[i].Name, Value = (T)(object)di[i].ShortValue, Address = di[i].Address }); } } } } return da; } public ObservableCollection InitIOData(string type) { //get the whole informations ObservableCollection da = new ObservableCollection(); return da; } public void SetAO(string name, float value) { } public void SetDO(string name, bool value) { } } }