/// <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); } }
/// <summary> /// function for request setConfiguration /// </summary> /// <returns></returns> public ResponseCode setConfigurationRequest(ConfigurationVO configVo) { try { stateVar = new ReadState(); stateVar.packetState = PacketState.START_OF_PACKET; stateVar.currentPos = 0; Packet.Packet packet = new Packet.Packet(1048); packet.Append(EnumAndConstants.START_FRAME); //SOF packet.Append((byte)EnumAndConstants.PROTOCOL_VER); //Version : 1 DSN = new Random().Next(); //Random number packet.Append((byte)DSN); packet.Append((byte)RequestId.SET_CONFIGIRATION); //Request : 2 packet.Append((byte)28); // Length : 0 packet.Append((byte)configVo.mode_operation); packet.Append((byte)configVo.NumberOfSelectedChannels); packet.Append((UInt16)configVo.ChannelValue); adc_resolution = configVo.adcresolution; //packet.Append((byte)configVo.adcresolution); sampling_rate = configVo.sampaling_rate; packet.Append((byte)configVo.sampaling_rate); packet.Append((byte)configVo.T5VDAC); packet.Append((byte)configVo.T7VDAC); packet.Append((UInt16)configVo.T1); packet.Append((UInt16)configVo.T2); packet.Append((UInt16)configVo.T3); packet.Append((UInt16)configVo.T4); packet.Append((UInt16)configVo.T5); packet.Append((UInt16)configVo.T6); packet.Append((UInt16)configVo.T7); packet.Append((UInt16)configVo.T8); packet.Append((UInt16)configVo.T9); packet.Append((UInt16)configVo.T10); packet.Append((byte)calculateCheckSum(packet, false)); GraphFileCollectionSingleton.getInstance().channelFileMap = new Dictionary <ushort, List <string> >(); //Append packetfields return(sendRequest(serialPort, ref packet)); } catch (Exception ex) { m_logger.Error(ex); return(ResponseCode.FAILURE); } }
static ConfigurationVO() { m_Config = new ConfigurationVO(); }