Esempio n. 1
0
 public void Connect()
 {
     m_DDK.AuditMessage(AuditLevel.Normal, "ExampleLCSystemDriver.OnConnect");
     m_LCSystem.OnConnect();
     m_Pump.OnConnect();
     m_Sampler.OnConnect();
     m_Detector.OnConnect();
 }
        /// <summary>
        /// This method is called to exchange data (string) with the driver. The main purpose
        /// is to communicate with the driver configuration module.
        /// </summary>
        /// <remarks>
        /// Note that OnSendReceive can be called BEFORE Init, therefore we receive the calling
        /// IDDK instance as a parameter. When a driver is initially added to the instrument,
        /// it is loaded but it will not be initialized until the user has confirmed the
        /// configuration.
        /// </remarks>
        /// <param name="cmDDK">The DDK instance</param>
        /// <param name="inputString">The string which is sent to the driver</param>
        /// <param name="outputString">The answer string from the driver</param>
        public void OnSendReceive(IDDK cmDDK, string inputString, out string outputString)
        {
            // Write the input to the audit trail.
            cmDDK.AuditMessage(AuditLevel.Message, "OnSendReceive: inputString = " + inputString);

            // Fill in some response.
            outputString = DateTime.Now.ToString() + " - " + inputString;
            cmDDK.AuditMessage(AuditLevel.Message, "OnSendReceive: outputString = " + outputString);
        }
Esempio n. 3
0
        public void Init(IDDK cmDDK)
        {
            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // Send a message to the audit trail
            cmDDK.AuditMessage(AuditLevel.Message, "MyCompany.TempCtrlDriver.Init()");

            m_TempCtrlDevice = new TempCtrlDevice();
            m_TempCtrlDevice.Create(cmDDK, configurationParser.GetDeviceName("Oven Device"));
        }
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            // Send a message to the audit trail
            cmDDK.AuditMessage(AuditLevel.Message, "MyCompany.TimeTableDriver.Driver.Init()");

            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // Create our device.
            m_Device = new TimeTableDevice();
            m_Device.Create(cmDDK, configurationParser.GetDeviceName("Time Table Device"));
        }
Esempio n. 5
0
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            // Send a message to the audit trail
            cmDDK.AuditMessage(AuditLevel.Message, "SinusChannel.Driver.Init()");

            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // create our channel
            m_Channel = new Channel();
            m_Channel.Create(cmDDK, configurationParser.GetDeviceName("Sinus Channel"));

            m_TimestampedChannelEx = new TimestampedChannelEx();
            m_TimestampedChannelEx.Create(cmDDK, configurationParser.GetDeviceName("Timestamped Sinus Channel Ex"));
        }
Esempio n. 6
0
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            // Send a message to the audit trail
            cmDDK.AuditMessage(AuditLevel.Message, "MyCompany.ExampleDriver.Driver.Init()");

            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // Create our devices.
            m_Device1 = new ExampleDevice();
            m_Device1.Create(cmDDK, configurationParser.GetDeviceName("Example Device 1"));

            m_Device2 = new ExampleDevice();
            m_Device2.Create(cmDDK, configurationParser.GetDeviceName("Example Device 2"));
        }
Esempio n. 7
0
        public void AuditMessage(AuditLevel level, string text, string callerMethodName = null)
        {
            if (string.IsNullOrEmpty(callerMethodName))
            {
                callerMethodName = CallerMethodName;
            }

            if (m_Demo != null)
            {
                m_Demo.AuditMessage(level, text, callerMethodName);
            }
            else
            {
                if (m_DDK != null)
                {
                    m_DDK.AuditMessage(level, text);
                }
                Log.WriteLine(Id, level, text, callerMethodName);
            }
        }
        /// <summary>
        /// Create the Dionex.Chromeleon.Symbols.IDevice and our Properties and Commands
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        /// <param name="name">The name for our device</param>
        /// <returns>our IDevice object</returns>
        internal IDevice Create(IDDK cmDDK, string name)
        {
            // Create our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, "This is a device using an embedded binary data block (blob).");

            // Let the DDK create a data block id.
            // This id will be associated with the driver id and the symbol name of your driver instance.
            m_BlobDataID = m_MyCmDevice.CreateBlobId("MyBlobDataType");

            // Attach to TransferPreflightToRun and OnPreflightEnd in order to report the content of the blob to the audit trail.
            m_MyCmDevice.OnTransferPreflightToRun += OnTransferPfToRun;
            m_MyCmDevice.OnPreflightEnd           += OnPreflightEnd;

            m_MyCmDevice.StoreAdditionalInformation("AdditionalInformation1");
            cmDDK.AuditMessage(AuditLevel.Normal, m_MyCmDevice.GetAdditionalInformation());

            m_MyCmDevice.CustomData = "Some custom data, here, a string, but could be any object";

            return(m_MyCmDevice);
        }
