mirror of
				https://github.com/galera951/experiment-automation.git
				synced 2025-10-31 15:27:55 +03:00 
			
		
		
		
	work on generator class
This commit is contained in:
		
							parent
							
								
									491a7310c8
								
							
						
					
					
						commit
						20d17edaf8
					
				
							
								
								
									
										6
									
								
								project/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								project/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | |||||||
|  | *test* | ||||||
|  | *tmp* | ||||||
|  | .vscode | ||||||
|  | *.exe | ||||||
|  | *.o | ||||||
|  | main | ||||||
| @ -50,33 +50,53 @@ public: | |||||||
| 
 | 
 | ||||||
| class Generator: public Device { | class Generator: public Device { | ||||||
| public: | public: | ||||||
| 	Generator(std::string path_name): Device(path_name), channel("C1") {  } | 	Generator(std::string path_name): Device(path_name), m_channel("C1") {  } | ||||||
|  | 
 | ||||||
|  | 	void set_channel(size_t channel) { | ||||||
|  | 		if (channel == 1 || channel == 2) m_channel = "C" + std::to_string(channel); | ||||||
|  | 		else std::cerr << "Invalid channel" << std::endl; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	void buzz() { | 	void buzz() { | ||||||
| 		command("BUZZ ON"); | 		command("BUZZ ON"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void basic_wave( | 	void set_waveform(std::string waveform) { | ||||||
| 		size_t channel, | 		m_waveform = waveform; | ||||||
| 		std::string type, | 		command(m_channel + ":BSWV WVTP," + waveform); | ||||||
| 		double frequency, |  | ||||||
| 		double period, |  | ||||||
| 		double amplitude, |  | ||||||
| 		double offset, |  | ||||||
| 		double phase |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	void set_channel(size_t ch) { |  | ||||||
| 		if (ch == 1 || ch == 2) channel = "C" + std::to_string(ch); |  | ||||||
| 		else std::cerr << "Invalid channel" << std::endl; |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void set_waveform(std::string type) { | 	void set_frequency(double frequency) { | ||||||
| 		command(channel + ":BSWV WVTP," + type); | 		m_frequency = frequency; | ||||||
|  | 		command(m_channel + ":BSWV FRQ," + std::to_string(frequency)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	void set_period(double period) { | ||||||
|  | 		command(m_channel + ":BSWV PERI," + std::to_string(period)); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	void set_amplitude(double amplitude) { | ||||||
|  | 		command(m_channel + ":BSWV AMP," + std::to_string(amplitude)); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	void set_offset(double offset) { | ||||||
|  | 		command(m_channel + ":BSWV OFST," + std::to_string(offset)); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	void set_phase(double phase) { | ||||||
|  | 		command(m_channel + ":BSWV PHSE," + std::to_string(phase)); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	void update(); | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
| 	std::string channel; | 	std::string m_channel; | ||||||
|  | 	std::string m_waveform; | ||||||
|  | 	double m_frequency; | ||||||
|  | 	double m_period; | ||||||
|  | 	double m_amplitude; | ||||||
|  | 	double m_offset; | ||||||
|  | 	double m_phase; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								project/main
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								project/main
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								project/main.o
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								project/main.o
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user