MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / init_config

Method init_config

Extensions/PilotOSMachine/QPilotOSMachine.cpp:103–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void QPilotOSMachine::init_config(std::string& url, bool log_cout)
104{
105 PilotQVM::ELog::get_instance().set_output_log(log_cout);
106 PTraceInfo("***************** On QPilotOSMachine::init for mode: " << m_machine_type << " *****************\n"
107 << g_version << "\n");
108 try
109 {
110 if (m_machine_type == "Pilot")
111 {
112 std::fstream pilot_config("/etc/statetab.d/sysinfo");
113 if (pilot_config.is_open())
114 {
115 pilot_config >> url;
116 pilot_config.close();
117 if (url.empty()) {
118 PTraceWarn("Warn: No Permission with Pilot, try run local.");
119 }
120 }
121 }
122 PTraceInfo("Pilot url: " << url);
123 m_machine_type = m_machine_type == "Pilot" && !url.empty() ? "Pilot" : "CPU";
124 if (m_machine_type == "Pilot")
125 {
126 m_pilot_machine = new(std::nothrow) PilotQVM::QPilotMachine;
127 m_noise_params = new(std::nothrow) PilotQVM::PilotNoiseParams;
128 auto _r = m_pilot_machine->init(url, log_cout);
129 PTraceInfo("m_pilot_machine init return " << _r);
130 }
131 else
132 {
133 m_cpu_machine = new(std::nothrow) QPanda::CPUQVM;
134 m_cpu_machine->init();
135 }
136 _start();
137 }
138 catch (const std::exception& e)
139 {
140 PTraceInfo("Catch unknow exception" << e.what());
141 }
142
143 PTraceInfo("***************** on QPilotOSMachine::init ok ****************");
144}
145
146ErrorCode QPilotOSMachine::get_token(std::string& rep_json)
147{

Callers 1

initMethod · 0.80

Calls 4

set_output_logMethod · 0.80
emptyMethod · 0.45
initMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected