Esempio n. 1
0
        // 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;
             +
             + }));
             */
        }
Esempio n. 2
0
 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}.");
             }
         }
     }
 }
Esempio n. 3
0
        // CallbackMethod executed after write to WTX
        public void WriteDataReceived(IDeviceData deviceValues)
        {
            textBox2.Invoke(new Action(() =>
            {
                textBox2.Text = "write executed";
            }));

            RenameButtonGrossNet();
        }
Esempio n. 4
0
 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.");
     }
 }
Esempio n. 5
0
        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
            });
        }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
 private void callbackMethod(IDeviceData obj)
 {
 }
Esempio n. 8
0
 private void WriteDataCompleted(IDeviceData obj)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
 private void callbackMethod(IDeviceData obj)
 {
     throw new NotImplementedException();
 }
Esempio n. 10
0
 private void OnWriteData(IDeviceData obj)
 {
 }
Esempio n. 11
0
 private void OnReadData(IDeviceData obj)
 {
 }
Esempio n. 12
0
        private IDeviceData _deviceData; // Service om data op te halen

        public DeviceController(IDeviceData deviceData)
        {
            _deviceData = deviceData;
        }
Esempio n. 13
0
 public IndexModel(IConfiguration config, IDeviceData deviceData)
 {
     this.config     = config;
     this.deviceData = deviceData;
 }
Esempio n. 14
0
 public IDeviceDataResult CreateItem(IDeviceData model)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
        // 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();
        }
Esempio n. 16
0
 public DetailModel(IDeviceData deviceData)
 {
     this.deviceData = deviceData;
 }
Esempio n. 17
0
 private void Write_DataReceived(IDeviceData obj)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 private void WriteDataCompleted(IDeviceData obj)
 {
 }