Exemplo n.º 1
0
        private uint Setting_for_Single_Measurment()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_CARDMODE, Regs.SPC_REC_STD_SINGLE);

            Communication_LOG += "Set single measurement:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 2
0
        //Unklar was Trigger 1 bis 3 machen
        private uint Trigger_1()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_TRIG_ORMASK, Regs.SPC_TMASK_NONE);       //aus

            Communication_LOG += "Trigger Set 1:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 3
0
        private uint Set_Range()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_AMP0, Range);

            Communication_LOG += "Range to +/- " + Range.ToString() + "mV:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 4
0
        private uint Set_Frequency()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_SAMPLERATE, Frequency);

            Communication_LOG += "Frequency to " + Frequency.ToString() + "Hz:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 5
0
        private uint Diff_Channel_0to1()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_DIFF0, 1);

            Communication_LOG += "Diff. Channel 0 to 1:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 6
0
        private uint Input_1MOhm_Channel_1()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_50OHM1, 0);

            Communication_LOG += "Input 1MOhm Channel 1:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 7
0
        private uint Activate_Chanel_0()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_CHENABLE, Regs.CHANNEL0);

            Communication_LOG += "Activate Channel 0:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 8
0
        //********************************************************************************************************************
        //                                       Lokale Spectrum Einzelbefehle
        //********************************************************************************************************************

        #region Spectrum_Commands

        private uint Reset()
        {
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_M2CMD, Regs.M2CMD_CARD_RESET);

            Communication_LOG += "RESET:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (cO.ExtDataOrder != null)
            {
                // Сохранение измененных данных
                DataRowView Drv;
                if (Idx < 0)
                {
                    // Если idx<0 то создаем новую запись
                    Drv = Base.classOrder.dataView.AddNew();
                }
                else
                {
                    // определяем запись для редактирования
                    Drv = Base.classOrder.dataView[Idx];
                    Drv.BeginEdit();
                }

                // Производи заполнение измененными данными запись для редактирования
                //Drv.BeginEdit();
                cO.ThisToRow(Drv.Row);
                Drv.EndEdit();
                Base.classOrder.UpdateTable();
            }
            else
            {
                MessageBox.Show(this, "Не выбран тип заказа!", "Внимание!");
            }
        }
Exemplo n.º 10
0
        private uint Did_Trigger_Event_occured()
        {
            //263 is Rückgabewert wenn kein Trigger gefunden wird
            uint errorCode = Drv.spcm_dwSetParam_i64(H_Device, Regs.SPC_M2CMD, Regs.M2CMD_CARD_WAITTRIGGER);

            Communication_LOG += "Trigger found:\n" + errorCode.ToString() + "\n";
            return(errorCode);
        }
Exemplo n.º 11
0
        static void ThrowSpcmException(IntPtr device)
        {
            uint errorReg;
            int  errorValue;
            var  errorText = new StringBuilder(1024);

            Drv.spcm_dwGetErrorInfo_i32(device, out errorReg, out errorValue, errorText);
            throw new SpcmException(errorText.ToString());
        }
Exemplo n.º 12
0
        public Device(string deviceName)
            : base(true)
        {
            var handle = Drv.spcm_hOpen(deviceName);

            if (handle == IntPtr.Zero)
            {
                ThrowSpcmException(handle);
            }

            SetHandle(handle);
            InitializeCardProperties();
        }
Exemplo n.º 13
0
        private void Close()
        {
            //Schließen
            Drv.spcm_vClose(H_Device);
            Communication_LOG += "Connenction canceled\n";

            //Ab hier verbunden
            IsConnected = false;

            //UI anpassen
            button_OpenClose.Text   = "Open";
            Voltage_Trigger.Enabled = false;
        }
Exemplo n.º 14
0
        public bool WaitDma()
        {
            var errorCode = Drv.spcm_dwSetParam_i32(handle, Regs.SPC_M2CMD, Regs.M2CMD_DATA_WAITDMA);

            if (errorCode == Error.ERR_TIMEOUT)
            {
                return(false);
            }
            if (errorCode != 0)
            {
                ThrowSpcmException(handle);
            }

            return(true);
        }
Exemplo n.º 15
0
        public override void Close()
        {
            //Schließen
            Drv.spcm_vClose(H_Device);
            Communication_LOG += "Connenction canceled\n";

            //Ab hier verbunden
            IsConnected = false;

            //UI anpassen
            button_OpenClose.Text         = "Open";
            comboBox_Frequency.Enabled    = false;
            comboBox_Range.Enabled        = false;
            numericUpDown_Trigger.Enabled = false;
        }