Esempio n. 9
0
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            // Send a message to the audit trail
            cmDDK.AuditMessage(AuditLevel.Message, "MyCompany.NelsonNCI900.Driver.Init()");

            m_DDK = cmDDK;

            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // Which COM port should be used?
            m_ComPort =
                configurationParser.Parameter("Communication", "Port", "COM1");

            // create our master device
            m_MasterDev = new Master(this);
            IDevice iMaster = m_MasterDev.Create(cmDDK, configurationParser.GetDeviceName("Interface"));

            // create our relays
            m_RelayDev = new Relay[(int)NumberOf.Relays];
            for (int i = 0; i < (int)NumberOf.Relays; i++)
            {
                m_RelayDev[i] = new Relay(i, this);
                IDevice pDevice = m_RelayDev[i].Create(cmDDK, configurationParser.GetDeviceName("Relay " + (i + 1).ToString()));
                pDevice.SetOwner(iMaster);
            }

            m_Channel = new Channel[(int)NumberOf.Channels];

            // create our channel
            m_Channel[0] = new Channel(this, 0);
            IChannel channel = m_Channel[0].Create(cmDDK, configurationParser.GetDeviceName("Channel A"));

            channel.SetOwner(iMaster);

            // create our channel
            m_Channel[1] = new Channel(this, 1);
            channel      = m_Channel[1].Create(cmDDK, configurationParser.GetDeviceName("Channel B"));
            channel.SetOwner(iMaster);
        }
Esempio n. 10
0
 void IDriver.Connect()
 {
     m_DDK.AuditMessage(AuditLevel.Normal, "IDriver.Connect() called");
     m_Device.Connect();
 }
Esempio n. 11
0
 void IDriver.Init(IDDK cmDDK)
 {
     m_DDK = cmDDK;
     m_DDK.AuditMessage(AuditLevel.Normal, "IDriver.Init() called");
     m_Device = new Device(m_DDK);
 }
        void IDriverSendReceive.OnSendReceive(IDDK ddk, string xmlTextRequest, out string xmlTextResponse)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }

            XmlCommand.CommandId commandId = XmlCommand.CommandId.Unknown;
            xmlTextResponse = string.Empty;
            try
            {
                bool testError = false;
                if (testError)
                {
                    throw new Exception("IDriverSendReceive.OnSendReceive test error");
                }

                CommandRequest commandRequest = new CommandRequest(xmlTextRequest);
                commandId = commandRequest.Id;
                bool configIsSimulated = commandRequest.IsSimulated;

                switch (commandId)
                {
                case XmlCommand.CommandId.GetIsIdle:
                {
                    bool isIdle;
                    if (configIsSimulated)
                    {
                        isIdle = true;
                    }
                    else
                    {
                        isIdle = true;
                    }
                    CommandGetIsIdle command = new CommandGetIsIdle(commandRequest.XmlText, isIdle);
                    xmlTextResponse = command.XmlText;
                    break;
                }

                case XmlCommand.CommandId.GetFirmwareData:
                {
                    if (IsSimulated == configIsSimulated)
                    {
                        if (!IsCommunicating)
                        {
                            Connect();
                        }
                    }
                    else
                    {
                        if (configIsSimulated)          // IsSimulated is False
                        {
                            SetSimulatedFirmwareData();
                        }
                        else          // IsSimulated is True
                        {
                            // Open communication - this must set the FirmwareUsbAddress
                            try
                            {
                                // Send commands to get whatever data is needed, in this case: FirmwareVersion and SerialNo
                            }
                            finally
                            {
                                // Close communication
                            }
                        }
                    }

                    CommandGetFirmwareData command = new CommandGetFirmwareData(commandRequest.XmlText, FirmwareUsbAddress, FirmwareVersion, SerialNo);
                    xmlTextResponse = command.XmlText;

                    // Wait for while to test how the configuration UI handles these cases
                    Thread.Sleep(3 * 1000);
                    break;
                }

                default:
                    throw new Exception("Unknown command: \"" + commandId.ToString() + "\"");
                }
                Log.TaskEnd(Id, "Response = \"" + xmlTextResponse + "\"");
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                CommandResponse commandResponse = new CommandResponse(commandId, ex);
                xmlTextResponse = commandResponse.XmlText;
                // In general ddk.AuditMessage is not need here. Let the UI display the error from the xmlTextResponse.
                bool showErrorAsAuditTrail = false;
                if (showErrorAsAuditTrail)
                {
                    ddk.AuditMessage(AuditLevel.Error, ex.Message);
                }
            }
        }