public MultiClampCommander(uint serialNumber, uint channel, IClock clock)
        {
            SerialNumber = serialNumber;
            Channel      = channel;
            Clock        = clock;

            UInt32 lParam = MulticlampInterop.MCTG_Pack700BSignalIDs(this.SerialNumber, this.Channel); // Pack the above two into an UInt32
            int    result = Win32Interop.PostMessage(Win32Interop.HWND_BROADCAST, MulticlampInterop.MCTG_OPEN_MESSAGE, (IntPtr)Win32Interop.MessageEvents.WindowHandle, (IntPtr)lParam);

            Win32Interop.MessageEvents.WatchMessage(Win32Interop.WM_COPYDATA, (sender, evtArgs) =>
            {
                // WM_COPYDATA LPARAM is a pointer to a COPYDATASTRUCT structure
                Win32Interop.COPYDATASTRUCT cds;
                cds = (Win32Interop.COPYDATASTRUCT)
                      Marshal.PtrToStructure(evtArgs.Message.LParam, typeof(Win32Interop.COPYDATASTRUCT));

                // WM_COPYDATA structure (COPYDATASTRUCT)
                // dwData -- RegisterWindowMessage(MCTG_REQUEST_MESSAGE_STR)
                // cbData -- size (in bytes) of the MC_TELEGRAPH_DATA structure being sent
                // lpData -- MC_TELEGRAPH_DATA*
                MulticlampInterop.MC_TELEGRAPH_DATA mtd;
                mtd    = (MulticlampInterop.MC_TELEGRAPH_DATA)Marshal.PtrToStructure(cds.lpData, typeof(MulticlampInterop.MC_TELEGRAPH_DATA));
                var md = new MulticlampInterop.MulticlampData(mtd);

                OnParametersChanged(md);
            });
        }
        void Dispose(bool disposing)
        {
            if (!this._disposed)
            {
                UInt32 lParam = MulticlampInterop.MCTG_Pack700BSignalIDs(this.SerialNumber, this.Channel); // Pack the above two into an UInt32
                int    result = Win32Interop.PostMessage(Win32Interop.HWND_BROADCAST, MulticlampInterop.MCTG_CLOSE_MESSAGE, (IntPtr)Win32Interop.MessageEvents.WindowHandle, (IntPtr)lParam);

                // Note disposing has been done.
                _disposed = true;
            }
        }
示例#3
0
 public MulticlampParametersChangedArgs(IClock clock, MulticlampInterop.MulticlampData data)
     : base(clock)
 {
     this.Data = data;
 }
示例#4
0
 private static void CheckScaleFactorUnits(MulticlampInterop.MulticlampData deviceParams, MulticlampInterop.ScaleFactorUnits[] allowedScaleFactorUnits)
 {
     if (!allowedScaleFactorUnits.Contains(deviceParams.ScaleFactorUnits))
         throw new MulticlampDeviceException(deviceParams.ScaleFactorUnits + " is not an allowed unit conversion for scaled output mode.");
 }
示例#5
0
        public Measurement Convert(Measurement incoming, string outgoingUnits, MulticlampInterop.MulticlampData deviceParams)
        {
            MulticlampInterop.ScaleFactorUnits[] allowedScaleFactorUnits;

            switch (deviceParams.ScaledOutputSignal)
            {
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_VC_GLDR_I_MEMB:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_IC_GLDR_I_CMD_MEMB:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_IC_GLDR_I_CMD_SUMMED:

                    allowedScaleFactorUnits = new[] {
                            MulticlampInterop.ScaleFactorUnits.V_A,
                            MulticlampInterop.ScaleFactorUnits.V_mA,
                            MulticlampInterop.ScaleFactorUnits.V_nA,
                            MulticlampInterop.ScaleFactorUnits.V_uA,
                            MulticlampInterop.ScaleFactorUnits.V_pA
                        };

                    CheckScaleFactorUnits(deviceParams, allowedScaleFactorUnits);

                    return null;
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_IC_GLDR_V_MEMBx10:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_IC_GLDR_V_MEMBx100:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_VC_GLDR_V_CMD_EXT:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_VC_GLDR_V_CMD_MEMB:
                case MulticlampInterop.SignalIdentifier.AXMCD_OUT_PRI_VC_GLDR_V_CMD_SUMMED:

                    allowedScaleFactorUnits = new[] {
                        MulticlampInterop.ScaleFactorUnits.V_mV,
                        MulticlampInterop.ScaleFactorUnits.V_uV,
                        MulticlampInterop.ScaleFactorUnits.V_V
                    };

                    CheckScaleFactorUnits(deviceParams, allowedScaleFactorUnits);

                    return null;
                default:
                    throw new ArgumentOutOfRangeException("Unsupported ScaledOutputSignal mode: " + deviceParams.ScaledOutputSignal);
            }
        }
示例#6
0
 private void OnParametersChanged(MulticlampInterop.MulticlampData data)
 {
     lock (_eventLock)
     {
         if (ParametersChanged != null)
         {
             ParametersChanged(this, new MulticlampParametersChangedArgs(Clock, data));
         }
     }
 }