How To Collect Readings Done After Port Opened
Feb 1, 2011
I'm using the .NET SerialPort class to communicate with gauges. Every time a button on a gauge is pressed a reading value is sent over port. The problem I have is that if the gauge button is pressed while the program is off then when the program starts it fires the data received event for that existing data. I don't want this behavior -- I only want to collect readings done after the port is opened.
port = New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)
port.Open()
port.DtrEnable = True
System.Threading.Thread.Sleep(100)
port.ReadExisting()
AddHandler port.DataReceived, AddressOf PortDataReceived
If I don't have the Thread.Sleep then the DataReceived event is fired for the previous gauge data. I'm guessing this is because the ReadExisting doesn't block and so when its called immediately after an open it just reads nothing. So if you call 'port.BytesToRead()' immediately after open its zero. If you call it 100ms after open its non-zero. I guess this makes sense -- it takes time after open to read the existing data. Another option is to call read and set the read timeout but that seems no different than Thread.Sleep except you have to catch an exception...
View 1 Replies
ADVERTISEMENT
Oct 19, 2009
If I have posted this question in the wrong forum, please tell me how to find the correct forum.
I am working on an application that presents the average of a list of compass readings. The readings are wind directions. The problem occurs when the wind is oscillating around North. Some of the readings will be in the 300's, other readings can be 1, 2, 10, etc. degress. (A compass reads from 1 to 360 degress. 360 degrees is the same as 0 degrees.
You can't just average the numbers. For example, if you had two readings, 355 degrees and 5 degrees, just averaging the two results in an answer of 180 degrees. The correct answer is either 360 degrees or 000 degrees.
Most likely I can code data analysis logic to look for the problem, but I am hoping there is a simplier way. Does anybody know the answer?
View 9 Replies
Nov 6, 2011
I would like to know if it is possible to get temprature readings of system components using VB.
View 1 Replies
May 24, 2011
Below is my code. I have a system that provides me voltage readings that changes based on a timer (interval of 300 milliseconds). I want to compile voltage readings for over 5 seconds (but I need the timer reading to remain at 300 ms) and then spit out an average of the THAT data. How do I do this? I was thinking of using datasetvalue but wasn't sure.
Public Class Form1
Private Daqboard As MccDaq.MccBoard = New MccDaq.MccBoard(0)
Private RangeSelected As MccDaq.Range = MccDaq.Range.Bip5Volts
Dim ULStat As MccDaq.ErrorInfo
Dim Channel As Integer = 0, DataValue As System.UInt16, EngVolts As Single
[Code] .....
View 6 Replies
Jun 3, 2012
I'm trying to make a gravity application (with speed readings/music player) for in the car.So I've found some sample code to create an event handler in C#, except I don't know any C#. This is the code to add an eventhandler:
motion.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<MotionReading>>(motion_CurrentValueChanged);
How do I do this in VB.NET? as there is no CurrentValueChanged...
View 8 Replies
Jan 24, 2012
My application waits for the user to click twice to draw a rectangle on an image, and use the rectangle to create a clone and save it. Then it restarts with the next rectangle. When I work on a large image (10800x7236) after a few cycles I get an out of memory error. but I still don't understand what's going on, and I would appreciate if some expert out there clarified why it didn't work before and it works now. This is the snippet executed after the user clicks twice, and fails after 5-6 cycles:
[Code]....
View 1 Replies
Mar 11, 2012
I currently have code that creates and inserts ~175,000 names into a table.
What is the quickest way to collect a random first and last name? So far I have tried, Reading from two text files where every name is one line it takes ~2:30 minutes Reading from a table with [first][last] columns takes ~4 minutes
View 4 Replies
Sep 12, 2011
I have a multi-user app which consists of a Windows form (VS2008), and a SQL Express 2008 database. I'm already detecting if the dataset has changed before the user closes the form so I can prompt them to save their changes. What I'd like to do is to capture the changes they've made, and write them to a database table so that users can track all changes made to each record on the DB.What is the best way to grab hold of the data changes before they're written back to the DB and also grab the original records?
View 1 Replies
Nov 18, 2009
I have a SQL server table that has a list of Usernames and a list of points ranging from 1 to 10,000.I want to display the number of points in my VB.NET program from the username given. For example, if I type in "john" in the first box the program will give me a message box saying whatever amount of points "john" has. I'm not really sure about
This is the Table Structure:
Usernames Points
-----------------------------
[code].....
View 1 Replies
Jul 27, 2011
I have a class orderItem it is a parent of Product and service class Im adding product or services in a listcollection. How can I cast service or product for retrieving orderitem?
Public MustInherit Class OrderItem
Private m_enuItemType As TypeOfItem = TypeOfItem.None
Private m_strUserID As String = ""
[Code]....
View 1 Replies
Jun 12, 2010
I have 4 textboxs in my new form. and each of them, i want the data from the db show in the txtbox.[code]...
View 1 Replies
Feb 5, 2009
I collect two sets of data from two different databases, This data is now in two collections. I then join/append the one collection to the other and then put it in to a list view.I really would like to order this list view by the first column without the click event.To make this even harder the First column contains Data that is DateTime and i have found that it orders the items by the day number and not the months or years or time.I have found one way but it then cause's me further agony when doing some checks upon the data within the listview later in my code. This answer is to rearrange the format to "yyyy-MM-dd HH:mm:SS" then using the listview.sorting = sortorder.
View 7 Replies
Mar 11, 2010
i want to create an application that collect data from the rs-232.Someone have a code example with multi rs-232 in thread .I have one pc that have mapping virtual com.
View 1 Replies
Dec 31, 2010
What I need to do is have my application check to see if the last hour that was inserted into the database table is equal to the current hour minus 1 hour when it runs. If it is not equal to the current hour -1 then it needs to go back and download the missing data automatically.
The hours go from 1 to 24 with midnight being the 24th hour as you'll see in my code. My problem is I don't know how to code what I'm trying to do.
Here is the current code:
Private Sub HourDownload()
DeleteFileHour()
If OneHour("C:abcd.pfx", "******") = True Then
[Code]....
View 11 Replies
Dec 10, 2009
I have a windows app (2.0 framework) that's about 860k in size, just a small db app with a couple of data entry screens and a few reports (Cystal) I noticed that when the app starts the mem usage according to task manager is ~11,000k viewing just one report jumps the mem usage to 56,000k. i thought i could reclaim some of that memory by adding some GC.COLLECT() callls, but no luck. Mem usage stays the same in task manager.
So I made an even smaller test app with two forms....Form1 has two buttons , button1 Opens Form2, and button 2 calls GC.COLLECT()
From 2 contains a datagridview and 1 button. The form load for form2 executes the fill for the dataset that populates the datagridview and the button on Form 2 closes the form.
Here's the code for each form....
CODE:
No matter what I've tried so far I cannot seem to reclaim mem that gets used.
View 3 Replies
Aug 11, 2010
I am running into an issue with phrasing the following XML. I need to load the content into a object that is outline in the second code block. I am looking for all items to be Property flags within the Object.
<MigrationType>
<MigrationOption id="1">
<NAME>Project Configuration</NAME>
<DISPLAY>TRUE</DISPLAY>
<PAGE id="1">RequiredItems</PAGE>
[Code]...
View 6 Replies
Jan 29, 2011
I have an application (i've been working on for a long time) that has many tabs and controls and quite a few components And a good deal of design code. And a list box that has around 100k items (i had to put a loader to pass the 3-4 seconds while its loading to prevent it from not-responding)I had a few Gc.collect calls in specific places (mostly after many items are added or removed). When my application loads, i call GC.collect only once at the end of the load. The program consumes around 35K memory by the time its loaded. However, i decided to mess around abit (don't worry i made backups)First i started putting gc.collect in some random places, and to my surprise the memory upon loading was observably decreasing. Then I went ahead and put a macro that puts GC.Collect before every End Sub, Exit Function, Exit Sub, and Return value, there is. Basically every block in my application had atleat one GC.Collect.
I fixed some 6 or 7 silly replace errors and compiled. When the program launched, the memory used at the end of launch was 21K!
At first glance that seemed great, but then i realized switching between tabs was VERY glitchy. and adding new lists took around 10x more time than usual (the loader stayed on for around 20 seconds!) And even though the memory looked good, the program was useless like this.Then i decided to mess around differently. I removed GC.Collect from the entire solution. It was no longer called even once.At first glance, when i launched the app it consumed just under 60K memory. That seemed terrible. However i realized something: even though my program in that state showed on taskmanager that it was consuming alot more memory than usual, it seemed like it was lighter than ever! Switching tabs was faster than before, especially every time i go to the tab that has the listbox control with 100k items. Loading items took around 3-4 seconds, but there was no stutter when the list finished loading whereas before it had an evident 0.3s stutter after the items were added.
This was all surprising to me because i thought GC.Collect was first of all, something that it doesnt matter where or how many times you call it. I thought it was just something that should be called at the end of work and i didnt think it would matter if it was called during work.Second of all, i thought GC.Collect only affected resources that are inaccessible, or resources my program is done with. How come the application feels faster when i don't call it?Third of all, i thought the VB CLR does most of the memory cleaning for me, and that GC.Collect was somewhat of a redundant command. It didn't seem so redundant to me at all considering the difference between using it heavily and not using it at all was around 38K in memory usage!
So i guess my questions are:
1) Do I need to call GC.Collect? WhereWhen do i call it?2) Why does calling it affect performance? And where does one draw the line between that memory stat on taskmanager and the program's performance?3) I also decided to run a small test. Why does a blank vb form application require 10K memory? How accurate is that stat shown on the task manager?
View 3 Replies
Nov 27, 2010
I'm mohammed from Oman ,I'm visual studio.net programmer How I can Read the Data From Barcode Weight scales By Serial port and TcpIp port
View 7 Replies
Jul 31, 2011
In my program; I need to collect a sequence of events in a variable of some sort. Each time the Sub is initiated, it should add one random event to the sequence (so that it gets longer each time) and then run through the sequence.This is rather difficult to express.What I'm trying to do, is create a Simon Says game with the four buttons.After the sequence goes through blinking the buttons, the program must then be able to capture the sequence of button presses by the user and match that to the sequence that the program ran.So, I need to be able to keep track of two sequences in a variable. Arrays?
View 3 Replies
Apr 20, 2012
I have a table on my SQL DB call ReportList which is a list of report. I need to go through that list and interrogate the reportserver, eport by report, to populate a table called ReportParameters. The ReportParameters table has a column for ReportOwnerID which needs to contains the ReportID value of the corresponding (owner) report as listed in the ReportList table.
It needs to work so:- I have a listbox of the reports as per REportList and a GridView that list all the parameters (uniquely - most of the parameters are common to many reports) the idea being that the parameters get set once and the report can be kicked off by selecting them in the ReportList CheckListBox and clicking on Execute. I would like it that as I click on a particular report in the ListView, the relevant parameters in the Gridview get a green background and those that do not apply are red. The leftmost column in the gridview contains tha Parameter NAME (not editable) and the next column must be editable to populate the value.
Done so far: I have tried on clicking the Execute button, to build a parameters string in a testbox and call that with the Javascript OpenReportWin() function when I open the report in a new window. This works fine, but my biggest issue it interrogating the reportserver reports to get back a list of parameters and dooping them into a table. I have tried to use a hidden DataGrid bound to a ds onto the reportParamaters table.
I have tried to populate it using a datalist but I cannot get the hang of these thionsg and its looking messy. Their must be a simple clean way of getting the .GetParameters resultset back from the report server and populating the table without having to create a reportviewer object and cycling through the list of reports - it then has to render each report before you can get that list out.
View 1 Replies
May 10, 2012
I get a problem with my program. My program should do :
-Explore folders from a main folder (LOGS)
-See if there are csv files
-Copy the data from CSV (all informations are on the first column)
-Paste it in one xls file (with a sheet for every csv)[code]...
View 2 Replies
Jan 11, 2009
I am just trying to get the information i collect from the pc's hostname and pass it into a db. All the db passwords, location etc are correct but i am getting nothing.
Imports System
Imports Microsoft.Win32
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub DB()
[Code] ......
View 14 Replies
Dec 25, 2011
collect information from core temp ( how to gain information about the CPU directly from the motherboard or windows E.G temperature CPU name ) and use it as a variable within VB.
View 3 Replies
Feb 15, 2012
collect username and password from database for login?
View 2 Replies
Jan 4, 2010
I have an access database with 3 tables, want to collect data from 2 and insert them into a new row in the third (although this seems redundant there are reasons for wanting it that way). I created a form and call the data from the two tables fine, once the form is filled I try to add a new row to the third but it will not add the row even though it is telling me that is has. When I open my access table the record is not there. I am new at this and just can't figure out why it won't work, I have tried several approaches the latest is
Code:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Activate()
Dim IDNUM As String = InputBox("Enter Student ID Number")
'storing the text entered in a string
[Code] .....
View 2 Replies
Jun 10, 2011
I have a routine that is supposed to grab all email addresses within a certain group. The email address list can be well over 1000 emails. When emailing it out though I can only send around 150 emails at a time. So what I i've done is executed a query and threw all the emails into a collection.
How do I now reiterate through the collection grab 100 addresses each time and call the routine to email that group?
Dim emailToGroup As String = ddlEmailTo.SelectedValue
Dim connStr As String = ConfigurationManager.ConnectionStrings("SNA_TRT").ConnectionString
[Code]....
View 1 Replies
Jun 27, 2010
How can I collect details regarding the hardware and software, of a PC? As for registration process of the product (my app), I wish to collect the details of that PC and get it saved into my server.When the client request for a new serial key, because of formatting the PC and other reasons, I would compare the PC details and will issue a new serial key based on the result. (small changes in the PC will not be considered)?
View 2 Replies
Jul 25, 2011
I have a Windows form.in windows form have a combo box that give me a list of available port serial with it code (Dim ports As String() =SerialPort.GetPortNames())for example( Com1,Com8,Com15,...).but I want to give me fullname of serial port in device manager for example in dvice manager is these (Comunication Port(COM1) - Printer Port(LPT1) And USB Serial Port(COM8)).how to Get it?
View 2 Replies
Jun 9, 2010
I would like to detect the Address and Port number of the Parallel Port in computer.
View 4 Replies
Dec 22, 2009
I have a function that returns a date. I want to use a modal window to get the datte value from the user and pass it into the function.
View 1 Replies