12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using SCADA;
- using SCADA.Drive;
- using SCADA_DAQ.Plugin.Core.Service;
- using SCADA_DAQ.Plugin.Machine.Device;
- using System;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- namespace SCADA_DAQ.Customer.Machines
- {
- /// <summary>
- /// 客户自定义设备
- /// </summary>
- [DisplayName("客户自定义设备")]
- public partial class SampleMachine : BasePLCMachine
- {
- /// <summary>
- /// 报警合集
- /// </summary>
- public ObservableCollection<Alarm> AlarmCollection { get; set; } = new ObservableCollection<Alarm>();
- /// <summary>
- ///
- /// </summary>
- public Redundancy RedundancyService { get; set; } //冗余服务
- /// <summary>
- ///
- /// </summary>
- /// <param name="machieID"></param>
- public SampleMachine(string machieID) : base(machieID)
- {
- RedundancyService = ServiceHost.Instance.GetService<Redundancy>();
- AlarmCodes =
- Env.DAL.Base_AlarmCode.GetData<DBModel.Base_AlarmCode>()?
- .Select(t => new Alarm() { AlarmCode = t.AlarmCode_Str, Desc = t.AlarmDesc_Str })?
- .ToLookup(t => t.AlarmCode).ToDictionary(t => t.Key, t => t.First());
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
- {
- if (RedundancyService?.RedundancyState == RedundancyStates.Standby) { return; } //如果是待机模式就不执行下面的逻辑
- base.RegReadValueChanged(sender, e);
- var reg = (RegInfo)sender;
- //if (reg.Comment.Variable == "Sys_1minPlus")
- //{
- // Log.Info($"寄存器变化:{reg.Comment.Variable},value:{reg.Value}");
- //}
- }
- /// <summary>
- /// 扫描完成事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void ScanCompleted(object sender, EventArgs e)
- {
- if (RedundancyService?.RedundancyState == RedundancyStates.Standby) { return; } //如果是待机模式就不执行下面的逻辑
- base.ScanCompleted(sender, e);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void AlarmTriggered(object sender, AlarmTriggedEventArgs e)
- {
- base.AlarmTriggered(sender, e);
- var reg = (e.Alarm as Alarm<RegInfo>).Tag;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void AlarmReset(object sender, AlarmTriggedEventArgs e)
- {
- base.AlarmReset(sender, e);
- }
- }
- }
|