Example #1
0
        /// <summary>
        /// Get configuration details and create CSV
        /// </summary>
        /// <param name="receivedPacket"></param>
        private static void GetConfigurationDetails(Packet.Packet receivedPacket)
        {
            try
            {
                ConfigurationVO configVo = ConfigurationVO.GetInstance();
                //receivedPacket.RemoveByte();

                configVo.mode_operation = receivedPacket.RemoveByte(); //Mode of Operation
                configVo.NumberOfSelectedChannels = receivedPacket.RemoveByte();
                configVo.ChannelValue = receivedPacket.RemoveUInt16(); // Channel
                //configVo.adcresolution = receivedPacket.RemoveByte(); // ADC resolution
                //adc_resolution = configVo.adcresolution;
                configVo.sampaling_rate = receivedPacket.RemoveByte(); // Sampling rate
                sampling_rate = configVo.sampaling_rate;
                // MAITREYEE:two paramters added according to the new requirement.
                configVo.T5VDAC = receivedPacket.RemoveByte();
                configVo.T7VDAC = receivedPacket.RemoveByte();

                receivedPacket.UseLittleEndian = true;
                configVo.T1 = receivedPacket.RemoveUInt16();
                configVo.T2 = receivedPacket.RemoveUInt16();
                configVo.T3 = receivedPacket.RemoveUInt16();
                configVo.T4 = receivedPacket.RemoveUInt16();
                configVo.T5 = receivedPacket.RemoveUInt16();
                configVo.T6 = receivedPacket.RemoveUInt16();
                configVo.T7 = receivedPacket.RemoveUInt16();
                configVo.T8 = receivedPacket.RemoveUInt16();
                configVo.T9 = receivedPacket.RemoveUInt16();
                configVo.T10 = receivedPacket.RemoveUInt16();
                receivedPacket.UseLittleEndian = false;
                List<ConfigurationVO> configlist = new List<ConfigurationVO>();
                configlist.Add(configVo);

                string applicationConfigurationPath = ApplicationUtil.ApplicationUtil.GetApplicationPath();
                applicationConfigurationPath += EnumAndConstants.CONFIGURATION_FILE;

                if (ApplicationUtil.ApplicationUtil.CheckFileExists(applicationConfigurationPath) == true)
                {
                    File.Delete(applicationConfigurationPath);
                }

                ApplicationUtil.ApplicationUtil.CreateCSVFromGenericList(configlist, applicationConfigurationPath);
                //if (null != SetStatusEvent)
                //    SetStatusEvent(true, true);
            }
            catch (Exception ex)
            {
                m_logger.Error(ex);
            }
        }
Example #2
0
        /// <summary>
        /// Get trigger mode values
        /// </summary>
        /// <param name="receivedPacket"></param>
        /// <param name="responceId"></param>
        private void GetTriggerModeRequest(Packet.Packet receivedPacket, int responceId)
        {
            if (responceId == (int)ADCStatus.START_ADC)
            {
                //TODO : Make 2 bytes
                ChannelValue = receivedPacket.RemoveUInt16();//CHANNEL ID
                //if (ApplicationUtil.ApplicationUtil.FirstRecievedChannelValue == 0)
                //{
                //    ApplicationUtil.ApplicationUtil.FirstRecievedChannelValue = ChannelValue;
                //}
                //else
                //{
                //    if (ChannelValue == ApplicationUtil.ApplicationUtil.FirstRecievedChannelValue)
                //    {
                //        CreateNewFile = true;

                //    }
                //}

                List<int> channels = new List<int>();
                ApplicationUtil.ApplicationUtil.GetValueFromNumber(ChannelValue, out channels);
                if (channels.Count == 1 && channels.Count!=0)
                {
                    //adc_resolution = 1;
                    ChannelA = channels[0];
                    ChannelB = -1;
                    isBothClicked = false;
                }
                else if (channels.Count > 1 && channels.Count != 0)
                {
                    //adc_resolution = 0;
                    ChannelA = channels[0];
                    ChannelB = channels[1];
                    isBothClicked = true;

                }
                //As per new Doc
                //adc_resolution = receivedPacket.RemoveByte();//adc resolution
                //TODO : 2 byte
                sampling_rate = receivedPacket.RemoveByte();//sampling rate
                receivedPacket.UseLittleEndian = true;
                NUMBER_OF_RECORDS = receivedPacket.RemoveUInt16();//Number of records
                //if (adc_resolution != EnumAndConstants.BIT_CHECKER)
                //{
                //    NUMBER_OF_RECORDS /= 2;
                //}
                receivedPacket.UseLittleEndian = false;

                stateVar = new ReadState();
                stateVar.currentPos = 0;
                stateVar.packetState = PacketState.ADC_COUNT;
                //if (adc_resolution == EnumAndConstants.BIT_CHECKER)
                //{
                stateVar.ReadBuffer = new byte[NUMBER_OF_RECORDS * EnumAndConstants.CONSTANT_VALUE];
                //}
                //else
                //{
                //    stateVar.ReadBuffer = new byte[NUMBER_OF_RECORDS * EnumAndConstants.CONSTANT_VALUE];
                //}
            }
            receivedPacket.RemoveByte(); //CRC
            waitHandle.Set();
        }