Пример #1
0
        //
        // Constructor - Must be public for COM registration!
        //
        public Focuser()
        {
            EventLogger.LogMessage("Constructing new instance of FocusLynx ASCOM Driver 1", System.Diagnostics.TraceLevel.Info);

            // Get a ID for the driver based on it's type, then make it unique by adding a number on the end of it.
            uniqueDriverID = HubFocuserRev2.GetUniqueDriverId(Marshal.GenerateProgIdForType(this.GetType()));
            driverID = Marshal.GenerateProgIdForType(this.GetType());

            myFoc = SharedResources.HubFoc1;
            //Create the list of SupporedActions
            flSupportedActions = new ArrayList();
            flSupportedActions.Add("RefreshConfigNow");
            flSupportedActions.Add("HomeDevice");
            flSupportedActions.Add("CenterDevice");
            flSupportedActions.Add("GetFocuserNumber");
            flSupportedActions.Add("GetDeviceNickname");
            flSupportedActions.Add("SetDeviceNickname");
            flSupportedActions.Add("GetTempCoeffValue");
            flSupportedActions.Add("SetTempCoeffValue");
            flSupportedActions.Add("GetTempCoeffName");
            flSupportedActions.Add("SetTempCoeffName");
            flSupportedActions.Add("GetSelectedTempCompMode");
            flSupportedActions.Add("SetTempCompMode");
            flSupportedActions.Add("GetTempComp");
            flSupportedActions.Add("SetTempComp");
            flSupportedActions.Add("GetLEDBrightness");
            flSupportedActions.Add("SetLEDBrightness");
            flSupportedActions.Add("GetDeviceType");
            flSupportedActions.Add("SetDeviceType");
            flSupportedActions.Add("GetBacklashCompSteps");
            flSupportedActions.Add("SetBacklashCompSteps");
            flSupportedActions.Add("GetBacklashCompEnabled");
            flSupportedActions.Add("SetBacklashCompEnabled");
            flSupportedActions.Add("GetFirmwareVersion");
            flSupportedActions.Add("GetCOMPortName");
            flSupportedActions.Add("ForceHubDisconnect");
            flSupportedActions.Add("GetConnectionType");
            flSupportedActions.Add("SetTempCompAtStart");
            flSupportedActions.Add("GetTempCompAtStart");
            flSupportedActions.Add("SetTempOffset");
            flSupportedActions.Add("GetTempOffset");
            flSupportedActions.Add("SyncPosition");
            flSupportedActions.Add("ResetToDefaults");
            flSupportedActions.Add("GetWiFiConnectionState");
            flSupportedActions.Add("GetWiFiAttachedState");
            flSupportedActions.Add("GetWiFiFirmware");
            flSupportedActions.Add("GetWiFiIPAddress");
            flSupportedActions.Add("GetWiFiNetworkName");
            flSupportedActions.Add("SetWiFiNetworkName");
            flSupportedActions.Add("GetWiFiSecurityType");
            flSupportedActions.Add("SetWiFiSecurityType");
            flSupportedActions.Add("GetWiFiSecurityKey");
            flSupportedActions.Add("SetWiFiSecurityKey");
            flSupportedActions.Add("GetWiFiWEPIndex");
            flSupportedActions.Add("SetWiFiWEPIndex");
            flSupportedActions.Add("WiFiPushChanges");
            flSupportedActions.Add("WiFiResetDefaults");
            flSupportedActions.Add("SetupDialogNonStandard");
        }
        static HubFocuserRev2()
        {
            // Get the connections settings from profile.
            EventLogger.LogMessage("Constructing STATIC HubFocuser class.", System.Diagnostics.TraceLevel.Info);

            Profile p = new Profile();
            p.DeviceType = "Focuser";
            PopulateFocuserTypes();

            connectionMethod = (ConnectionMethods)Enum.Parse(typeof(ConnectionMethods),
                p.GetValue(pDriverID, pConnMeth, "", ConnectionMethods.Serial.ToString()));

            // Add note to inform users that the second profile item is not used to hold settings...
            string msg = "This profile item is not used to store any settings. It's only purpose is to link " +
                " the FocusLynx Focuser 2, shown in the chooser, to a ProgID used for COM object creation.";
            p.WriteValue(pUnusedDriverID, "Note:", msg);

            // Initialize the hubFocusers
            instance1 = new HubFocuserRev2(FOCUSER_NUMBER.ONE);
            instance2 = new HubFocuserRev2(FOCUSER_NUMBER.TWO);

            setupFocuserCommunicator();
        }
        static SharedResources()
        {
            EventLogger.LogMessage("Creating FocusLynx Shared Resources", System.Diagnostics.TraceLevel.Info);
            // Get the stored TraceLevel from the ASCOM Profile and convert it to a usable type.
            Utilities.Profile p = new Utilities.Profile();
            p.DeviceType = "Focuser";
            string level = p.GetValue(SharedProfileDriverID, "Trace Level", "", System.Diagnostics.TraceLevel.Info.ToString());
            System.Diagnostics.TraceLevel traceLevel = (System.Diagnostics.TraceLevel)Enum.Parse(typeof(System.Diagnostics.TraceLevel), level);
            try { EventLogger.LoggingLevel = traceLevel; }
            catch
            {
                // This means someone keyed in an invalid value for trace level. Fix the problem
                p.WriteValue(SharedProfileDriverID, "Trace Level", System.Diagnostics.TraceLevel.Error.ToString());
                EventLogger.LoggingLevel = System.Diagnostics.TraceLevel.Warning;
                EventLogger.LogMessage("Invalid Trace Level string found in settings profile. Value was: "
                    + level + ". Trace Level has been automatically set to Warning now. Problem automatically resolved!", System.Diagnostics.TraceLevel.Warning);
            }

            //myFocuserManager = FocuserManager.GetInstance();    // Focuser Manager is implemented as a singleton just so that
                                                                // there is no chance of creating multiple instances of it.

            hubFocuser1 = HubFocuserRev2.Instance1;
            hubFocuser2 = HubFocuserRev2.Instance2;
            EventLogger.LogMessage("myFocuserManager Created Successfully!", System.Diagnostics.TraceLevel.Info);
        }