Beispiel #1
0
 public int Control(int iPort, ushort wCommand, ref sr_h.sr_mult_rdout2 pvArg)
 {
     return(0);
 }
Beispiel #2
0
        //* <f> */
        //*============================================================================
        //*
        //* function name: sr_get_data()
        //*
        //* purpose: check for shift register stopped, and if so read the data and
        //*	    put it in the database run record.
        //*
        //* return value: SR_SUCCESS/SR_NOT_FINISHED/ZERO_COUNT_TIME/SR_TRY_AGAIN/FAIL
        //*
        //* special notes: if there is a failure, the shift register port is closed.
        //*
        //* revision history:
        //*
        //*  date	author		revision
        //*  ----	------		--------
        //*  11/30/93	Bill Harker	created
        //*
        //*============================================================================*/
        public unsafe int sr_get_data(ref run_rec_ext run_ptr)
        {
            sr_h.sr_rdout rdout = new sr_h.sr_rdout();		/* sr scaler data */
            sr_h.sr_mult_rdout mult_rdout;	/* sr multiplicity data */
            sr_h.sr_mult_rdout2 mult_rdout2;	/* sr multiplicity data */
            int bincount = sr_h.SR_MAX_MULT;
            byte sr_status;
            int status, mult_status;
            ushort num_trys;
            ushort i, j;

            /* check for shift register stopped */
            sr_status = 0;
            status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_STATUS, ref sr_status);
            if (status != sr_h.SR_SUCCESS)
            {
                status = sr_restart();
                if (status == SUCCESS)
                    return (SR_TRY_AGAIN);
                else
                    return (FAIL);
            }
            if ((sr_status & sr_h.SR_S_FAULT) != 0)
            {
                status = sr_restart();
                if (status == SUCCESS)
                    return (SR_TRY_AGAIN);
                else
                    return (FAIL);
            }
            if (((sr_status & sr_h.SR_S_TIMEOUT) == 0) && ((sr_status & sr_h.SR_S_STOPPED) == 0))
                return (SR_NOT_FINISHED);
            log.TraceEvent(LogLevels.Info, 0x4f32E, "Getting data from the shift register");
            /* get a set of scaler data from the shift register */
            num_trys = 0;
            do
            {
                status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_RDOUT, ref rdout);
                num_trys++;
            } while ((status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));

            /* get a set of multiplicity data from the shift register */
            if ((dsid.SRType == InstrType.MSR4A) ||
                (dsid.SRType == InstrType.PSR) || AMSRFerSher)
            {
                mult_rdout = new sr_h.sr_mult_rdout();	/* sr multiplicity data */
                num_trys = 0;
                do
                {
                    Thread.Sleep(100);		/* allow windows system to execute */
                    mult_status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_MULT_RDOUT, ref mult_rdout);
                    num_trys++;
                } while ((mult_status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));
            }
            else if (JSR15orUNAPMasqueradingAsAMSR || dsid.SRType == InstrType.JSR15 || dsid.SRType == InstrType.UNAP)
            {
                bincount = sr_h.SR_MAX_MULT2;
                mult_rdout2 = new sr_h.sr_mult_rdout2();	/* 512 sr multiplicity data */
                num_trys = 0;
                do
                {
                    Thread.Sleep(100);		/* allow windows system to execute */
                    mult_status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_MULT_RDOUT2, ref mult_rdout2);
                    num_trys++;
                } while ((mult_status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));
            }
            else
            {
                mult_rdout = new sr_h.sr_mult_rdout();
                mult_status = sr_h.SR_SUCCESS;
                mult_rdout.n = bincount;
                for (j = 0; j < bincount; j++)
                {
                    mult_rdout.rpa[j] = 0;
                    mult_rdout.a[j] = 0;
                }
            }

            if ((status != sr_h.SR_SUCCESS) || (mult_status != sr_h.SR_SUCCESS))
            {
                status = sr_restart();
                if (status == SUCCESS)
                    return (SR_TRY_AGAIN);
                else
                    return (FAIL);
            }
            else if (rdout.time <= 0)
            {
                return (ZERO_COUNT_TIME);
            }

            /* read high voltage */
            if (dsid.SRType == InstrType.JSR12)
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_JSR12_GET_HV,
                    ref run_ptr.run_high_voltage);
            }
            else if ((dsid.SRType == InstrType.PSR) ||
                (dsid.SRType == InstrType.AMSR) || (dsid.SRType == InstrType.UNAP))
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_PSR_GET_HV,
                 ref run_ptr.run_high_voltage);
            }
            else if (dsid.SRType == InstrType.JSR15) // HHMR
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_HHMR_GET_HV,
                    ref run_ptr.run_high_voltage);
            }
            else if (dsid.SRType == InstrType.DGSR)
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_DGSR_GET_HV,
                    ref run_ptr.run_high_voltage);
            }
            else
            {
                run_ptr.run_high_voltage = 0.0;
            }

            /* put shift register data in run record */
            /* use current date and time */
            string dt = String.Empty;
            int x = NCCTransfer.INCC.Gen32.gen_date_time(NCCTransfer.INCC.Gen32.GEN_DTF_IAEA, ref dt);

            //gen_date_time (GEN_DTF_IAEA, &string_addr);
            //strcpy (run_date_time_string, string_addr);
            Byte[] dtba = Encoding.ASCII.GetBytes(dt);
            fixed (byte* rd = run_ptr.run_date,
                    rt = run_ptr.run_time,
                    tst = run_ptr.run_tests)
            {
                TransferUtils.Copy(dtba, 0, rd, 0, INCC.DATE_TIME_LENGTH);
                TransferUtils.Copy(dtba, 9, rt, 0, INCC.DATE_TIME_LENGTH); // ? index?
                TransferUtils.PassPack(tst);

                run_ptr.run_count_time = rdout.time;
                run_ptr.run_singles = rdout.totals;
                run_ptr.run_scaler1 = rdout.totals2;
                run_ptr.run_scaler2 = rdout.totals3;
                run_ptr.run_reals_plus_acc = rdout.rpa;
                if (dsid.SRType == InstrType.DGSR)  // todo: gate_length2, but no-one will ever need it
                {
                    run_ptr.run_acc = rdout.a * (sr_parms.gateLengthMS / sr_parms.gateLengthMS);
                    //  sr_parms.gate_length2);
                }
                else
                {
                    run_ptr.run_acc = rdout.a;
                }

                fixed (double* RA = run_ptr.run_mult_reals_plus_acc, A = run_ptr.run_mult_acc)
                {
                        for (i = 0; i < bincount; i++)
                        {
                            if (bincount == sr_h.SR_MAX_MULT)
                            {
                                RA[i] = mult_rdout.rpa[i];
                                A[i] = mult_rdout.a[i];
                            }
                            else  if (bincount == sr_h.SR_MAX_MULT2)
                            {
                                RA[i] = mult_rdout2.rpa[i];
                                A[i] = mult_rdout2.a[i];
                            }
                        }
                }
            }
            return (sr_h.SR_SUCCESS);
        }
