static void Main(string[] args) { ScaleData sd = new ScaleData { BaudRate = 9600, DataBits = 7, Parity = (System.IO.Ports.Parity) 2, PortName = "COM5", StartBits = 1, StopBits = (System.IO.Ports.StopBits) 1, StartString = "ABCD,", StopString = "kg", WeightRegex = @"[0-9 +-]*", Tare = 800 }; //in this sample the received data is "ABCD, -100kg" ScaleReader sr = new ScaleReader(sd); while (true) { sr.Read(); Console.WriteLine(sr.LastReadWeight); Thread.Sleep(100); } }
private void MainScreen_Load(object sender, EventArgs e) { MessageLogger.SetLogControl(this.messageLog1); this.Text += " - " + CommonData.sapSettings.device; btnRecord.Visible = false; grpBoxSelectedMaterial.Visible = false; barcodeScanner1.startRunning(this); if (CommonData.localSettings.OtherPackingStationPort != 0) { backgroundWorker1.RunWorkerAsync(); } txtUserName.Text = string.Format("User: {0}", ThisApp.user); // Do main application initialisation in a separate thread, showing the startup dialog while we're waiting new BusyDialog(ThisApp.Initialise).ShowDialog(); if (CommonData.slDates.Count > 0) { reworkDateSel = CommonData.slDates[0]; } scaleIndicator1.SetReader(ScaleReader.GetScaleReader()); ThisApp.scale = scaleIndicator1; buttonMatrix1.Setup(4, 2, CommonData.normalOrders.Cast <ButtonMatrix.MatrixObject>().ToList()); numericKeypad1.ValueChanged += HandleFilterValueChanged; buttonMatrix1.ButtonSelected += HandleButtonSelected; barcodeScanner1.BarcodeRead += HandleBarcodeScanned; UpdateModeText(); }