Пример #1
0
        internal void Add(double Minium, double Maximum, TraceLoggerPlus TL)
        {
            TL.LogMessage("AxisRates.Add", "Before m_Rates.Length: " + m_Rates.Length);
            Rate r = new Rate(Minium, Maximum);                 // Create a new rate to add to the new array

            Rate[] NewRateArray = new Rate[m_Rates.Length + 1]; // Create a new Rate array to replace the current one
            TL.LogMessage("AxisRates.Add", "NewRateArray.Length: " + NewRateArray.Length);
            Array.Copy(m_Rates, NewRateArray, m_Rates.Length);  // Copy the current contents of the m_Rated array to the new array
            NewRateArray[m_Rates.Length] = r;                   // Add the new rate the the new Rates array.
            m_Rates = NewRateArray;                             // Make m_Rates point at the new larger array
            TL.LogMessage("AxisRates.Add", "After m_Rates.Length: " + m_Rates.Length);
        }
Пример #2
0
 public ServerConfigurationForm(TraceLoggerPlus Logger, string serviceType, string ipAddressString, decimal portNumber, string userName, string password) : this()
 {
     TL = Logger;
     TL.LogMessage("ServerConfigurationForm", "Form initialiser starting");
     deviceNumberIndexes  = new Dictionary <string, int>();
     configuredDevices    = new Dictionary <string, ConfiguredDevice>();
     this.serviceType     = serviceType;
     this.ipAddressString = ipAddressString;
     this.portNumber      = portNumber;
     this.userName        = userName;
     this.password        = password;
     TL.LogMessage("ServerConfigurationForm", "Form initialiser completed");
 }
