I have a large public class which called Telescope
. I have created a new form (form1.cs
) and I want to call some of the public void that the class has.
I do something like this in the form to initialise the class
Telescope controls = new Telescope();
controls.CommandString("Gs#",true);
After that I can see the all the methods but it fails in the execution as the class is already initialized and there is an existing serial port connection ongoing, so it reports that there is no serial port connection.
Any help? How can I use the existing methods from the new form?
Telescope class is in Driver.cs
public string CommandString(string command, bool raw)
{
CheckConnected("CommandString");
serialPort.ClearBuffers();
serialPort.Transmit(command);
return serialPort.ReceiveTerminated("#");
}
When I use the CommandString in the Driver.cs (where the telescope class is) it works. It does not work from the form1.cs
I get an exception:
************** Exception Text **************
ASCOM.NotConnectedException: CommandString