Wednesday, January 20, 2016

Chart Channel

I am now working with the "Chart Channel"-program upgrade. It is a big job, but I believe I will need that with my tour robot project. It will take 2- 4 weeks to complete, The old program don't follow OOP design and possibly I have  compromise. Databases have to turn XML. At this point I have no idea how to make graphics. After couple of weeks I know more.

Saturday, January 9, 2016

C# Step by Step

I have studied the book "Microsoft Visual C# Step by Step". I decided "to go back to school" and it was actually a good decision. There is no shortcut. I hope I get it completed within a week.

I attended today Houston Robotics Club Meetup. We are designing  robots. My feelings are a bit mixed. I have not make any team work in twenty years. I don't know these (6) people and I came there in the middle of the process. I will go there now every Saturday and see what happens. Hopefully all goes well.

It will be busy year 2016, if I get all my plans completed.

Monday, December 28, 2015

Resident Database

I am now concentrated in ASP.NET to get our resident database reports ready this year. I haven't be happy with MS Access reports and I am now investigating Crystal Reports for Visual Studio and Visual Studio's own report tool. I hope I can use the flexibility of LINQ. I used Crystal Reports ten years ago.

It was a time consuming work to figure out, how to transfer MM Access database to SQL Express. I didn't get the conversion tool to work. I transferred the data table by table by converting them first to text. I am naturally overdoing our database, but I want to learn.

Basically the database front end is now designed with the Web Forms. I was planning to go the ASP.NET MVC, but it was too much learning at this point. Eventually I have to do that later.

Front End- design is not so easy with ASP.NET than with MS Access and Visual Studio Windows Forms. I made a lot of googling, but I couldn't find proper solutions. Then I started to make that with the old way. It means start to think:)  All controls on ASP- pages actually create a HTML code. It took a lot of time to profoundly understand  it!  I can now combine data controls with regular controls by editing the source HTML file.

Tuesday, December 22, 2015

Eddie's First Steps

Eddie is now moving!! The serial port problem was actually my simple program bug. I didn't clear one variable.  It is actually seen in my last post in the C# code. My big audience didn't find it:)

My analysis was totally wrong, but I still have problems with receiving data.
I found a good article about serial ports on .NET:

http://www.innovatic.dk/knowledg/SerialCOM/SerialCOM.htm

The picture is from the screen capture from Eddies eyes and brains, Dell laptop.



Sunday, December 20, 2015

Eddie Obeys but won't Give Good Feedback

Eddie is now moving from the  dashboard. Sending commands appeared to be easy, but receiving data is another story. I have tried to read sensors and update form controls and I had only partial success.

I got finally all working by reading serial data byte by byte. Trying to read receive data line by line or the whole buffer didn't work for me. It can be a driver issue or I haven't get the full idea of threading.

Now I cannot clear the receiving buffer. That means I cannot update form fields properly without tricks. All worked very well with VB5&6 in good old times.

I am using now timer to send commands like with VB5.

Anyway, here is the code:

private void SerialPortDataReceived(object sender, SerialDataReceivedEventArgs e)
        {
          
            byte[] buff = new byte[sp.BytesToRead];
               
                int result = sp.Read(buff, 0, sp.BytesToRead);
                /*
                foreach (byte b in buff)
                  
                */
                foreach (byte b in buff)
                {
                RecASCII += b.ToString();
                }
            //string aa = sp.ReadLine();
            //string aaa = sp.ReadExisting();
            Thread.Sleep(100);
            sp.DiscardInBuffer(); // clear buffer
            RecHEX = ASCIITOHex(RecASCII);
          
            this.Invoke((MethodInvoker)delegate
            {
                RightPing.Text = RecHEX;
                LeftPing.Text = RecHEX;
            });

            }

Wednesday, December 16, 2015

Geodesy

I have now studied LINQ (Language Integrated Query) in the ASP project. It is more flexible than normal query language, because I can make queries in the code level. I created our resident database with MS Access and I had difficulties to create complicated queries for reports. This should work

I have tried to check the "Chart Channel" geodesy part. At this point it is overwhelming to me. Unfortunately I never studied  geodesy profoundly and I never knew, what the code is exactly doing. So get a new study project. Typically things are clearing up and I don't need to know all. Just persistent work.

Sunday, December 13, 2015

Pinging

I haven't been lazy this weekend. I am still fighting with threads. It appears to be very fundamental and new to the old Visual Basic - programmer like me. Some progress anyway.

The code below reads Eddie's ping (sonar) sensors and update the form text controls.
Text controls updates happen in the different thread. I had a lot of googling to make this happen. The other option I have check is the Backgroundworker-class.

Things are going slowly now, but I know based on my experience, all will accelerate later.

I have also worked with ASP-study and the VB6 "Charts Channel" with Artinsoft tool. Unfortunately it's free version allows only 10000 lines. So I have to divide the code. The "Charts Channel" is about 23000 lines. Naturally I can remove some code. Artinsoft tool isn't the perfect solution, but it gives some foundation how to do the conversion. 


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;

namespace SimpleEddie


{
public partial class Form1 : Form


{
public Form1()


{
InitializeComponent();
serialPort1.PortName = "COM3";


serialPort1.BaudRate = 115200;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
serialPort1.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);


serialPort1.Open();
string msg = "PING \r";


serialPort1.Write(msg);

}
private void Form1_Load(object sender, EventArgs e)


{

}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)


{
string data = serialPort1.ReadExisting();
if (data != "")


{
string data1 = data.Substring(0, 3);
string data2 = data.Substring(4, 3);
this.Invoke((MethodInvoker)delegate {
LeftPing.Text = data1; // runs on UI thread


RightPing.Text = data2;
});
}

}
}
}