// This is a callback-method, which will be called after the reading of the register is finished. public void Read_DataReceived(IDeviceData deviceValues) { int taraValue = _wtxObj.GrossValue - _wtxObj.NetValue; textBox2.Invoke(new Action(() => { textBox2.Text = "Net value : " + _wtxObj.NetValue + " t" + Environment.NewLine + "Gross value : " + _wtxObj.GrossValue + " t" + Environment.NewLine + "Tara value : " + taraValue + " t"; pictureBox1.Image = WTXJetGUISimple.Properties.Resources.NE107_DiagnosisActive; })); /* * textBox2.Invoke(new Action(() => * { * textBox2.Text = "Net:" + WTXObj.netGrossValueStringComment(WTXObj.NetValue, WTXObj.decimals) + WTXObj.unitStringComment() + Environment.NewLine + "Gross:" + WTXObj.netGrossValueStringComment(WTXObj.GrossValue, WTXObj.decimals) + WTXObj.unitStringComment() + Environment.NewLine + "Tara:" + WTXObj.netGrossValueStringComment(taraValue, WTXObj.decimals) + WTXObj.unitStringComment(); + textBox2.TextAlign = HorizontalAlignment.Right; + + //pictureBox1.Image = Properties.Resources.NE107_DiagnosisActive; + + })); */ }
public static void MatchedUserAgents(IWrapper wrapper) { using (var data = wrapper.Pipeline.CreateFlowData()) { data.AddEvidence("header.user-agent", Constants.MobileUserAgent) .Process(); var elementData = data.Get(wrapper.GetEngine().ElementDataKey); IDeviceData device = (IDeviceData)elementData; Assert.AreEqual(1, device.UserAgents.Value.Count); foreach (var matchedUa in device.UserAgents.Value) { foreach (var substring in matchedUa.Split('_', '{', '}')) { Assert.IsTrue(Constants.MobileUserAgent.Contains(substring), $"The matched substring '{substring}' does not " + $"exist in the original User-Agent."); var index = matchedUa.IndexOf(substring); var original = Constants.MobileUserAgent .Substring(index, substring.Length); Assert.AreEqual(substring, original, $"Expected to find substring '{original}' at character " + $"position {index} but the substring found was " + $"{substring}."); } } } }
// CallbackMethod executed after write to WTX public void WriteDataReceived(IDeviceData deviceValues) { textBox2.Invoke(new Action(() => { textBox2.Text = "write executed"; })); RenameButtonGrossNet(); }
public static void DeviceId(IWrapper wrapper) { using (var data = wrapper.Pipeline.CreateFlowData()) { data.AddEvidence("header.user-agent", Constants.MobileUserAgent) .Process(); var elementData = data.Get(wrapper.GetEngine().ElementDataKey); IDeviceData device = (IDeviceData)elementData; Assert.IsNotNull(device.DeviceId, "The device id should not be null."); Assert.IsTrue(string.IsNullOrEmpty(device.DeviceId.Value) == false, "The device id should not be empty."); } }
public IDeviceDataResult CreateItem(IDeviceData model) { var data = new DeviceData { DeviceDataId = _data.Max(d => d.DeviceDataId) + 1, DeviceId = model.DeviceId, Data = model.Data, TimeStamp = model.TimeStamp, TopicId = model.TopicId }; _data.Add(data); return(new DeviceDataSuccessResult() { Item = data }); }
public IDeviceDataResult CreateItem(IDeviceData model) { try { if (IsDeviceValid(model.DeviceId)) { model.TimeStamp = DateTime.Now; return(_deviceDataRepository.CreateItem(model)); } else { return(new DeviceDataFailureResult()); } } catch (Exception e) { var failure = new DeviceDataFailureResult(); failure.AddData(new List <string> { e.Message }); return(failure); } }
private void callbackMethod(IDeviceData obj) { }
private void WriteDataCompleted(IDeviceData obj) { throw new NotImplementedException(); }
private void callbackMethod(IDeviceData obj) { throw new NotImplementedException(); }
private void OnWriteData(IDeviceData obj) { }
private void OnReadData(IDeviceData obj) { }
private IDeviceData _deviceData; // Service om data op te halen public DeviceController(IDeviceData deviceData) { _deviceData = deviceData; }
public IndexModel(IConfiguration config, IDeviceData deviceData) { this.config = config; this.deviceData = deviceData; }
public IDeviceDataResult CreateItem(IDeviceData model) { throw new NotImplementedException(); }
// Still not working : /* * [Test, TestCaseSource(typeof(WriteTestsModbus), "AsyncWriteBackgroundworkerCase")] * public bool AsyncWriteBackgroundworkerTest(Behavior behavior) * { * var runner = new BackgroundWorker(); * * testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); * _wtxObj = new WtxModbus(testConnection, 200); * * _wtxObj.Connect(this.OnConnect, 100); * * ManualResetEvent done = new ManualResetEvent(false); * * runner.RunWorkerCompleted += delegate { done.Set(); }; * * runner.RunWorkerAsync(); * * DateTime end = DateTime.Now.AddSeconds(20); * bool res = false; * * while ((!res) && (DateTime.Now < end)) * { * _wtxObj.Async_Call(0x2, callbackMethod); // Read data from register * * res = done.WaitOne(0); * } * return res; * } */ // Callback method for writing on the WTX120 device: private void OnWriteData(IDeviceData obj) { throw new NotImplementedException(); }
public DetailModel(IDeviceData deviceData) { this.deviceData = deviceData; }
private void Write_DataReceived(IDeviceData obj) { throw new NotImplementedException(); }
private void WriteDataCompleted(IDeviceData obj) { }