123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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<string, T> GetIOData<T>(string type)
- {
- //get only value by keys
- Dictionary<string, T> da = new Dictionary<string, T>();
- if (type == "PLC1.AIList")
- {
- var diList = QueryDataClient.Instance.Service.GetData($"{Provider}.AIList");
- if (diList != null)
- {
- List<NotifiableIoItem> di = (List<NotifiableIoItem>)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<IOItem<T>> InitIOData<T>(string type)
- {
- //get the whole informations
- ObservableCollection<IOItem<T>> da = new ObservableCollection<IOItem<T>>();
- if (type == "PLC1.AIList")
- {
- var diList = QueryDataClient.Instance.Service.GetData($"{Provider}.AIList");
- if (diList != null)
- {
- List<NotifiableIoItem> di = (List<NotifiableIoItem>)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<T>()
- {
- Index = di[i].Index,
- Name = di[i].Name,
- Value = (T)(object)di[i].ShortValue,
- Address = di[i].Address
- });
- }
- }
- }
- }
-
- return da;
- }
- public ObservableCollection<AOItem> InitIOData(string type)
- {
- //get the whole informations
- ObservableCollection<AOItem> da = new ObservableCollection<AOItem>();
-
- return da;
- }
- public void SetAO(string name, float value)
- {
- }
- public void SetDO(string name, bool value)
- {
- }
- }
- }
|