Beispiel #3
0
        //* <f> */
        //*============================================================================
        //*
        //* function name: sr_get_data()
        //*
        //* purpose: check for shift register stopped, and if so read the data and
        //*	    put it in the database run record.
        //*
        //* return value: SR_SUCCESS/SR_NOT_FINISHED/ZERO_COUNT_TIME/SR_TRY_AGAIN/FAIL
        //*
        //* special notes: if there is a failure, the shift register port is closed.
        //*
        //* revision history:
        //*
        //*  date	author		revision
        //*  ----	------		--------
        //*  11/30/93	Bill Harker	created
        //*
        //*============================================================================*/

        public unsafe int sr_get_data(ref run_rec_ext run_ptr)
        {
            sr_h.sr_rdout       rdout = new sr_h.sr_rdout(); /* sr scaler data */
            sr_h.sr_mult_rdout  mult_rdout;                  /* sr multiplicity data */
            sr_h.sr_mult_rdout2 mult_rdout2;                 /* sr multiplicity data */
            int    bincount = sr_h.SR_MAX_MULT;
            byte   sr_status;
            int    status, mult_status;
            ushort num_trys;
            ushort i, j;

            /* check for shift register stopped */
            sr_status = 0;
            status    = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_STATUS, ref sr_status);
            if (status != sr_h.SR_SUCCESS)
            {
                status = sr_restart();
                if (status == SUCCESS)
                {
                    return(SR_TRY_AGAIN);
                }
                else
                {
                    return(FAIL);
                }
            }
            if ((sr_status & sr_h.SR_S_FAULT) != 0)
            {
                status = sr_restart();
                if (status == SUCCESS)
                {
                    return(SR_TRY_AGAIN);
                }
                else
                {
                    return(FAIL);
                }
            }
            if (((sr_status & sr_h.SR_S_TIMEOUT) == 0) && ((sr_status & sr_h.SR_S_STOPPED) == 0))
            {
                return(SR_NOT_FINISHED);
            }
            log.TraceEvent(LogLevels.Info, 0x4f32E, "Getting data from the shift register");
            /* get a set of scaler data from the shift register */
            num_trys = 0;
            do
            {
                status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_RDOUT, ref rdout);
                num_trys++;
            } while ((status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));

            /* get a set of multiplicity data from the shift register */
            if ((dsid.SRType == InstrType.MSR4A) ||
                (dsid.SRType == InstrType.PSR) || AMSRFerSher)
            {
                mult_rdout = new sr_h.sr_mult_rdout();  /* sr multiplicity data */
                num_trys   = 0;
                do
                {
                    Thread.Sleep(100);          /* allow windows system to execute */
                    mult_status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_MULT_RDOUT, ref mult_rdout);
                    num_trys++;
                } while ((mult_status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));
            }
            else if (JSR15orUNAPMasqueradingAsAMSR || dsid.SRType == InstrType.JSR15 || dsid.SRType == InstrType.UNAP)
            {
                bincount    = sr_h.SR_MAX_MULT2;
                mult_rdout2 = new sr_h.sr_mult_rdout2();        /* 512 sr multiplicity data */
                num_trys    = 0;
                do
                {
                    Thread.Sleep(100);          /* allow windows system to execute */
                    mult_status = SRLib.Control(dsid.SerialPort, sr_h.SR_GET_MULT_RDOUT2, ref mult_rdout2);
                    num_trys++;
                } while ((mult_status == sr_h.SR_TIMEOUT) && (num_trys <= SR_NUM_TRYS));
            }
            else
            {
                mult_rdout   = new sr_h.sr_mult_rdout();
                mult_status  = sr_h.SR_SUCCESS;
                mult_rdout.n = bincount;
                for (j = 0; j < bincount; j++)
                {
                    mult_rdout.rpa[j] = 0;
                    mult_rdout.a[j]   = 0;
                }
            }

            if ((status != sr_h.SR_SUCCESS) || (mult_status != sr_h.SR_SUCCESS))
            {
                status = sr_restart();
                if (status == SUCCESS)
                {
                    return(SR_TRY_AGAIN);
                }
                else
                {
                    return(FAIL);
                }
            }
            else if (rdout.time <= 0)
            {
                return(ZERO_COUNT_TIME);
            }

            /* read high voltage */
            if (dsid.SRType == InstrType.JSR12)
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_JSR12_GET_HV,
                            ref run_ptr.run_high_voltage);
            }
            else if ((dsid.SRType == InstrType.PSR) ||
                     (dsid.SRType == InstrType.AMSR) || (dsid.SRType == InstrType.UNAP))
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_PSR_GET_HV,
                            ref run_ptr.run_high_voltage);
            }
            else if (dsid.SRType == InstrType.JSR15) // HHMR
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_HHMR_GET_HV,
                            ref run_ptr.run_high_voltage);
            }
            else if (dsid.SRType == InstrType.DGSR)
            {
                SRLib.Ioctl(dsid.SerialPort, sr_h.SR_DGSR_GET_HV,
                            ref run_ptr.run_high_voltage);
            }
            else
            {
                run_ptr.run_high_voltage = 0.0;
            }

            /* put shift register data in run record */
            /* use current date and time */
            string dt = String.Empty;
            int    x  = NCCTransfer.INCC.Gen32.gen_date_time(NCCTransfer.INCC.Gen32.GEN_DTF_IAEA, ref dt);

            //gen_date_time (GEN_DTF_IAEA, &string_addr);
            //strcpy (run_date_time_string, string_addr);
            Byte[] dtba = Encoding.ASCII.GetBytes(dt);
            fixed(byte *rd = run_ptr.run_date,
                  rt       = run_ptr.run_time,
                  tst      = run_ptr.run_tests)
            {
                TransferUtils.Copy(dtba, 0, rd, 0, INCC.DATE_TIME_LENGTH);
                TransferUtils.Copy(dtba, 9, rt, 0, INCC.DATE_TIME_LENGTH); // ? index?
                TransferUtils.PassPack(tst);

                run_ptr.run_count_time     = rdout.time;
                run_ptr.run_singles        = rdout.totals;
                run_ptr.run_scaler1        = rdout.totals2;
                run_ptr.run_scaler2        = rdout.totals3;
                run_ptr.run_reals_plus_acc = rdout.rpa;
                if (dsid.SRType == InstrType.DGSR)  // todo: gate_length2, but no-one will ever need it
                {
                    run_ptr.run_acc = rdout.a * (sr_parms.gateLengthMS / sr_parms.gateLengthMS);
                    //  sr_parms.gate_length2);
                }
                else
                {
                    run_ptr.run_acc = rdout.a;
                }

                fixed(double *RA = run_ptr.run_mult_reals_plus_acc, A = run_ptr.run_mult_acc)
                {
                    for (i = 0; i < bincount; i++)
                    {
                        if (bincount == sr_h.SR_MAX_MULT)
                        {
                            RA[i] = mult_rdout.rpa[i];
                            A[i]  = mult_rdout.a[i];
                        }
                        else if (bincount == sr_h.SR_MAX_MULT2)
                        {
                            RA[i] = mult_rdout2.rpa[i];
                            A[i]  = mult_rdout2.a[i];
                        }
                    }
                }
            }

            return(sr_h.SR_SUCCESS);
        }