Ejemplo n.º 1
0
        /// <summary>
        /// Залоггировать детально RshInitMemory
        /// </summary>
        public static void WriteRshMemory2Log(RshInitMemory rshMemory)
        {
            using (FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.WriteLine("rshMemory.startType: " + rshMemory.startType.ToString());
                    sw.WriteLine("rshMemory.bufferSize: " + rshMemory.bufferSize.ToString());
                    sw.WriteLine("rshMemory.frequency: " + rshMemory.frequency.ToString());
                    sw.WriteLine("rshMemory.control: " + rshMemory.control.ToString());
                    sw.WriteLine("rshMemory.beforeHistory: " + rshMemory.beforeHistory.ToString());
                    sw.WriteLine("rshMemory.startDelay: " + rshMemory.startDelay.ToString());
                    sw.WriteLine("rshMemory.hysteresis: " + rshMemory.hysteresis.ToString());
                    sw.WriteLine("rshMemory.packetNumber: " + rshMemory.packetNumber.ToString());
                    sw.WriteLine("rshMemory.threshold: " + rshMemory.threshold.ToString());
                    sw.WriteLine("rshMemory.controlSynchro: " + rshMemory.controlSynchro.ToString());

                    if (rshMemory.channels != null)
                        sw.WriteLine("rshMemory.channels.Length = " + rshMemory.channels.Length.ToString());
                    else
                        sw.WriteLine("rshMemory.channels.Length = null");

                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Получить RshInitMemory, созданный на основе передаваемого GprFileInfo
        /// </summary>
        public static RshInitMemory GetRshInitMemory(IGprFileInfo fileInfo)
        {
            var rshMemory = new RshInitMemory();

            rshMemory.startType = fileInfo.pythonSettings.startType;
            rshMemory.bufferSize = fileInfo.pythonSettings.bufferSize;
            rshMemory.frequency = fileInfo.pythonSettings.frequency;
            rshMemory.controlSynchro = fileInfo.pythonSettings.controlSynchro;
            rshMemory.startDelay = fileInfo.pythonSettings.startDelay;
            rshMemory.beforeHistory = fileInfo.pythonSettings.preHistory;
            rshMemory.threshold = fileInfo.pythonSettings.threshold;
            rshMemory.hysteresis = fileInfo.pythonSettings.hysteresis;
            rshMemory.channels = new RshChannel[fileInfo.pythonSettings.channels.Length];
            for (int i = 0; i < fileInfo.pythonSettings.channels.Length; i++)
            {
                rshMemory.channels[i] = new RshChannel();
                rshMemory.channels[i].control = fileInfo.pythonSettings.channels[i].control;
                rshMemory.channels[i].delta = fileInfo.pythonSettings.channels[i].delta;
                rshMemory.channels[i].gain = fileInfo.pythonSettings.channels[i].gain;
            }

            return rshMemory;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Получить RshInitMemory, созданный на основе текущего GprFileInfo
        /// </summary>
        public RshInitMemory GetRshInitMemory()
        {
            var rshMemory = new RshInitMemory();

            rshMemory.startType = this.pythonSettings.startType;
            rshMemory.bufferSize = (uint)(this.pythonSettings.bufferSize * this.pythonSettings.channels.Length);
            rshMemory.frequency = this.pythonSettings.frequency;
            rshMemory.controlSynchro = this.pythonSettings.controlSynchro;
            rshMemory.startDelay = this.pythonSettings.startDelay;
            rshMemory.beforeHistory = this.pythonSettings.preHistory;
            rshMemory.threshold = this.pythonSettings.threshold;
            rshMemory.hysteresis = this.pythonSettings.hysteresis;
            rshMemory.channels = new RshChannel[this.pythonSettings.channels.Length];
            for (int i = 0; i < this.pythonSettings.channels.Length; i++)
            {
                rshMemory.channels[i] = new RshChannel();
                rshMemory.channels[i].control = this.pythonSettings.channels[i].control;
                rshMemory.channels[i].delta = this.pythonSettings.channels[i].delta;
                rshMemory.channels[i].gain = this.pythonSettings.channels[i].gain;
            }

            return rshMemory;
        }
Ejemplo n.º 4
0
 private void TryToInitRshMemory(Device device, RshInitMemory memory)
 {
     var st = device.Init(memory);
     rshMem = memory;
     if (st != RSH_API.SUCCESS)
         throw new IOException("RSH_API: " + st.ToString() + " :: " + "device.Init(memory)");
 }
Ejemplo n.º 5
0
 private void InitRshMemory(RshInitMemory rshMemory)
 {
     TryToInitRshMemory(device, rshMemory);
 }
Ejemplo n.º 6
0
        public void Init(bool TimerChecked, RshInitMemory rshMemory, RshInitPort rshPort, CalibrationProperties calibrationProperties)
        {
            Logging.WriteToLog("Connection.Init(...)");

            AddCalibration(calibrationProperties);
            InitRshMemory(rshMemory);
            InitRshPort(rshPort);
        }
Ejemplo n.º 7
0
        public short[] GenerateTestAscan(RshInitMemory rshMem)
        {
            int height = (int)rshMem.bufferSize;
            short[] ascan = new short[height];

            double sig = 15;
            int shift = 100;
            int t2;
            int t1;
            if (rshMem.channels.Length == 1)
            {
                for (int q = 0; q < height; q++)
                {
                    //if (q < 128)
                    //    ascan[q] = Convert.ToInt16(13276);
                    //else
                    //    ascan[q] = Convert.ToInt16(-13276);
                    //ascan[q] = Convert.ToInt16(rand.Next(-32768, 32768));//(-2048, 2047));//Convert.ToInt16(DateTime.Now.Second*4 + 15);
                    //ascan[q] = Convert.ToInt16(DateTime.Now.Second * 546);
                    //if (DateTime.Now.Second*5 < q)
                    //    ascan[q] = Convert.ToInt16(13276);
                    //else
                    //    ascan[q] = Convert.ToInt16(-13276);

            //                    if (DateTime.Now.Second * 5 < q)
            //                        ascan[q] = Convert.ToInt16(1023);
            //                    else
            //                        ascan[q] = Convert.ToInt16(-1024);

                    // mexican hat wavelet
                    t1 = q - shift;
                    t2 = q - 2 * shift - (DateTime.Now.Second * 10 + DateTime.Now.Millisecond / 100) % 200;
                    ascan[q] = Convert.ToInt16(
                        GetMexicanHat(sig, t1, q) + GetMexicanHat(sig, t2, q)
                        + rand.Next(-100, 100)
                        );
                }
            }
            else if (rshMem.channels.Length == 2)
            {
                //for (int q = gprFileInfo.pythonSettings.GetAscanLength(); q < height; q++)
                //{
                //    t = q - shift - gprFileInfo.pythonSettings.GetAscanLength() - DateTime.Now.Second;
                //    ascan[q] = Convert.ToInt16(4000 * 2 / (Math.Sqrt(3 * sig * Math.Sqrt(Math.PI))) * (1 - t * t / sig / sig) * Math.Pow(Math.E, (-t * t / (2 * sig * sig))));
                //}
                int ascanlength = (int)rshMem.bufferSize / rshMem.channels.Length;

                for (int q = 0; q < ascanlength; q++)
                {
                    t1 = q - shift;
                    t2 = q - 2 * shift - (DateTime.Now.Second * 10 + DateTime.Now.Millisecond / 100) % 100;
                    var v1 =
                        GetMexicanHat(sig, t1, q) + GetMexicanHat(sig, t2, q)
                        //+ 100
                        + rand.Next(-100, 100)
                        ;
                    var v2 =
                        -GetMexicanHat(sig, t1, q) - GetMexicanHat(sig, t2, q)
                        + rand.Next(-50, 50)
                        ;
                    ascan[2*q] = Convert.ToInt16(v1);
                    ascan[2*q + 1] = Convert.ToInt16(v2);
                }
            }
            return ascan;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Выполнить подключение к прибору
        /// </summary>
        public bool Connect(bool TimerChecked, RshInitMemory rshMemory, RshInitPort rshPort, CalibrationProperties calibrationProperties)
        {
            RSH_API st; //Код выполнения операции.
            bool res = true;

            Logging.WriteToLog("Connection.Connect(...)");

            try
            {
                EstablishConnection();
                AddCalibration(calibrationProperties);
                AddBoardPortInfo();
                InitRshMemory(rshMemory);
                InitRshPort(rshPort);
                Connected = true;

                Logging.WriteToLog(" the device is connected!");
            }
            catch (IOException e)
            {
                Connected = false;
                st = RSH_API.NET_TCPSOCKETCONNECTFAILED;//(RSH_API)Enum.Parse(typeof(RSH_API), e.Message.Substring(9));
                SayGoodBye(st);
                res = false;
            }

            return res;
        }
Ejemplo n.º 9
0
 public void Connect(bool TimerChecked, RshInitMemory rshMemory, RshInitPort rshPort, CalibrationProperties calibrationProperties)
 {
     Connected = connection.Connect(TimerChecked, rshMemory, rshPort, calibrationProperties);
     if (Processor.Scenario.Any(x => x.GetType() == typeof(ProcessingSynchro)))
         InitSynchroOperation(rshMemory);
 }
Ejemplo n.º 10
0
 private void InitSynchroOperation(RshInitMemory rshMemory)
 {
     var synchroOperation = Processor.Scenario.First(x => x.GetType() == typeof (ProcessingSynchro)) as ProcessingSynchro;
     synchroOperation.ChannelsNum = rshMemory.channels.Length;
     synchroOperation.FlagValue = rshMemory.threshold;
     synchroOperation.Prehistory = rshMemory.beforeHistory;
     synchroOperation.SlopeFront = Convert.ToBoolean(rshMemory.controlSynchro);
 }
Ejemplo n.º 11
0
 public short[] GetTestAscan(RshInitMemory rshMemory)
 {
     var ascans = new List<short[]>();
     for (int i = 0; i < NumberAscansToProcess; i++)
         ascans.Add(connection.GenerateTestAscan(rshMemory));
     return Processor.Process(ascans);
 }