Пример #3
0
        private void cmbDeviceType_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "Clearing items");
                cmbDevice.Items.Clear();

                TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "Setting selected index to -1");
                cmbDevice.SelectedIndex = -1;

                TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "Resetting instance number");
                DeviceNumber = 0;

                if (cmbDeviceType.SelectedItem.ToString() == SharedConstants.DEVICE_NOT_CONFIGURED)
                {
                    TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "\"None\" device type selected");
                    cmbDevice.Items.Clear();
                    cmbDevice.SelectedIndex = -1;
                    cmbDevice.ResetText();
                    cmbDevice.Enabled = false;
                    description       = "";
                    progID            = SharedConstants.DEVICE_NOT_CONFIGURED;
                }
                else
                {
                    cmbDevice.Enabled = true;
                    TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "Real device type has been selected");
                }


                if (recalculate)
                {
                    setupForm.RecalculateDeviceNumbers();
                    recalculate = false;
                }

                // Set up device list so we can translate ProgID to description

                ArrayList devices = profile.RegisteredDevices(cmbDeviceType.SelectedItem.ToString());
                TL.LogMessage(0, 0, 0, "cmbDeviceType_Changed", "Created registered device arraylist");

                deviceDictionary.Clear();
                foreach (KeyValuePair kvp in devices)
                {
                    if (!deviceDictionary.ContainsKey(kvp.Value))
                    {
                        deviceDictionary.Add(kvp.Key, kvp.Value);
                    }
                    cmbDevice.Items.Add(kvp.Value);
                }
                if (cmbDevice.Items.Count > 0)
                {
                    cmbDevice.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #4
0
        public void InitUI(ServerConfigurationForm parent, TraceLoggerPlus Logger)
        {
            setupForm = parent;
            TL        = Logger;
            TL.LogMessage(0, 0, 0, "InitUI", "Start");
            profile = new Profile();
            TL.LogMessage(0, 0, 0, "InitUI", "Created Profile");

            cmbDeviceType.Items.Add(SharedConstants.DEVICE_NOT_CONFIGURED);
            TL.LogMessage(0, 0, 0, "InitUI", "Added Device not configured");


            foreach (string deviceType in profile.RegisteredDeviceTypes)
            {
                TL.LogMessage(0, 0, 0, "InitUI", "Adding item: " + deviceType);
                cmbDeviceType.Items.Add(deviceType);
                deviceTypes.Add(deviceType); // Remember the device types on this system
            }
            TL.LogMessage(0, 0, 0, "InitUI", "Setting selected index to 0");

            cmbDeviceType.SelectedIndex = 0;
            TL.LogMessage(0, 0, 0, "InitUI", "Finished");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DomeBaseClass"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public DomeBaseClass(string RequiredDriverNumber, string RequiredDriverDisplayName, string RequiredProgId)
        {
            try
            {
                // Initialise variables unique to this particular driver with values passed from the calling class
                DriverNumber      = RequiredDriverNumber;
                DriverDisplayName = RequiredDriverDisplayName; // Driver description that displays in the ASCOM Chooser.
                DriverProgId      = RequiredProgId;

                if (TL == null)
                {
                    TL = new TraceLoggerPlus("", string.Format(SharedConstants.TRACELOGGER_NAME_FORMAT_STRING, DriverNumber, DEVICE_TYPE));
                }
                RemoteClientDriver.ReadProfile(clientNumber, TL, DEVICE_TYPE, DriverProgId,
                                               ref traceState, ref debugTraceState, ref ipAddressString, ref portNumber, ref remoteDeviceNumber, ref serviceType, ref establishConnectionTimeout, ref standardServerResponseTimeout,
                                               ref longServerResponseTimeout, ref userName, ref password, ref manageConnectLocally, ref imageArrayTransferType, ref imageArrayCompression);
                TL.LogMessage(clientNumber, DEVICE_TYPE, string.Format("Trace state: {0}, Debug Trace State: {1}, TraceLogger Debug State: {2}", traceState, debugTraceState, TL.DebugTraceState));
                Version version = Assembly.GetEntryAssembly().GetName().Version;
                TL.LogMessage(clientNumber, DEVICE_TYPE, "Starting initialisation, Version: " + version.ToString());

                clientNumber = RemoteClientDriver.GetUniqueClientNumber();
                TL.LogMessage(clientNumber, DEVICE_TYPE, "This instance's unique client number: " + clientNumber);

                RemoteClientDriver.ConnectToRemoteServer(ref client, ipAddressString, portNumber, serviceType, TL, clientNumber, DEVICE_TYPE, standardServerResponseTimeout, userName, password);

                URIBase = string.Format("{0}{1}/{2}/{3}/", SharedConstants.API_URL_BASE, SharedConstants.API_VERSION_V1, DEVICE_TYPE, remoteDeviceNumber.ToString());
                TL.LogMessage(clientNumber, DEVICE_TYPE, "This devices's base URI: " + URIBase);
                TL.LogMessage(clientNumber, DEVICE_TYPE, "Establish communications timeout: " + establishConnectionTimeout.ToString());
                TL.LogMessage(clientNumber, DEVICE_TYPE, "Standard server response timeout: " + standardServerResponseTimeout.ToString());
                TL.LogMessage(clientNumber, DEVICE_TYPE, "Long server response timeout: " + longServerResponseTimeout.ToString());
                TL.LogMessage(clientNumber, DEVICE_TYPE, "User name: " + userName);
                TL.LogMessage(clientNumber, DEVICE_TYPE, string.Format("Password is Null or Empty: {0}, Password is Null or White Space: {1}", string.IsNullOrEmpty(password), string.IsNullOrWhiteSpace(password)));
                TL.LogMessage(clientNumber, DEVICE_TYPE, string.Format("Password length: {0}", password.Length));

                TL.LogMessage(clientNumber, DEVICE_TYPE, "Completed initialisation");
            }
            catch (Exception ex)
            {
                TL.LogMessageCrLf(clientNumber, DEVICE_TYPE, ex.ToString());
            }
        }
Пример #6
0
        private void SetupDialogForm_Load(object sender, EventArgs e)
        {
            TL.LogMessage("SetupForm Load", "Start");

            this.Text = DriverDisplayName + " Configuration";
            addressList.Items.Add(SharedConstants.LOCALHOST_NAME);

            cmbServiceType.Text = ServiceType;

            int selectedIndex = 0;

            if (IPAddressString != SharedConstants.LOCALHOST_NAME)
            {
                addressList.Items.Add(IPAddressString);
                selectedIndex = 1;
            }

            IPHostEntry host;
            IPAddress   localIP = null;

            host = Dns.GetHostEntry(Dns.GetHostName());
            bool found = false;

            foreach (IPAddress ip in host.AddressList)
            {
                if ((ip.AddressFamily == AddressFamily.InterNetwork) & !found)
                {
                    localIP = ip;
                    TL.LogMessage("GetIPAddress", "Found IP Address: " + ip.ToString());
                    found = true;
                    if (ip.ToString() != IPAddressString) // Only add addresses that are not the currently selected IP address
                    {
                        addressList.Items.Add(ip.ToString());
                    }
                }
                else
                {
                    TL.LogMessage("GetIPAddress", "Ignored IP Address: " + ip.ToString());
                }
            }
            if (localIP == null)
            {
                throw new Exception("Cannot find IP address of this device");
            }

            TL.LogMessage("GetIPAddress", localIP.ToString());
            addressList.SelectedIndex               = selectedIndex;
            numPort.Value                           = PortNumber;
            numRemoteDeviceNumber.Value             = RemoteDeviceNumber;
            numEstablishCommunicationsTimeout.Value = Convert.ToDecimal(EstablishConnectionTimeout);
            numStandardTimeout.Value                = Convert.ToDecimal(StandardTimeout);
            numLongTimeout.Value                    = Convert.ToDecimal(LongTimeout);
            txtUserName.Text                        = UserName.Unencrypt(TL);
            txtPassword.Text                        = Password.Unencrypt(TL);
            chkTrace.Checked                        = TraceState;
            chkDebugTrace.Checked                   = DebugTraceState;
            if (ManageConnectLocally)
            {
                radManageConnectLocally.Checked = true;
            }
            else
            {
                radManageConnectRemotely.Checked = true;
            }

            this.BringToFront();
        }
Пример #7
0
        public void RecalculateDeviceNumbers()
        {
            TL.LogMessage("RecalculateDeviceNumbers", "Start of RecalculateDeviceNumbers");

            // Add a zero entry for each device type on this system
            deviceNumberIndexes.Clear();
            foreach (string device in registeredDeviceTypes)
            {
                deviceNumberIndexes.Add(device, 0);
            }
            TL.LogMessage(0, 0, 0, "RecalculateDeviceNumbers", "Initialised device numbers");

            foreach (string deviceType in registeredDeviceTypes)
            {
                TL.LogMessage(0, 0, 0, "RecalculateDeviceNumbers", "Processing device type: " + deviceType);
                SortedDictionary <string, ServedDeviceClient> servedDevices = new SortedDictionary <string, ServedDeviceClient>();
                foreach (ServedDeviceClient c in this.Controls.OfType <ServedDeviceClient>().Where(asd => asd.DeviceType == deviceType))
                {
                    servedDevices.Add(c.Name, c);
                }
                TL.LogMessage(0, 0, 0, "RecalculateDeviceNumbers", "Added served devices");
                Dictionary <string, string> x = new Dictionary <string, string>();

                foreach (KeyValuePair <string, ServedDeviceClient> item in servedDevices)
                {
                    TL.LogMessage(0, 0, 0, "RecalculateDeviceNumbers", "Processing item number: " + item.Value.Name + " ");
                    if (item.Value.DeviceType == deviceType)
                    {
                        TL.LogMessage(0, 0, 0, "RecalculateDeviceNumbers", "Setting " + deviceType + " item number: " + deviceNumberIndexes[deviceType].ToString());
                        item.Value.DeviceNumber          = deviceNumberIndexes[deviceType];
                        deviceNumberIndexes[deviceType] += 1;
                    }
                }
            }

            TL.LogMessage("RecalculateDeviceNumbers", "End of RecalculateDeviceNumbers");
        }
Пример #8
0
        private void SetupDialogForm_Load(object sender, EventArgs e)
        {
            TL.LogMessage("SetupForm Load", "Start");

            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            this.Text = $"{DriverDisplayName} Configuration - Version {version} - {DeviceType}";
            addressList.Items.Add(SharedConstants.LOCALHOST_NAME_IPV4);

            cmbServiceType.Text = ServiceType;

            int selectedIndex = 0;

            if (IPAddressString != SharedConstants.LOCALHOST_NAME_IPV4)
            {
                addressList.Items.Add(IPAddressString);
                selectedIndex = 1;
            }

            IPHostEntry host;
            IPAddress   localIP = null;

            host = Dns.GetHostEntry(Dns.GetHostName());
            bool found = false;

            foreach (IPAddress ip in host.AddressList)
            {
                if ((ip.AddressFamily == AddressFamily.InterNetwork) & !found)
                {
                    localIP = ip;
                    TL.LogMessage("GetIPAddress", "Found IP Address: " + ip.ToString());
                    found = true;
                    if (ip.ToString() != IPAddressString) // Only add addresses that are not the currently selected IP address
                    {
                        addressList.Items.Add(ip.ToString());
                    }
                }
                else
                {
                    TL.LogMessage("GetIPAddress", "Ignored IP Address: " + ip.ToString());
                }
            }
            if (localIP == null)
            {
                throw new Exception("Cannot find IP address of this device");
            }

            TL.LogMessage("GetIPAddress", localIP.ToString());
            addressList.SelectedIndex               = selectedIndex;
            numPort.Value                           = PortNumber;
            numRemoteDeviceNumber.Value             = RemoteDeviceNumber;
            numEstablishCommunicationsTimeout.Value = Convert.ToDecimal(EstablishConnectionTimeout);
            numStandardTimeout.Value                = Convert.ToDecimal(StandardTimeout);
            numLongTimeout.Value                    = Convert.ToDecimal(LongTimeout);
            txtUserName.Text                        = UserName.Unencrypt(TL);
            txtPassword.Text                        = Password.Unencrypt(TL);
            chkTrace.Checked                        = TraceState;
            chkDebugTrace.Checked                   = DebugTraceState;
            if (ManageConnectLocally)
            {
                radManageConnectLocally.Checked = true;
            }
            else
            {
                radManageConnectRemotely.Checked = true;
            }

            CmbImageArrayTransferType.Items.Add(SharedConstants.ImageArrayTransferType.JSON);
            CmbImageArrayTransferType.Items.Add(SharedConstants.ImageArrayTransferType.Base64HandOff);
            CmbImageArrayTransferType.SelectedItem = ImageArrayTransferType;

            cmbImageArrayCompression.Items.Add(SharedConstants.ImageArrayCompression.None);
            cmbImageArrayCompression.Items.Add(SharedConstants.ImageArrayCompression.Deflate);
            cmbImageArrayCompression.Items.Add(SharedConstants.ImageArrayCompression.GZip);
            cmbImageArrayCompression.Items.Add(SharedConstants.ImageArrayCompression.GZipOrDeflate);
            cmbImageArrayCompression.SelectedItem = ImageArrayCompression;

            // Make the ImageArray transfer configuration drop-downs visible only when a camera driver is being accessed.
            if (DeviceType == "Camera")
            {
                cmbImageArrayCompression.Visible    = true;
                CmbImageArrayTransferType.Visible   = true;
                LabImageArrayConfiguration1.Visible = true;
                LabImageArrayConfiguration2.Visible = true;
            }
            else
            {
                cmbImageArrayCompression.Visible    = false;
                CmbImageArrayTransferType.Visible   = false;
                LabImageArrayConfiguration1.Visible = false;
                LabImageArrayConfiguration2.Visible = false;
            }

            // Handle cases where the stored registry value is not one of the currently supported modes
            if (CmbImageArrayTransferType.SelectedItem == null)
            {
                CmbImageArrayTransferType.SelectedItem = SharedConstants.IMAGE_ARRAY_TRANSFER_TYPE_DEFAULT;
            }
            if (cmbImageArrayCompression.SelectedItem == null)
            {
                cmbImageArrayCompression.SelectedItem = SharedConstants.IMAGE_ARRAY_COMPRESSION_DEFAULT;
            }

            this.BringToFront();
        }