64,676
社区成员
发帖
与我相关
我的任务
分享
string s,str;
ifstream ifs("p001.txt");
ofstream ofs("parameter.txt");
int found1,found2;
while(getline(ifs,str))
{
found1=s.find("[");
found2=s.find("/");
//if(found1!=string::npos&&found2!=string::npos)
if(s.length()>found1&&found1!=string::npos)
{s.erase(found1);str+="\n";str+=s;}
continue;
if (s.length()>found2&&found2!=string::npos)
{s.erase(found2-1);str+="\n";str+=s;}
continue;
}
#include "StdAfx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <complex>
using namespace std;
int main()
{
string s,str;
ifstream ifs("c:\\p001.txt");
ofstream ofs("c:\\parameter.txt");
int found1,found2;
while(getline(ifs,str))
{
found1=str.find("[");
found2=str.find("/");
if(found1 >-1 && found2 >-1)
{
if(found1 < found2)
s+=str.substr(0, found1) + '\n';
else
s+=str.substr(0, found2) + '\n';
}
else if(found1 >-1 && found2 == -1)
{
s+=str.substr(0, found1) + '\n';
}
else if(found1 == -1 && found2 > -1)
{
s+=str.substr(0, found2) + '\n';
}
else
{
continue;
}
}
cout << s << endl;
return 0;
}
//输出结果是
3060 Output voltage
3070 Output current
3080 Output frequency
Drive output power. UNI
9406 Torque ref
9405 Norm Speed
3210 Speed ref
3200 Ramp ref
162 Enable SM mon N
163 Start SM mon N
164 FastStop SM mon N
//疑问?
//3090 Output power R 0.00 0.00 0.00 PV V-F-S-B 这行没有"["或"/"
//Drive output power. UNIT: [kW] for AVy ... AC/AC4, [kVA] for AVy ... BR/BR4. 里面有"["
3060 Output voltage [V] R 0.00 0.00 0.00 PV V-F-S-B
Voltage on the drive output terminals
3070 Output current [A] R 0.00 0.00 0.00 PV V-F-S-B
Current on the drive output terminals
3080 Output frequency [Hz] R 0.00 0.00 0.00 PV V-F-S-B
Drive output frequency
3090 Output power R 0.00 0.00 0.00 PV V-F-S-B
Drive output power. UNIT: [kW] for AVy ... AC/AC4, [kVA] for AVy ... BR/BR4.
9406 Torque ref [Nm] R 0.00 0.00 0.00 PV F-S-B
Drive torque reference
9405 Norm Speed [rpm] R 0.00 0.00 0.00 PV V-F-S-B
Speed of the motor
3210 Speed ref [rpm] R 0.00 0.00 0.00 PV V-F-S-B
Drive speed reference
3200 Ramp ref [rpm] R 0.00 0.00 0.00 PV V-F-S-B
Drive ramp reference
162 Enable SM mon N/A R 0 0 1 DV V-F-S-B
It shows the drive Enable state
163 Start SM mon N/A R 0 0 1 DV V-F-S-B
It shows the drive Start state
0 OFF
1 ON
164 FastStop SM mon N/A R 0 0 1 DV V-F-S-B
It shows the drive FastStop state