完整代码如下
public partial class MotorWave : System.Web.UI.Page
{
string Station;
string Line;
string Time;
string Motor_Order;//电机序号
double LeftZ;
double RightZ; private OracleConnection conn;
protected void Page_Load(object sender, EventArgs e)
{ Station = Request.QueryString["station"];
Line = Request.QueryString["line"];
Time = Request.QueryString["time"];
LZ = Convert.ToDouble(Request.QueryString["LZ"]);
RZ = Convert.ToDouble(Request.QueryString["RZ"]);
Motor_Order = Request.QueryString["motor_order"];
byte[] Buf = new byte[1024 * 1000];
ReadBlob(ref Buf);
//this.Pic();
this.Draw_Wave(ref Buf, Convert.ToInt32(Motor_Order)); }
......
int x;
int y;
for (int i = 0; i < Motor_Order; i++)
{
L_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; L_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (L_Stop - L_Start) * 2; }
L_Start = BitConverter.ToInt32(Buffer, ptr);
L_Stop = BitConverter.ToInt32(Buffer, ptr + 4);
int Number_L = L_Stop - L_Start;//波形点数
ptr += 8;
Point[] DataPt_L = new Point[Number_L];
int[] Wave_L = new int[Number_L];
for (int n = 0; n < Number_L; n++)
{
ushort value = 0;
double outer;
value=(ushort)((0x7f&Buffer[2 * n + ptr])*128);
value+=Buffer[2 * n + 1+ ptr];
outer=value;
outer = (outer * 1.02 / 16368 - 0.01) * 100 - LZ;//减去零点////////////////////////
//去除飞点
if (outer > 39)
{
replace_point++;
if (replace_point > 10)
{
replace_point = 0;
last_outer = 39;
}
outer = last_outer;
}
else
last_outer = outer; //画波形
Ph.DrawCurve(Pen_left, DataPt_L);
ptr = 0;//偏移
for (int i = 0; i < 8; i++)
{
L_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; L_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (L_Stop - L_Start) * 2; }
for (int i = 0; i < Motor_Order; i++)
{
R_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; R_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (R_Stop - R_Start) * 2; }
////
R_Start= BitConverter.ToInt32(Buffer, ptr);
R_Stop = BitConverter.ToInt32(Buffer, ptr + 4);
int Number_R = R_Stop - R_Start;//波形点数
ptr += 8;
Point[] DataPt_R = new Point[Number_R];
int[] Wave_R = new int[Number_R];
double RightZ = Convert.ToDouble(Request.QueryString["RZ"]);
for (int n = 0; n < Number_R; n++)
{
ushort value = 0;
double outer;
value = (ushort)((0x7f & Buffer[2 * n + ptr]) * 128);
value += Buffer[2 * n + 1 + ptr];
outer = value;
outer = (outer * 1.02 / 16368 - 0.01) * 100 - RightZ;//减去零点///////////////////////////////////////////////////////////
//去除飞点
if (outer > 39)
{
replace_point++;
if (replace_point > 10)
{
replace_point = 0;
last_outer = 39;
}
outer = last_outer;
}
else
last_outer = outer;
但是我现在编译的时候总说输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
行 34: LeftZ = Convert.ToDouble(Request.QueryString["LZ"]);异常详细信息: System.FormatException: 输入字符串的格式不正确。
public partial class MotorWave : System.Web.UI.Page
{
string Station;
string Line;
string Time;
string Motor_Order;//电机序号
double LeftZ;
double RightZ; private OracleConnection conn;
protected void Page_Load(object sender, EventArgs e)
{ Station = Request.QueryString["station"];
Line = Request.QueryString["line"];
Time = Request.QueryString["time"];
LZ = Convert.ToDouble(Request.QueryString["LZ"]);
RZ = Convert.ToDouble(Request.QueryString["RZ"]);
Motor_Order = Request.QueryString["motor_order"];
byte[] Buf = new byte[1024 * 1000];
ReadBlob(ref Buf);
//this.Pic();
this.Draw_Wave(ref Buf, Convert.ToInt32(Motor_Order)); }
......
int x;
int y;
for (int i = 0; i < Motor_Order; i++)
{
L_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; L_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (L_Stop - L_Start) * 2; }
L_Start = BitConverter.ToInt32(Buffer, ptr);
L_Stop = BitConverter.ToInt32(Buffer, ptr + 4);
int Number_L = L_Stop - L_Start;//波形点数
ptr += 8;
Point[] DataPt_L = new Point[Number_L];
int[] Wave_L = new int[Number_L];
for (int n = 0; n < Number_L; n++)
{
ushort value = 0;
double outer;
value=(ushort)((0x7f&Buffer[2 * n + ptr])*128);
value+=Buffer[2 * n + 1+ ptr];
outer=value;
outer = (outer * 1.02 / 16368 - 0.01) * 100 - LZ;//减去零点////////////////////////
//去除飞点
if (outer > 39)
{
replace_point++;
if (replace_point > 10)
{
replace_point = 0;
last_outer = 39;
}
outer = last_outer;
}
else
last_outer = outer; //画波形
Ph.DrawCurve(Pen_left, DataPt_L);
ptr = 0;//偏移
for (int i = 0; i < 8; i++)
{
L_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; L_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (L_Stop - L_Start) * 2; }
for (int i = 0; i < Motor_Order; i++)
{
R_Start = BitConverter.ToInt32(Buffer, ptr);
ptr += 4; R_Stop = BitConverter.ToInt32(Buffer, ptr);
ptr += 4;
ptr += (R_Stop - R_Start) * 2; }
////
R_Start= BitConverter.ToInt32(Buffer, ptr);
R_Stop = BitConverter.ToInt32(Buffer, ptr + 4);
int Number_R = R_Stop - R_Start;//波形点数
ptr += 8;
Point[] DataPt_R = new Point[Number_R];
int[] Wave_R = new int[Number_R];
double RightZ = Convert.ToDouble(Request.QueryString["RZ"]);
for (int n = 0; n < Number_R; n++)
{
ushort value = 0;
double outer;
value = (ushort)((0x7f & Buffer[2 * n + ptr]) * 128);
value += Buffer[2 * n + 1 + ptr];
outer = value;
outer = (outer * 1.02 / 16368 - 0.01) * 100 - RightZ;//减去零点///////////////////////////////////////////////////////////
//去除飞点
if (outer > 39)
{
replace_point++;
if (replace_point > 10)
{
replace_point = 0;
last_outer = 39;
}
outer = last_outer;
}
else
last_outer = outer;
但是我现在编译的时候总说输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
行 34: LeftZ = Convert.ToDouble(Request.QueryString["LZ"]);异常详细信息: System.FormatException: 输入字符串的格式不正确。
if (Request.QueryString["LZ"] != null && Double.TryParse(Request.QueryString["LZ"].ToString(), out LeftZ))
{
LeftZ = Convert.ToDouble(Request.QueryString["LZ"].ToString());
}
public double LeftZ
{
get
{
object leftZ = ViewState["LeftZ"];
if (leftZ != null)
return (double)leftZ;
else
return 0;
}
set
{
ViewState["LeftZ"] = value;
}
}
Double.TryParse(Request.QueryString["LZ"].ToString(), out LeftZ))