// Method executed after read from WTX by eventbased call from WTX120Modbus, UpdateEvent(..) // Updates displayed values and states //public void ReadDataReceived(IDeviceValues deviceValues) private void ValuesOnConsole(object sender, DataEvent e) { if (_wtxObj.LimitStatus == 0) //Check for Errors { int taraValue = _wtxObj.GrossValue - _wtxObj.NetValue; 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; })); } else { textBox2.Invoke(new Action(() => { pictureBox1.Image = Properties.Resources.NE107_OutOfSpecification; textBox2.Text = _wtxObj.LimitStatusStringComment(/*WTXObj.limitStatus*/); textBox2.TextAlign = HorizontalAlignment.Left; })); } if (_wtxObj.WeightMoving != 0) { toolStripLabel2.Text = "Moving"; } else //Not moving { toolStripLabel2.Text = ""; } if (_wtxObj.WeightType == 0) { toolStripLabel3.Text = "Gross"; } else { toolStripLabel3.Text = "Net"; } RenameButtonGrossNet(); }
public void testModbus_NetGrossValueStringComment_6D(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.Async_Call(0x00, OnReadData); Thread.Sleep(10); //testConnection.ReadRegisterPublishing(new DataEvent(new ushort[58], new string[58])); string strValue = _wtxObj.NetGrossValueStringComment(_wtxObj.GrossValue, 6 /*_wtxObj.Decimals*/); double dValue = _wtxObj.GrossValue / Math.Pow(10, 6 /*_wtxObj.Decimals*/); Assert.AreEqual(dValue.ToString("0.000000"), strValue); }