|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using BPA.Helper;
- using BPASmartClient.S7Net;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.DosingSystem.ViewModel
- {
- public class TempManageControlViewModel : NotifyBase
- {
- public TempManageControlViewModel()
- {
-
- }
-
- /// <summary>
- /// 正转
- /// </summary>
- public bool Foreward
- {
- get { return _mForeward; }
- set
- {
- _mForeward = value;
- BeltDirection = 0;
- IsRun = _mForeward;
- OnPropertyChanged();
- Task.Factory.StartNew(() =>
- {
- if (Reversal || !_mForeward)
- {
- SiemensTest.GetInstance.sh.Write("M1000.1", true);
- Thread.Sleep(2000);
- SiemensTest.GetInstance.sh.Write("M1000.1", false);
- }
- if (_mForeward)
- {
- SiemensTest.GetInstance.sh.Write("M1000.0", true);
- Thread.Sleep(2000);
- SiemensTest.GetInstance.sh.Write("M1000.0", false);
- }
- });
- }
- }
- private bool _mForeward;
-
- /// <summary>
- /// 反转
- /// </summary>
- public bool Reversal
- {
- get { return _mReversal; }
- set
- {
- _mReversal = value;
- BeltDirection = 1;
- IsRun = _mReversal;
- OnPropertyChanged();
- Task.Factory.StartNew(() =>
- {
- if (Foreward || !_mReversal)
- {
- SiemensTest.GetInstance.sh.Write("M1000.1", true);
- Thread.Sleep(2000);
- SiemensTest.GetInstance.sh.Write("M1000.1", false);
- }
- if (_mReversal)
- {
- SiemensTest.GetInstance.sh.Write("M1000.3", true);
- Thread.Sleep(2000);
- SiemensTest.GetInstance.sh.Write("M1000.3", false);
- }
- });
- }
- }
- private bool _mReversal;
-
- public bool IsRun { get { return _mIsRun; } set { _mIsRun = value; OnPropertyChanged(); } }
- private bool _mIsRun;
-
-
- public int BeltDirection { get { return _mBeltDirection; } set { _mBeltDirection = value; OnPropertyChanged(); } }
- private int _mBeltDirection;
-
- }
-
- public class SiemensTest
- {
-
- private volatile static SiemensTest _Instance;
- public static SiemensTest GetInstance => _Instance ?? (_Instance = new SiemensTest());
- private SiemensTest() { }
-
- public SiemensHelper sh { get; set; } = new SiemensHelper();
-
- public void Init()
- {
- Task.Run(() =>
- {
- //sh.Connect(S7.Net.CpuType.S71500, "192.168.1.12");
- sh.Connect(S7.Net.CpuType.S71200, "192.168.0.15");
- if (sh.IsConnected)
- MessageLog.GetInstance.Show("西门子PLC连接成功");
- else
- MessageLog.GetInstance.Show("西门子PLC连接失败");
- });
- //sh.Connect(S7.Net.CpuType.S71500, "192.168.1.12");
- //sh.Connect(S7.Net.CpuType.S71200, "192.168.0.15");
- }
-
- }
- }
|