| 101 | } |
| 102 | |
| 103 | void 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 | |
| 146 | ErrorCode QPilotOSMachine::get_token(std::string& rep_json) |
| 147 | { |
no test coverage detected