Exemplo n.º 16
0
        public override string AutoOpen(AutoConnect_Window myLoadScreen)
        {
            int iterration = 7;

            Communication_LOG += "Try to connect SPECTRUM:\n";

            //Öffnen
            try
            {
                H_Device = Drv.spcm_hOpen(VISA_or_Channel_Name);
            }
            catch (System.DllNotFoundException)
            {
                Communication_LOG += "FAILED!\n";
                return("DAQ-Unit: Connection was not found!" + Environment.NewLine);
            }

            //Prüfen ob verbindung erfolgreich war, sonst abbrechen
            if ((long)H_Device == 0)
            {
                Communication_LOG += "FAILED!\n";
                return("DAQ-Unit: Connection was not seccessfull!" + Environment.NewLine);
            }
            Communication_LOG += "Seccessful\n";

            myLoadScreen.ChangeTask("Reset ...", iterration);

            //Reseten
            ErrorCode_Spectrum += Reset();

            myLoadScreen.ChangeTask("Change UI ...", iterration);

            //Ab hier verbunden
            IsConnected = true;

            //UI anpassen
            button_OpenClose.Text         = "Close";
            comboBox_Frequency.Enabled    = true;
            comboBox_Range.Enabled        = true;
            numericUpDown_Trigger.Enabled = true;

            return("");
        }
Exemplo n.º 17
0
        //********************************************************************************************************************
        //                                         GUI: Open/Close + ComboBoxes
        //********************************************************************************************************************

        #region Open/Close

        public override void Open()
        {
            //Öffnen
            Communication_LOG += "Try to connect SPECTRUM:\n";

            //Öffnen
            try
            {
                H_Device = Drv.spcm_hOpen(VISA_or_Channel_Name);
            }
            catch (System.DllNotFoundException)
            {
                MessageBox.Show("Conection to Spectrum DAQ was NOT found!\nTry again.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Communication_LOG += "FAILED!\n";
                return;
            }

            //Prüfen ob verbindung erfolgreich war, sonst abbrechen
            if ((long)H_Device == 0)
            {
                MessageBox.Show("Conection to Spectrum DAQ was NOT seccessful!\nTry again.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Communication_LOG += "FAILED!\n";
                return;
            }
            Communication_LOG += "Seccessful\n";

            //Reseten
            ErrorCode_Spectrum += Reset();

            //Ab hier verbunden
            IsConnected = true;

            //UI anpassen
            button_OpenClose.Text         = "Close";
            comboBox_Frequency.Enabled    = true;
            comboBox_Range.Enabled        = true;
            numericUpDown_Trigger.Enabled = true;
        }
Exemplo n.º 18
0
        //********************************************************************************************************************
        //                                         Lokale Functionen
        //********************************************************************************************************************

        #region lokal

        private void Open()
        {
            //Öffnen
            Communication_LOG += "Try to connect SPECTRUM:\n";

            //Öffnen
            IP_Adresse = textBox_IP.Text;
            try
            {
                H_Device = Drv.spcm_hOpen(IP_Adresse);
            }
            catch (System.DllNotFoundException)
            {
                MessageBox.Show("Conection to Spectrum DAQ was NOT found!\nTry again.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Communication_LOG += "FAILED!\n";
                return;
            }

            //Prüfen ob verbindung erfolgreich war, sonst abbrechen
            if ((long)H_Device == 0)
            {
                MessageBox.Show("Conection to Spectrum DAQ was NOT seccessful!\nTry again.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Communication_LOG += "FAILED!\n";
                return;
            }
            Communication_LOG += "Seccessful\n";

            //Reseten
            ErrorCode_Spectrum += Reset();

            //Ab hier verbunden
            IsConnected = true;

            //UI anpassen
            button_OpenClose.Text   = "Close";
            Voltage_Trigger.Enabled = true;
        }
Exemplo n.º 19
0
        // подготовка метки по индексу в списке инвентаризации
        private void GetRFIDLabelInfo()
        {
            byte[] aB;

            LReady      = false;
            XTIDPresent = false;
            lSerialInt  = 0;

            aEPC   = new byte[0];
            aTID   = new byte[0];
            aBLR   = new byte[0];
            BinEPC = "";

            nCRC   = nLenEPC = nPC = 0;
            nMDID  = nModNum = 0;
            Secure = false;

            try
            {
                if (Drv.SetDword("RFID.CurrentId", nCurInList))
                {
                    aEPC   = Drv.GetBin("RFID.ChipId");
                    LReady = true;
                    PassLocked();
                    LReady4Write = !aSecured[1];
                    //if (aSecured[1] && (AccessPassword == 0))
                    //{
                    //    return;
                    //}

                    if (Drv.SetBin("RFID.EPCC1G2.Id", aEPC))
                    {
                        // доступ
                        Drv.SetBool("RFID.EPCC1G2.Secured", false);

                        //Drv.SetBool("RFID.EPCC1G2.Secured", aSecured[1]);

                        if (Drv.SetDword("RFID.EPCC1G2.Bank", 2))
                        {// чтение TID
                            int nC = 4;

                            TIDInfo(Drv);

                            bool bOld = Drv.throwsException;
                            Drv.throwsException = false;
                            for (nC = 4; nC <= 12; nC = nC + 2)
                            {
                                Drv.SetDword("RFID.BlockPointer", 0);
                                Drv.SetDword("RFID.BlockCount", nC);
                                aB = Drv.GetBin("RFID.BlockData");
                                if ((aB == null) || (aB.Length == 0))
                                {
                                    continue;
                                }
                                aTID = aB;
                            }
                            Drv.throwsException = bOld;
                            nMDID = ((uint)aTID[2]) >> 4;
                            nMDID = ((uint)aTID[1] << 8) + nMDID;

                            nModNum = ((uint)aTID[2]) & 0x0F;
                            nModNum = (nModNum << 8) + ((uint)aTID[3]);
                        }
                        if (Drv.SetDword("RFID.EPCC1G2.Bank", 1))
                        {// чтение служебной перед EPC
                            Drv.SetDword("RFID.BlockPointer", 0);
                            Drv.SetDword("RFID.BlockCount", 16);
                            aBLR = Drv.GetBin("RFID.BlockData");

                            nCRC    = ((uint)aBLR[0] << 8) + ((uint)aBLR[1]);
                            nPC     = ((uint)aBLR[2] << 8) + ((uint)aBLR[3]);
                            nLenEPC = ((uint)aBLR[2] >> 3);
                        }
                    }
                    else
                    {
                        aBLR = aEPC;
                    }
                }
                //*****
            }
            catch (Exception e)
            {
                LReady = false;
                MessageBox.Show("RFID Error!");
            }
        }
Exemplo n.º 20
0
        // установка флагов парольной защиты
        public bool PassLocked()
        {
            bool
                bOld = Drv.throwsException,
                bRet = false;

            //byte[]
            //    aPass;

            try
            {
                Drv.throwsException = true;
                Drv.SetBool("RFID.EPCC1G2.Secured", false);

                if (Drv.SetDword("RFID.EPCC1G2.Bank", 0))
                {// чтение Pass
                 //Drv.SetDword("RFID.BlockPointer", 0);
                 //Drv.SetDword("RFID.BlockCount", 4);
                 //try
                 //{
                 //    aPass = Drv.GetBin("RFID.BlockData");
                 //}
                 //catch
                 //{
                 //    aSecured[0] = true;
                 //}
                 //Drv.SetDword("RFID.BlockPointer", 4);
                 //Drv.SetDword("RFID.BlockCount", 4);
                 //try
                 //{
                 //    aPass = Drv.GetBin("RFID.BlockData");
                 //}
                 //catch
                 //{
                 //    aSecured[1] = true;
                 //}

                    try
                    {
                        Drv.SetDword("RFID.BlockPointer", 0);
                        Drv.SetDword("RFID.BlockCount", 8);
                        aRes         = Drv.GetBin("RFID.BlockData");
                        KillPassword = (int)Bytes2Int(aRes, 0);
                        if (KillPassword > 0)
                        {
                            aSecured[0] = true;
                        }
                        //AccessPassword = (int)Bytes2Int(aRes, 4);
                        //if (AccessPassword > 0)
                        //    aSecured[1] = true;
                    }
                    catch
                    {
                        bRet            =
                            aSecured[1] = true;
                    }


                    //bRet = true;
                }
            }
            catch
            {
            }
            finally
            {
                Drv.throwsException = bOld;
            }
            return(bRet);
        }
Exemplo n.º 21
0
 protected override bool ReleaseHandle()
 {
     Drv.spcm_vClose(handle);
     return(true);
 }
Exemplo n.º 22
0
        public void SetParam(int register, long value)
        {
            var errorCode = Drv.spcm_dwSetParam_i64(handle, register, value);

            HandleError(handle, errorCode);
        }
Exemplo n.º 23
0
        public void GetParam(int register, out int value)
        {
            var errorCode = Drv.spcm_dwGetParam_i32(handle, register, out value);

            HandleError(handle, errorCode);
        }
Exemplo n.º 24
0
        public void GetContinuousBuffer(uint bufType, out IntPtr buffer, out ulong bufferLength)
        {
            var errorCode = Drv.spcm_dwGetContBuf_i64(handle, bufType, out buffer, out bufferLength);

            HandleError(handle, errorCode);
        }
Exemplo n.º 25
0
        public void DefineTransfer(uint bufType, uint direction, uint notifySize, IntPtr buffer, ulong boardOffset, ulong bufferLength)
        {
            var errorCode = Drv.spcm_dwDefTransfer_i64(handle, bufType, direction, notifySize, buffer, boardOffset, bufferLength);

            HandleError(handle, errorCode);
        }