-
-
Save dj1711572002/6218dc39edd0dd9bf418d0cec34fbb8f to your computer and use it in GitHub Desktop.
C# RTK skiMonitor FLowGraph for analysys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using System.IO; | |
using System.IO.Ports; | |
using System.Diagnostics; | |
using System.Threading; | |
using static System.Windows.Forms.VisualStyles.VisualStyleElement; | |
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; | |
using static System.Windows.Forms.AxHost; | |
using System.Drawing.Drawing2D; | |
using System.Drawing.Text; | |
using System.Xml.Linq; | |
using static System.Net.Mime.MediaTypeNames; | |
using static System.Windows.Forms.LinkLabel; | |
//using System.Runtime.Remoting.Channels; | |
using System.Security.Policy; | |
using System.Text.RegularExpressions; | |
using System.Security.Cryptography; | |
using static System.Net.WebRequestMethods; | |
using File = System.IO.File; | |
using System.Runtime.Intrinsics.X86; | |
namespace STA23_SerialMonitor_rev06 | |
{ | |
//...................................................................................................................................................... | |
public partial class Form1 : Form | |
{ | |
//converts string/char into ASCII | |
byte[] encoding = System.Text.ASCIIEncoding.ASCII.GetBytes("Hello, World!"); | |
int j, rN; | |
int stopflag = 0; | |
int selectPos, stopPos;//richtextbox 行位置 | |
string mode, modeset; | |
string[] row0, row1, row2, row3, row4;//data 格納 | |
int writeflag; | |
String name;//filename | |
string[] sline;// = new string[150000]; | |
//****************************dgvデータ構造体************************************** | |
//生データを検査して、有効データ範囲を得る | |
struct dgvchk | |
{ | |
public int maxrow;//Row.Count | |
public int startrow;// | |
public int endrow;// | |
public int maxrn;//data エポック数 | |
public int startrn;//有効スタートrn | |
public int endrn;//有効エンドrn | |
public int miss;//itow飛び個数 | |
public double missper;//miss% | |
public int[] fmiss;//smode[]範囲内でのflag 67未満の個数 | |
public double[] fmissper;//fmiss% | |
// mode | |
public int[] smode_startNo;//=new int[10];//s] modeの開始番号 配列 | |
public int[] smode_endNo;//=new int[10];//s] modeの終了番号 配列 | |
public int smodeN;//測定ファイル内のsmode範囲の個数 | |
//time | |
public int[] smode_startitow; | |
public int[] smode_enditow; | |
public int[] smode_time;//sec | |
// digit error | |
public string [,] digit_err;//itow+err.string | |
public int[] digit_errN;//[smodeN] | |
//itow error | |
public string[,] itow_error;// 足りないitow.Tostring() | |
public int[] itow_errN;//[smodeN] | |
public double[] itow_errper;//% err | |
}; | |
dgvchk dc;//1測定dgvに一個 | |
//****************************位置ポイント構造体************************************ | |
struct basep | |
{ | |
public double Ny; | |
public double Ex; | |
public double Dz; | |
public double Height; | |
public double gSpeed; | |
public double headMot; | |
public double mHead; | |
public int flags; | |
public double pdop; | |
//data n | |
public int rn; | |
public int itow; | |
public int tp; | |
public int miss; | |
}; | |
struct rovrp | |
{ | |
public double Ny; | |
public double Ex; | |
public double Dz; | |
public double Height; | |
public double gSpeed; | |
public double headMot; | |
public double mHead; | |
public int flags; | |
public double pdop; | |
//data n | |
public int rn; | |
public int itow; | |
public int tp; | |
public int miss; | |
}; | |
basep[] bp = new basep[50000]; | |
rovrp[] rp = new rovrp[50000]; | |
//******************* ターン構造体 turns******************************************************** | |
struct Turns | |
{ | |
//Public rNturnNo() ;// Integer //rNturnNo(rN)=turnNo | |
public string skiRL; //左右スキーの指定(0)番に収納 | |
public int turnNo; //ターン番号 | |
public string direction;// //ターン方向 R L | |
public int lastNo;// //ターンの数(0)番に収納 | |
public int startNo, endNo;// //開始データ行No | |
public double[] NY; | |
public double[] EX; | |
public double[] EZ; | |
public int initX, initY, endX, endY;// //開始座標、終了座標 X:lon Y:lat | |
public double turnTime;// //ターン時間 | |
public double turnTimesum;// //累積ターン経過時間 | |
//ターン弧 | |
public double Radius;// //簡易円近似半径 | |
public double theta;////fallLine 角度 | |
public int minorDia, majorDia;// //ターン半円の縦短径、横長径 | |
public double Aspectratio; //pectratio;// //ターン弧のアスペクト比 | |
public double fallen;// //fallLine長さ | |
public double fallensum;// // fallLineの累計 | |
public double initHeight, endHeight;// | |
public double fallHeight;// //fallLineの標高差 | |
public double fallHeightsum;////fallLine標高差の累計 | |
public double Slopedeg;// //fallLineの斜度deg | |
public double Arclen;// //円弧長 | |
public double Arclensum;////円弧長の累計 | |
//Speed | |
public double[] Speed;////Speed配列 | |
public double inSpeed, outSpeed, aveSpeed, maxSpeed, minSpeed;////ターン中の速度各種 | |
//Heading Skidding | |
public double[] headMot;////headMot角配列 | |
public double[] headSki;// //ski角配列 | |
public double[] Skid;// //Skid角配列 | |
public double maxHeadmot, minHeadmot, dHeadmot;// //headMot角各種 | |
public double maxSkid, minSkid, aveSkid, dSkid;// | |
//G Acceleration | |
public double[] Gacc;////平均加速度 | |
public double Gaccmax, Gaccmin, Gaccave;// | |
//Slope ターン開始点標高と終了点標高と傾斜角 | |
public double startHeight; | |
public double lastHeight; | |
public double tSlope; | |
public int xdot;//makeATurnBitmap()で使ったドット分解能dot/data tR[0].xdotに収納 | |
}; | |
//-----------Turns 構造体配列定義------------------------------- | |
Turns[] tR = new Turns[1000];////右スキーのターン構造体配列宣言200個まで収納 | |
Turns[] tL = new Turns[1000];////左スキーのターン構造体配列宣言200個まで収納 | |
//************************************Graphic parameters************************************************************************* | |
const int blen = 3000;//処理データ単位3000行を1ブロックにしてBitmapメモリー節約 | |
//int rN; | |
int rowN;//dgv rowCount | |
String fname; | |
public double[] f; | |
public double[] fout; | |
public double[] fkekka; | |
// | |
int[,] dgv = new int[50000, 16]; | |
double[,] dgv16_MA = new double[50000, 5];//FilteredData:M9N_gSpeed_MA(16),M9N_headMot_MA(17),M9N_velN_MA(18),M9N_velE_MA(19),M9N_velD(20) | |
double[,] dgv21_Igr = new double[50000, 8];//積分要素F9P:igr_F9P_gSpeed(21),igr_F9P_velN(22),igr_F9P_velE(23),igr_F9P_velD(24) | |
//積分要素M9N:igr_M9N_gSpeed_MA(25),igr_M9N_velN_MA(26),igr_M9N_velE_MA(27),igr_M9N_velD_MA(28) | |
//bitmap definition | |
//picturebox size----------- | |
const int pic1w = 1000;//pictrueBox1 幅 | |
const int pic1h = 500;//pictureBox1 高さ | |
const int pic2w = 500; | |
const int pic2h = 500; | |
const int pic3w = 500; | |
const int pic3h = 500; | |
const int bw = 20000;// blen;//180000 ; | |
const int xysize = 10000; | |
int wakuflag = 0; | |
Bitmap sourceBitmap = new Bitmap(bw, pic1h);//X軸bw個 data(10msec周期で300秒) Y軸 | |
Bitmap trimmedBitmap = new Bitmap(pic1w, pic1h);//PictuerBox1に貼りこむBitmap | |
Bitmap xyBitmap = new Bitmap(xysize, xysize);//xyプロットのソース | |
Bitmap xysBitmap = new Bitmap(xysize, xysize);//xyプロットのソース拡大用Bitmapとしてポイントサイズを1に最小化した | |
Bitmap p2Bitmap = new Bitmap(pic2w, pic2h);//picturebox2のBitmap | |
Bitmap p2sBitmap = new Bitmap(pic2w, pic2h);//picturebox2の拡大用Bitmapとしてポイントサイズを1に最小化した | |
Bitmap p2wBitmap = new Bitmap(pic2w, pic2h);//picturebox2の枠用Bitmap | |
Bitmap p3Bitmap = new Bitmap(pic3w, pic3h);//picturebox2のBitmap | |
//-XYPLOT----------------- | |
double scalex, scaley; | |
double scale0 = 1; | |
int blockn = 0;//データブロックNo ComboBox7のINDEX値 | |
int blockn_1 = 0;//1個前のブロックNo | |
long lonW, latH; | |
long[] maxlon = new long[10]; | |
long[] minlon = new long[10]; | |
long[] maxlat = new long[10]; | |
long[] minlat = new long[10]; | |
int a = 1; | |
int a_1 = 1; | |
double wheelPos = 0;// Mouse Wheel Position | |
double wheelVal; | |
//xycut | |
int lefttopx;//= (int)(cutcenterx - (pic2w / 2) / magni);//切り取り四角座標計算 | |
int lefttopy;//= (int)(cutcentery - (pic2h / 2) / magni); | |
int pointrowN;//pictureBox3 クリックで得た指定行No | |
//-------------------データブロック構造体---------------------------- | |
public struct data_block | |
{ | |
public int blockSize; | |
public int blockNo; | |
public int startRow; | |
public int endRow; | |
public long maxlon; | |
public long minlon; | |
public long maxlat; | |
public long minlat; | |
public long lonW;//全幅 | |
public long latH;//全高 | |
public int[] nutralN;//ニュートラルポイントの行No 配列 | |
} | |
data_block[] dbk; | |
int alln;//全ブロック数 | |
//-------------------------------------------------------------------- | |
int px_1, py_1; | |
//prown クリック座標逆引き配列 | |
int[] prownx; | |
int[] prowny; | |
struct lines | |
{ | |
public string name;//LIne名 選択されたデータ名 | |
public bool available;//Lineが有効:true 無効:false | |
public int colN;//Column番号 | |
public Color clr; | |
public int sa;//data 間隔 | |
public int rN_avail; | |
public int period; | |
public int x; | |
public int x_1; | |
public int y; | |
public int y_1; | |
public int max; | |
public int min; | |
public int baseL;//Graph base Line 1/2 1/1 | |
public int uscale;//headMot=100000 | |
} | |
//Struct GraphLine | |
public Color[] samples = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Aqua, Color.DeepPink, Color.BlanchedAlmond,Color.Orange }; | |
lines[] gline;//gline global | |
//**********************Graphic parameter END ********************************************************** | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
//...................................................................................................................................................... | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
/* | |
stopflag = 0; | |
serialPort1.BaudRate = 115200; | |
serialPort1.Parity = Parity.None; | |
serialPort1.DataBits = 8; | |
serialPort1.StopBits = StopBits.One; | |
serialPort1.Handshake = Handshake.None; | |
serialPort1.PortName = portComboBox.Text; | |
serialPort1.Open(); | |
*/ | |
} | |
//...................................................................................................................................................... | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
this.Text = "STA23_SerialMonitor_rev06"; | |
richTextBox1.Visible = false; | |
dgv1.Visible = false; | |
/* | |
string[] ports = SerialPort.GetPortNames(); | |
foreach (string port in ports) | |
{ | |
portComboBox.Items.Add(port); | |
} | |
if (portComboBox.Items.Count > 0) | |
{ | |
// portComboBox.SelectedIndex = 1; | |
rN = 0; | |
} | |
writeflag = 0; | |
*/ | |
//------------------------------ | |
// serialPort1.Encoding = System.Text.Encoding.GetEncoding(932); | |
} | |
//..... ................................................................................................................................................. | |
private void button2_Click(object sender, EventArgs e) | |
{ | |
/* | |
stopflag = 0; | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write(textBox2.Text + "\n"); | |
} | |
*/ | |
} | |
//...................................................................................................................................................... | |
delegate void SetTextCallback(string text); | |
//...................................................................................................................................................... | |
/* | |
private void Response(string text) | |
{ | |
if (textBox1.InvokeRequired) | |
{ | |
SetTextCallback d = new SetTextCallback(Response); | |
BeginInvoke(d, new object[] { text }); | |
} | |
else | |
{ | |
string[] data = (text).Split(',');//,//);//カンマ区切りにばらす | |
int dnum = data.Length; | |
label6.Text = data[0]; | |
//char[] chararray = text.ToCharArray(); | |
//File.AppendAllLines(@"d:\mydata.csv",chararray, Encoding.GetEncoding("shift-jis")); | |
if (writeflag == 0) | |
{ | |
DateTime dt = DateTime.Now; | |
name = dt.ToString($"{dt:MMddHHmmss}"); | |
} | |
using (StreamWriter sw = new StreamWriter(@"C:\RTK_LOG\" + name + ".csv", true, Encoding.GetEncoding("shift-jis"))) | |
{ | |
writeflag = 1; | |
// sw.WriteLine(text); | |
sw.Write(text); | |
} | |
rN++; | |
textBox1.Text = text; | |
if (checkBox1.Checked == true) | |
{ | |
//if (data[0] == "[m]") | |
//{ | |
richTextBox1.AppendText(text + "<" + dnum.ToString() + ">"); | |
//} | |
} | |
} | |
} | |
*/ | |
private void checkBox2_CheckedChanged(object sender, EventArgs e) | |
{ | |
if (checkBox2.Checked == true) | |
{ | |
checkBox2.Checked = false; | |
selectPos = richTextBox1.Text.Length; | |
textBox1.Text = "selectPos=" + selectPos.ToString(); | |
} | |
else | |
{ | |
checkBox2.Checked = true; | |
stopPos = richTextBox1.SelectionStart; | |
textBox1.Text = "stopPos=" + stopPos.ToString(); | |
} | |
} | |
/* | |
//...................................................................................................................................................... | |
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) | |
{ | |
if (stopflag == 0) | |
{ | |
string str = serialPort1.ReadLine(); | |
Response(str); | |
} | |
} | |
*/ | |
//...................................................................................................................................................... | |
/* | |
private void serialPort2_DataReceived(object sender, SerialDataReceivedEventArgs e) | |
{ | |
if (stopflag == 0) | |
{ | |
string str2 = serialPort2.ReadLine(); | |
Response(str2); | |
} | |
} | |
*/ | |
//...................................................................................................................................................... | |
private void button4_Click(object sender, EventArgs e) | |
{ | |
/* | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write("s");//Start Log | |
label6.Text = "Save modeset"; | |
} | |
*/ | |
} | |
//...................................................................................................................................................... | |
private void button5_Click(object sender, EventArgs e) | |
{ | |
/* | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write("q");//Quit log | |
label6.Text = "Quit modeset"; | |
} | |
*/ | |
} | |
private void textBox1_TextChanged(object sender, EventArgs e) | |
{ | |
string mes = textBox1.Text; | |
string head = mes.Substring(0, 3); | |
// richTextBox1.AppendText(head); | |
//Status行 md,flagsB,flagsR,pdopB,pdopR,haccB,haccR,miscount0,count_upB,count_upB0,tp,tp0 | |
/* | |
if (mes.IndexOf("m")>=0) | |
{ | |
string[] mdata = (mes + ",\n").Split(//,//);//カンマ区切りにばらす | |
label6.Text = "m"; | |
textBox6.Text = mdata[0]; | |
textBox3.Text = mdata[1]; | |
textBox4.Text = mdata[3]; | |
textBox5.Text = mdata[7]; | |
textBox7.Text = mdata[8]; | |
} | |
Debug.Print("indexof [p]=" + mes.IndexOf("p").ToString()); | |
if (mes.IndexOf("p") >= 0) | |
{ | |
string[] pdata = (mes + ",\n").Split(//,//);//カンマ区切りにばらす | |
label6.Text = "p";// pdata[0] + ":" + pdata[1] + ":" + pdata[2] + ":" + pdata[3]; | |
textBox6.Text = pdata[0]; | |
textBox3.Text = pdata[1]; | |
textBox4.Text = pdata[3]; | |
textBox5.Text = pdata[7]; | |
textBox7.Text = pdata[8]; | |
} | |
if (mes.IndexOf("s") >= 0) | |
{ | |
string[] sdata = (mes + ",\n").Split(//,//);//カンマ区切りにばらす | |
label6.Text = "s";// sdata[0] + ":" + sdata[1] + ":" + sdata[2] + ":" + sdata[3]; | |
textBox6.Text = sdata[0]; | |
textBox3.Text = sdata[1]; | |
textBox4.Text = sdata[3]; | |
textBox5.Text = sdata[7]; | |
textBox7.Text = sdata[8]; | |
} | |
*/ | |
} | |
//...................................................................................................................................................... | |
private void button6_Click(object sender, EventArgs e) | |
{ | |
/* | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write("p");//Pre Averaging Statistic | |
label6.Text = "Preprocess modeset"; | |
} | |
*/ | |
} | |
private void checkBox1_CheckedChanged(object sender, EventArgs e) | |
{ | |
if (checkBox1.Checked == true) | |
{ | |
richTextBox1.Visible = true; | |
} | |
else | |
{ | |
richTextBox1.Visible = false; | |
} | |
} | |
//...................................................................................................................................................... | |
private void button3_Click(object sender, EventArgs e) | |
{ | |
/* | |
stopflag = 1; | |
Thread.Sleep(1000);//Serial.close前のバッファ待ち時間 | |
writeflag = 0; | |
serialPort1.Close(); | |
*/ | |
} | |
private void button7_Click(object sender, EventArgs e) | |
{ | |
/* | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write("d");//Pre Averaging Statistic | |
label6.Text = "Dir modeset"; | |
} | |
*/ | |
} | |
private void checkBox3_CheckedChanged(object sender, EventArgs e) | |
{ | |
dgv1.Visible = true; | |
} | |
private void button8_Click(object sender, EventArgs e) | |
{ | |
/* | |
if (serialPort1.IsOpen) | |
{ | |
serialPort1.Write("b");//Pre Averaging Statistic | |
label6.Text = "BnoHoisei modeset"; | |
} | |
*/ | |
} | |
//read file | |
private void button9_Click(object sender, EventArgs e) | |
{ | |
//dgv1.Visible = true; | |
ReadDialog(); | |
} | |
//-----------------Read File ---------------------------------------------------- | |
private void ReadDialog() | |
{ | |
sline = new string[150000]; | |
int irn = 0; | |
string sizes = null; | |
var swtch = new System.Diagnostics.Stopwatch(); | |
dgv1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; | |
dgv1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; | |
dgv1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; | |
//sourceBitmap_clear(); | |
//OpenFileDialogクラスのインスタンスを作成 | |
OpenFileDialog ofd = new OpenFileDialog(); | |
//ダイアログを表示する | |
if (ofd.ShowDialog() == DialogResult.OK) | |
{ | |
// DataGridView初期化(データクリア) | |
dgv1.Columns.Clear(); | |
dgv1.Rows.Clear(); | |
// dgv1 set | |
dgv1.ColumnCount = 40; | |
dgv1.RowCount = 2; | |
//dgv1.RowHeadersWidth = 80; | |
// dgv1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True; | |
// DataGridViewColumn target_item = dgv1.Columns[0]; | |
// target_item.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; | |
// headerName(); | |
int rowN = 0; | |
int i; | |
int fi = 0; | |
int ic = 0; | |
//OKボタンがクリックされたとき、選択されたファイルを読み取り専用で開く | |
textBox2.Text = ofd.FileName; | |
//====================================ASCII read start======================================================== | |
//dgvの受信データをパラメータに代入 | |
//("[%c],%d,%d,%4.2f,%4.2f,%d,%d,%d,%d,%d,%d,%d\n\r",md,flagsB,flagsR,pdopB,pdopR,haccB,haccR,miscount0,count_upB,count_upB-count_upB0,tp,tp0); | |
//"[Base],%d,%4.2f,%4.2f,%4.2f,%d,%d,\n\r",itowB,NYB,EXB,DZB,gSpeedB,headMotB); | |
//"[Rover],%d,%4.2f,%4.2f,%4.2f,%d,%4.2f,%4.2f,%4.1f\n\r",itowR,NYR,EXR,DZR,gSpeedR,mHead,bnHosei+eX[0],relLm); | |
//"[BNO],%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f%,\n\r",eX[0],eY[0],eZ[0],eX[1],eY[1],eZ[1],eX[2],eY[2],eZ[2]); | |
// | |
string head0 = "md, flagsB, flagsR, pdopB, pdopR, haccB, haccR, miscount0, count_upB,count_upB0,tp,tp0"; | |
string head1 = ",[Base],itowB, NYB, EXB, DZB, gSpeedB, headMotBZ"; | |
string head2 = ",[Rover] ,itowR,NYR,EXR,DZR,gSpeedR,mHead,bnHosei+eX[0],relLm]"; | |
string head3 = ",BNO],yaw1,pitch1,roll1,yaw2,pitch2,roll2,yaw3,pitch3,roll3"; | |
string headall = head0 + head1 + head2 + head3; | |
string[] headArr = headall.Split(','); | |
int headlen = headArr.Length; | |
// string head0 = "md(0), flagsB(1), flagsR(2), pdopB(3), pdopR(4), haccB(5), haccR(6), miscount0(7), count_upB(8),count_upB0(9),tp(10),tp0(11)"; | |
//string head1 = ",[Base](12),itowB(13), NYB(14), EXB(15), DZB(16), gSpeedB(17), headMotBZ(18)"; | |
//string head2 = ",[Rover](19) ,itowR(20),NYR(21),EXR(22),DZR(23),gSpeedR(24),mHead(25),bnHosei+eX[0](26),relLm](27)"; | |
//string head3 = ",BNO](28),yaw1(29),pitch1(30),roll1(31),yaw2(32),pitch2(33),roll2(34),yaw3(35),pitch3(36),roll3(37)" | |
for (i = 0; i < headlen; i++) | |
{ | |
dgv1.Columns[i].HeaderText = headArr[i]; ; | |
dgv1.Rows[0].Cells[i].Value = i; | |
} | |
FileInfo filesize = new FileInfo(ofd.FileName); | |
swtch.Start(); | |
//-----readAllText----- | |
// シフトJISのファイルの読み込み | |
//System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); // memo: Shift-JISを扱うためのおまじない | |
//string alldata = File.ReadAllText(ofd.FileName, System.Text.Encoding.GetEncoding("Shift_JIS")); | |
string alldata = File.ReadAllText(ofd.FileName); | |
// var wordList = alldata.Replace("\r\n", "\n").Split(new[] { //\n//, //\r// }); | |
string[] sline = alldata.Split('['); | |
int ni=0; | |
for (ic = 1; ic < (int)(sline.Length - 2); ic++) | |
{ | |
//Debug.Print("sline[" + ic.ToString() + "]=" + sline[ic]); | |
string [] tsline = sline[ic].Split("\r\n");//行内に複数ある\r\nと余計なコメントを除去 | |
sline[ic] = tsline[0];//再度sline[]に代入 | |
/* | |
for (ni = 0; ni < tsline.Length; ni++) | |
{ | |
Debug.Print("tsline[" + ni.ToString() + "]=" + tsline[ni]); | |
} | |
*/ | |
} | |
//string[] sline = alldata.Split("\r\n"); | |
//Debug.Print("sline[0]=" + sline[0]); | |
// Debug.Print("sline[1]=" + sline[1]); | |
swtch.Stop(); | |
sizes = sline.Length + "行," + filesize.Length.ToString() + "byte Ellapsed Time=" + swtch.ElapsedMilliseconds.ToString() + "msec"; | |
label8.Text = sizes; | |
if (checkBox3.Checked == true)//dgv visible | |
{ | |
dgv1.Visible = true; | |
dgv1.RowHeadersWidth = 60; | |
//dgv1.TopLeftHeaderCell.Value = "左上"; | |
// richTextBox1.Visible = true; | |
swtch.Reset(); | |
swtch.Start(); | |
Debug.Print("sline.Length=" + sline.Length.ToString()); | |
string ss = "0"; | |
int cr = 0; | |
string datas0 =""; | |
string datas1 = ""; | |
string datas2=""; | |
for (ic = 1; ic < (int)(sline.Length - 2); ic++) | |
{ | |
//Debug.Print("sline["+ic.ToString()+"]=" + sline[ic].Substring(0, 3).ToString()); | |
if (sline[ic].Length > 2) | |
{ | |
sline[ic] = sline[ic].Replace("\r\n", ""); | |
// string tsline = sline[ic].Replace(Environment.NewLine, ""); | |
//string[] tsline = sline[ic].Split("\r\n"); | |
// Debug.Print("ic=" + ic.ToString() + "sline[0]=" + sline[0]); | |
if (sline[ic].Substring(0, 2) == "Ba") | |
{ | |
dgv1.Rows[cr].HeaderCell.Value = cr.ToString(); | |
/* | |
sline[ic - 1] = sline[ic - 1].Substring(0, sline[ic - 1].Length - 2); | |
sline[ic] = sline[ic].Substring(0, sline[ic].Length - 2); | |
sline[ic + 1] = sline[ic + 1].Substring(0, sline[ic + 1].Length - 2); | |
sline[ic + 2] = sline[ic + 2].Substring(0, sline[ic + 2].Length - 3); | |
*/ | |
datas2 = datas1; | |
datas1 = datas0; | |
ss = sline[ic - 1] + "," + sline[ic] + sline[ic + 1] + "," + sline[ic + 2]; | |
string[] datas = ss.Split(','); // カンマで区切って配列に格 | |
//Debug.Print("datas[0]=" + datas[0],"datas1="+datas1); | |
datas0 = datas[0]; | |
if (datas[0] == "s]") | |
{ | |
dgv1.Rows.Add(datas);//dgv1書き込み | |
cr++; | |
} | |
if(datas1=="s]" && datas0=="m]") | |
{ | |
dgv1.Rows.Add(datas);//dgv1書き込み | |
cr++; | |
//Debug.Print("[m] cr=" + cr.ToString()); | |
} | |
} | |
} | |
} | |
swtch.Stop(); | |
// TimeSpan tst = swtch.ElapsedMilliseconds; | |
label8.Text = sizes + "dgv:" + swtch.ElapsedMilliseconds.ToString() + "msec"; | |
} | |
}//File read End ******************************************************************************************************************* | |
} //ReadDialog() end | |
//==============================================Parameter set======================================================================= | |
//dgvの受信データをパラメータに代入 | |
//("[%c],%d,%d,%4.2f,%4.2f,%d,%d,%d,%d,%d,%d,%d\n\r",md,flagsB,flagsR,pdopB,pdopR,haccB,haccR,miscount0,count_upB,count_upB-count_upB0,tp,tp0); | |
//"[Base],%d,%4.2f,%4.2f,%4.2f,%d,%d,\n\r",itowB,NYB,EXB,DZB,gSpeedB,headMotB); | |
//"[Rover],%d,%4.2f,%4.2f,%4.2f,%d,%4.2f,%4.2f,%4.1f\n\r",itowR,NYR,EXR,DZR,gSpeedR,mHead,bnHosei+eX[0],relLm); | |
//"[BNO],%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f,%4.1f%,\n\r",eX[0],eY[0],eZ[0],eX[1],eY[1],eZ[1],eX[2],eY[2],eZ[2]); | |
// | |
//struct basep/rovrp basep=bp[] rovrp=rp[] | |
/* | |
struct basep | |
{ | |
public double Ny; | |
public double Ex; | |
public double Dz; | |
public double Height; | |
public double gSpeed; | |
public double headMot; | |
public double mHead; | |
public int flags; | |
public double pdop; | |
//data n | |
public int rn; | |
public int itow; | |
public int tp; | |
public int miss; | |
}; | |
*/ | |
void bpset(int n)//構造体配列bp[n]作成 | |
{ | |
} | |
void rpset(int n)//構造体配列rp[n]作成 | |
{ | |
} | |
/*==================datachk========================================= | |
struct dgvchk | |
{ | |
public int maxrow;//Row.Count | |
public int startrow;// | |
public int endrow;// | |
public int maxrn;//data エポック数 | |
public int startrn;//有効スタートrn | |
public int endrn;//有効エンドrn | |
public int miss;//itow飛び個数 | |
public double missper;//miss% | |
public int[] fmiss;//smode[]範囲内でのflag 67未満の個数 | |
public double[] fmissper;//fmiss% | |
// mode | |
public int[] smode_startNo;//=new int[10];//s] modeの開始番号 配列 | |
public int[] smode_endNo;//=new int[10];//s] modeの終了番号 配列 | |
public int smodeN;//測定ファイル内のsmode範囲の個数 | |
//time | |
public int[] smode_startitow; | |
public int[] smode_enditow; | |
public int[] smode_time;//sec | |
// digit error | |
public string [,] digit_err;//itow+err.string | |
public int[] digit_errN;//[smodeN] | |
//itow error | |
public string[,] itow_error;// 足りないitow.Tostring() | |
public int[] itow_errN;//[smodeN] | |
public double[] itow_errper;//% err | |
}; | |
dgvchk dc;//1測定dgvに一個 | |
// string head0 = "md(0), flagsB(1), flagsR(2), pdopB(3), pdopR(4), haccB(5), haccR(6), miscount0(7), count_upB(8),count_upB0(9),tp(10),tp0(11)"; | |
//string head1 = ",[Base](12),itowB(13), NYB(14), EXB(15), DZB(16), gSpeedB(17), headMotBZ(18)"; | |
//string head2 = ",[Rover](19) ,itowR(20),NYR(21),EXR(22),DZR(23),gSpeedR(24),mHead(25),bnHosei+eX[0](26),relLm](27)"; | |
//string head3 = ",BNO](28),yaw1(29),pitch1(30),roll1(31),yaw2(32),pitch2(33),roll2(34),yaw3(35),pitch3(36),roll3(37)" | |
*/ | |
private void button11_Click(object sender, EventArgs e)//sortdgv 起動 | |
{ | |
sortdgv(); | |
button12.Enabled = true; | |
int im; | |
//richTextBox1 write | |
richTextBox1.Visible = true; | |
for(im=0;im<dc.smodeN;im++) | |
{ | |
string mes = "smodeNo=" + im.ToString() + "startRow=" + dc.smode_startNo[im].ToString() + "endRow=" + dc.smode_endNo[im].ToString() + "time=" + dc.smode_time[im].ToString()+"\r\n"; | |
richTextBox1.AppendText(mes); | |
} | |
//slip 追加 DZB反転単位m | |
for (im=0;im<dc.maxrow;im++)//slipを全dgvデータ計算代入 | |
{ | |
double slipd = -(Convert.ToDouble(dgv1.Rows[im].Cells[18].Value) - Convert.ToDouble(dgv1.Rows[im ].Cells[25].Value)); | |
dgv1.Rows[im].Cells[28].Value = slipd.ToString();//28列のslip値代入 | |
//DZB標高差正負反転 | |
double DZBm = -Convert.ToDouble(dgv1.Rows[im].Cells[16].Value)/100; | |
dgv1.Rows[im].Cells[16].Value = DZBm.ToString("F2");//16列のSZB正負反転代入 | |
//Debug.Print("slip=" + slipd.ToString() + "slip dgv[" + (irn + startrowN).ToString() + "][28]=" + dgv1.Rows[irn + startrowN].Cells[28].Value.ToString()); | |
} | |
} | |
void sortdgv()//生データを整理してから各有効データの行番号を抽出 | |
{ | |
var swtch0 = new System.Diagnostics.Stopwatch(); | |
swtch0.Reset(); | |
swtch0.Start(); | |
dgv1.DefaultCellStyle.NullValue = "0"; | |
dgv1.DefaultCellStyle.DataSourceNullValue = "0"; | |
DateTime now = DateTime.Now; | |
Debug.Print("sortdgv In:" + now.ToString()); | |
//行チェック 列ごとに前後チェック | |
//string[,] itow_error = new string[10, 1000];//エラー行列を記録[smodeN,irr] | |
int colitowb = 13;//itowBの列番号 | |
int colitowr = 20;//itowRの列番号 | |
int iir = 0; | |
int iic = 1; | |
int erri = 0; | |
int itowB0, itowB0_1; | |
dc.digit_err = new string[10, 1000]; | |
dc.itow_error= new string[10, 1000];//エラー行列を記録[smodeN,irr] | |
dc.itow_errN = new int[10]; | |
dc.itow_errper = new double[10]; | |
dc.smode_startNo = new int[10]; | |
dc.smode_endNo = new int[10]; | |
dc.smode_startitow = new int[10]; | |
dc.smode_enditow = new int[10]; | |
dc.smode_time = new int[10]; | |
//*********Null削除**************************** | |
dc.maxrow = dgv1.RowCount; | |
for (iir = 1; iir < dc.maxrow - 2; iir++)//行ループ | |
{ | |
for (iic = 0; iic < 38; iic++) | |
{ | |
if (dgv1.Rows[iir].Cells[iic].Value == null) | |
{ | |
dgv1.Rows[iir].Cells[iic].Value = "0"; | |
//dgv1.Rows[iir].Cells[iic].Value = dgv1.Rows[iir - 1].Cells[iic].Value; | |
Debug.Print("null repaired 0 [" + iir.ToString() + "],[" + iic.ToString() + "]" + millis()); | |
} | |
} | |
// if (dgv1.Rows[iir].Cells[0].Value == null) | |
// { | |
// dgv1.Rows.RemoveAt(iir); | |
// Debug.Print("Null Remove iir=" + iir.ToString() + "Cells[0]=Null"); | |
//} | |
} | |
//**********Null削除END*******************************: | |
//各データの異常反転基準値配列を作る、<criteria[]は正数、>criteria[]は負数 | |
double[] criteria = new double[38] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 }; | |
//1:flags 131 67 変化 | |
dc.maxrow = dgv1.RowCount; | |
//最初にmHeadを180度回転補正 | |
mhead180(25, 2, dgv1.Rows.Count - 2);//mHead | |
mhead180(26, 2, dgv1.Rows.Count - 2);//BNHOSEI yaw1 | |
mhead180(29, 2, dgv1.Rows.Count - 2);//yaw1 | |
mhead180(32, 2, dgv1.Rows.Count - 2);//yaw2 | |
mhead180(35, 2, dgv1.Rows.Count - 2);//yaw3 | |
hmotd();//headMotをDoubleに変換 | |
//************************smode範囲 check***************************************************** | |
//dc.smode_startNo[], dc.smode_endNo[],dc.smodeNを得る | |
string modes = "+[s]"; | |
int smodenum = 0; | |
int mode_startflag = 0; | |
int mode_startNo = 0; | |
int mode_endNo = 0; | |
//smode Range Count itowが1秒以上離れたら別範囲************************************** | |
smodesearch(); | |
Debug.Print("smode count dc.smode_endNo[" + smodenum.ToString() + "]=" + dc.smode_endNo[smodenum].ToString() + "dc_smodeN=" + dc.smodeN.ToString()); | |
mode_endNo = dc.maxrow - 2; | |
DateTime now1 = DateTime.Now; | |
Debug.Print("smode SearchFinished :" + now1.ToString()); | |
//Smode end*********************************************************************************************************************************** | |
//Digit error repaire*********************************************************************************************** | |
//処理1:nullセルは0代入 | |
//処理2:文字が数値でないセルは、前の行データ代入 | |
int smodeitr = 0; | |
while (smodeitr <= dc.smodeN)//smodeの個数だけスキャン | |
{ | |
DateTime now3 = DateTime.Now; | |
// Debug.Print("loop end :" +now3.ToString()+ now3.Millisecond.ToString()); | |
for (iir = dc.smode_startNo[smodeitr]; iir < dc.smode_endNo[smodeitr]; iir++)//行ループ 2行から開始してiir-1行目とiir行目比較 | |
{ // public static bool TryParse( string s, out データ型名 result)を使って文字から数値変換できるかチェック | |
//nullチェック | |
string itows = dgv1.Rows[iir].Cells[13].Value.ToString(); | |
for (iic = 1; iic < 38; iic++) | |
{ | |
if (dgv1.Rows[iir].Cells[iic].Value == null)//nullチェック | |
{ | |
//dgv1.Rows[iir].Cells[iic].Value = "0"; | |
dgv1.Rows[iir].Cells[iic].Value = dgv1.Rows[iir - 1].Cells[iic].Value; | |
Debug.Print("null repaired 0 [" + iir.ToString() + "],[" + iic.ToString() + "]"+millis()); | |
} | |
} | |
int derr = 0; | |
for (iic = 1; iic < 38; iic++) | |
{ | |
if (iic != 12 && iic != 19 && iic != 28) | |
{ | |
double i; | |
//string cellstr = dgv1.Rows[iir].Cells[iic].Value.ToString(); | |
if (double.TryParse(dgv1.Rows[iir].Cells[iic].Value.ToString(), out i))//文字セルが数値かどうかチェック | |
{ | |
//itow_error[smodeitr, erri] = iir.ToString() + "," + itowsa.ToString(); | |
//Debug.Print("Inseted:itow_erri[" + smodeitr.ToString() + "," + erri.ToString() + "] =" + itow_error[smodeitr, erri] + ", itowB=" + dgv1.Rows[iir].Cells[13].Value + "," + dgv1.Rows[iir - 1].Cells[13].Value); | |
} | |
else | |
{ | |
// Debug.Print("数値に変換できません=" + "Rows[" + iir.ToString() + "]Cells[" + iic.ToString() + "]=" + dgv1.Rows[iir].Cells[iic].Value.ToString()+","+millis()); | |
//非数値異常値は、1個上のデータで置き換え | |
dc.digit_err[smodeitr, derr] = itows+","+dgv1.Rows[iir].Cells[iic].Value.ToString(); | |
// Debug.Print("dc_err="+dc.digit_err[smodeitr, derr]); | |
derr++; | |
if (checkBox4.Checked == true) | |
{ | |
int iiic; | |
for (iiic = 1; iiic < 38; iiic++) | |
{ | |
// Debug.Print("Rows[" + iir.ToString() + "]Cells[" + iiic.ToString() + "]=" + dgv1.Rows[iir].Cells[iiic].Value.ToString() + "=>Repaired=" + dgv1.Rows[iir].Cells[iiic].Value.ToString()); | |
dgv1.Rows[iir].Cells[iiic].Value = dgv1.Rows[iir - 1].Cells[iiic].Value; | |
} | |
} | |
// erri++;//エラー扱い | |
// iir++;//1個飛ばし | |
} | |
} | |
} | |
} | |
//increment | |
smodeitr++; | |
erri = 0; | |
}//while modeitr end | |
//===============================itow Insert=========================================================== | |
//if (checkBox4.Checked == true) | |
//{ | |
smodeitr = 0; | |
while (smodeitr < dc.smodeN)//smodeの個数だけスキャン | |
{ | |
Debug.Print("itowInsert START"); | |
for (iir = dc.smode_startNo[smodeitr]+1; iir < dc.smode_endNo[smodeitr]; iir++)//行ループ 2行から開始してiir-1行目とiir行目比較 | |
{ | |
itowB0 = Convert.ToInt32(dgv1.Rows[iir].Cells[13].Value); | |
itowB0_1 = Convert.ToInt32(dgv1.Rows[iir - 1].Cells[13].Value); | |
int itowsa = itowB0 - itowB0_1; | |
if (itowsa > 124 && itowsa<244) | |
{ | |
dc.itow_error[smodeitr, erri] = (itowB0 + 120).ToString() + "," + itowsa.ToString(); | |
dc.itow_errN[smodeitr] = erri; | |
rinsert(iir, itowsa); | |
//Debug.Print("124<<244iir="+iir.ToString()+"sa="+itowsa.ToString()+"Inserted:itow_erri[" + smodeitr.ToString() + "," + erri.ToString() + "] =" + dc.itow_error[smodeitr, erri] + ", itowB=" + dgv1.Rows[iir].Cells[13].Value + "," + dgv1.Rows[iir - 1].Cells[13].Value + "," + millis()); | |
erri++; | |
} | |
else if(itowsa>244) | |
{ | |
// Debug.Print(">244]iir=" + iir.ToString() + "sa=" + itowsa.ToString() + "Inserted:itow_erri[" + smodeitr.ToString() + "," + erri.ToString() + "] =" + dc.itow_error[smodeitr, erri] + ", itowB=" + dgv1.Rows[iir].Cells[13].Value + "," + dgv1.Rows[iir - 1].Cells[13].Value + "," + millis()); | |
} | |
} | |
smodeitr++; | |
erri = 0; | |
// }//itow insert end | |
} | |
smodesearch();//最後の行数でsmode再実施 | |
//Percent 計算 | |
//itow error | |
//public string[,] itow_error;// 足りないitow.Tostring() | |
//public int[] itow_errN;//[smodeN] | |
//public double[] itow_errper;//% err | |
for(smodeitr=0;smodeitr<dc.smodeN;smodeitr++) | |
{ | |
dc.itow_errper[smodeitr] = (double)dc.itow_errN[smodeitr] / (dc.smode_endNo[smodeitr] - dc.smode_startNo[smodeitr])*100; | |
// Debug.Print("dc.itow_errper[" + smodeitr.ToString() + "]=" + dc.itow_errper[smodeitr].ToString("F2")+"%"); | |
dc.smode_startitow[smodeitr] = Convert.ToInt32(dgv1.Rows[dc.smode_startNo[smodeitr]].Cells[13].Value); | |
dc.smode_enditow[smodeitr] = Convert.ToInt32(dgv1.Rows[dc.smode_endNo[smodeitr]].Cells[13].Value); | |
dc.smode_time[smodeitr] = dc.smode_enditow[smodeitr] - dc.smode_startitow[smodeitr]; | |
} | |
//}//checkbox4 end | |
Debug.Print("Sort dgv FINISHED"); | |
//finished | |
label9.Text="sortdgv:smodeN="+dc.smodeN.ToString()+"erri="+erri.ToString(); | |
}//sortdgv end | |
//******************************************************************************************************************************************** | |
private void smodesearch() | |
{ | |
//*********************smode Range Count itowが1秒以上離れたら別範囲************************************** | |
int iir; | |
int mode_startflag = 0; | |
int mode_startNo=0; | |
int smodenum=0; | |
int mode_endNo = 0; | |
dc.maxrow = dgv1.RowCount; | |
for (iir = 1; iir < dc.maxrow - 2; iir++)//行ループ | |
{ | |
int itowd = Convert.ToInt32(dgv1.Rows[iir].Cells[13].Value); | |
int itowd_1 = Convert.ToInt32(dgv1.Rows[iir - 1].Cells[13].Value); | |
//if (md.Substring(0, 2) == "s]" && mode_startflag == 0) | |
if (itowd - itowd_1 < 124 && mode_startflag == 0 && iir<=dc.maxrow-4) | |
{ | |
mode_startflag = 1; | |
mode_startNo = iir; | |
dc.smode_startNo[smodenum] = iir; | |
dc.smodeN = smodenum; | |
//Debug.Print("dc.smode_startNo[" + smodenum.ToString() + "]=" + dc.smode_startNo[smodenum].ToString()); | |
} | |
else if ((itowd - itowd_1 > 1000 || iir>=dc.maxrow-4 )&& mode_startflag == 1) | |
{ | |
mode_endNo = iir; | |
mode_startflag = 0; | |
dc.smode_endNo[smodenum] = iir; | |
dc.smodeN = smodenum + 1; | |
Debug.Print("dc.smode_endNo[" + smodenum.ToString() + "]=" + dc.smode_endNo[smodenum].ToString() + "dc_smodeN=" + dc.smodeN.ToString()); | |
smodenum++; | |
} | |
/* | |
else | |
{ | |
mode_endNo = iir; | |
mode_startflag = 1; | |
dc.smode_endNo[smodenum] = iir; | |
dc.smodeN = smodenum + 1; | |
//Debug.Print("dc.smode_endNo[" + smodenum.ToString() + "]=" + dc.smode_endNo[smodenum].ToString() + "dc_smodeN=" + dc.smodeN.ToString()); | |
//smodenum++; | |
} | |
*/ | |
//dc.maxrow = dgv1.RowCount; | |
} | |
} | |
private string millis() | |
{ | |
DateTime now3 = DateTime.Now; | |
string mil= now3.ToString() +":"+ now3.Millisecond.ToString(); | |
return mil; | |
} | |
private void rinsert(int rn, int sa) | |
{ | |
//itow | |
if (sa <= 240) | |
{ | |
try | |
{ | |
int cii; | |
dgv1.Rows.Insert(rn); | |
//Debug.Print("rinsert [=" + rn.ToString() + "]"); | |
dgv1.Rows[rn].Cells[13].Value = Convert.ToInt32(dgv1.Rows[rn - 1].Cells[13].Value) + 120;//抜けたitow | |
for (cii = 14; cii < 19; cii++) | |
{ | |
double ave = (Convert.ToDouble(dgv1.Rows[rn - 1].Cells[cii].Value) + Convert.ToDouble(dgv1.Rows[rn + 1].Cells[cii].Value)) / 2; | |
dgv1.Rows[rn].Cells[cii].Value = ave.ToString("F2"); | |
} | |
for (cii = 20; cii < 28; cii++) | |
{ | |
double ave = (Convert.ToDouble(dgv1.Rows[rn - 1].Cells[cii].Value) + Convert.ToDouble(dgv1.Rows[rn + 1].Cells[cii].Value)) / 2; | |
dgv1.Rows[rn].Cells[cii].Value = ave.ToString("F2"); | |
} | |
for (cii = 29; cii < 38; cii++) | |
{ | |
double ave = (Convert.ToDouble(dgv1.Rows[rn - 1].Cells[cii].Value) + Convert.ToDouble(dgv1.Rows[rn + 1].Cells[cii].Value)) / 2; | |
dgv1.Rows[rn].Cells[cii].Value = ave.ToString("F2"); | |
} | |
} | |
catch(Exception e) | |
{ | |
} | |
} | |
} | |
private void mhead180(int col, int startr, int endr)//rover haeding 180度回転 | |
{ | |
int hii; | |
for (hii = startr; hii < endr; hii++) | |
{ | |
double d; | |
string sh = dgv1.Rows[hii].Cells[col].Value.ToString(); | |
if (double.TryParse(sh, out d)) | |
{ | |
double head = Convert.ToDouble(dgv1.Rows[hii].Cells[col].Value) + 180; | |
if (head > 360) | |
{ | |
head = head - 360; | |
} | |
dgv1.Rows[hii].Cells[col].Value = head.ToString("F2"); | |
//変換出来たら、dにその数値が入る | |
// Console.WriteLine("{0} は数値 {1} に変換できます。", sh, d); | |
} | |
else | |
{ | |
//Console.WriteLine("{0} は数字ではありません。", sh); | |
Debug.Print("Not Numerical format Cell= " + hii.ToString() + "sh=" + sh); | |
} | |
} | |
} | |
private void hmotd()//headMotを小数点5桁に変換 | |
{ | |
int ir; | |
double d; | |
for (ir = 1; ir < dc.maxrow - 2; ir++)//行ループ | |
{ | |
string sh = dgv1.Rows[ir].Cells[18].Value.ToString(); | |
if (double.TryParse(sh, out d)) | |
{ | |
double hmotd = Convert.ToDouble(dgv1.Rows[ir].Cells[18].Value) * 0.00001; | |
dgv1.Rows[ir].Cells[18].Value = hmotd.ToString("F2"); | |
//変換出来たら、dにその数値が入る | |
Console.WriteLine("{0} は数値 {1} に変換できます。", sh, d); | |
} | |
else | |
{ | |
Console.WriteLine("{0} は数字ではありません。", sh); | |
Debug.Print("Not Numerical format Cell= " + ir.ToString() + "sh=" + sh); | |
} | |
//double hmotd = Convert.ToDouble(dgv1.Rows[ir].Cells[18].Value) * 0.00001; | |
//dgv1.Rows[ir].Cells[18].Value = hmotd.ToString(); | |
} | |
} | |
private void dgv1_CellClick(object sender, DataGridViewCellEventArgs e)//セル座標表示 | |
{ | |
label7.Text = "row=" + dgv1.CurrentCell.RowIndex.ToString() + "column=" + dgv1.CurrentCell.ColumnIndex.ToString(); | |
} | |
//====================================================== | |
//===========dgvSave=================================== | |
//==================================================== | |
private void button10_Click(object sender, EventArgs e) | |
{ | |
dgvsave(); | |
} | |
private void dgvsave() | |
{ | |
int i, j; | |
//Filename Timestamp | |
DateTime dt = DateTime.Now; | |
string fn = dt.ToString($"{dt:MMddHHmmss}"); | |
string fnstrng = "c:/RTK_Log/dgv_" + fn + ".csv"; | |
string hdstrng = "c:/RTK_Log/head_" + fn + ".csv"; | |
int dgvron = dgv1.RowCount; | |
int dgvcln = dgv1.ColumnCount; | |
Debug.Print("dgvron=" + dgvron.ToString() + ",dgvcln=" + dgvcln.ToString()); | |
using (StreamWriter sw = new StreamWriter(@fnstrng, false, Encoding.UTF8)) | |
{ | |
for (i = 1; i < dgvron - 1; i++) | |
{ | |
string dgvrow = ""; | |
for (j = 0; j < dgvcln; j++) | |
{ | |
dgvrow = dgvrow + dgv1.Rows[i].Cells[j].Value + ","; | |
} | |
sw.WriteLine(dgvrow); | |
} | |
} | |
//-----------HeaderText save---------------------- | |
//DataGridView1.Columns[0].HeaderTex | |
if (dgv1.Columns[2].HeaderText !="") | |
{ | |
using (StreamWriter sw = new StreamWriter(@hdstrng, false, Encoding.UTF8)) | |
{ | |
string dgvhead = ""; | |
for (j = 0; j < dgvcln; j++) | |
{ | |
dgvhead = dgvhead + dgv1.Columns[j].HeaderCell.Value + ","; | |
//Debug.Print("i=" + i.ToString() + ",dgvhead=" + dgvhead); | |
} | |
sw.WriteLine(dgvhead); | |
} | |
} | |
} | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@GRAPH @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
//-------------------------ターン構造体全ターンプロット makeATurnBitmap()------------------------------ | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
// | |
private void button13_Click(object sender, EventArgs e)//sourceBitmap作成してプロット | |
{ | |
dgv1.Visible = false; | |
hScrollBar1.Visible = true; | |
pictureBox1.Visible = true; | |
makeATurnBitmap(28); | |
//int ir; | |
//pictureBox1.Visible = true; | |
hScrollBar1.Minimum = 0;// tR[1].startNo;位置をゼロとする | |
Debug.Print("PLOT RANGE:tR[1].startNo"+tR[1].startNo.ToString() + "tR["+tR[0].lastNo.ToString()+"].endNo=" + tR[tR[0].lastNo].endNo.ToString() + "tR[0].xdot=" + tR[0].xdot.ToString()); | |
//int xdot = 1;// timeScale(); | |
hScrollBar1.Maximum =( tR[tR[0].lastNo].endNo- tR[1].startNo) * tR[0].xdot;//sourceBitmapの全ドット数 | |
hScrollBar1.Value = (tR[tR[0].lastNo].endNo - tR[1].startNo) * tR[0].xdot;//初期設定は、最大値右端にセット | |
textBox3.Text = Convert.ToInt32(hScrollBar1.Value / tR[0].xdot).ToString(); | |
Debug.Print("plot:hscro;;Bar.minimum=0=" + tR[1].startNo.ToString() + "hscrollBar.Max=" + hScrollBar1.Maximum.ToString()+"hscrollBar.Value=cx="+ hScrollBar1.Value.ToString()); | |
sourceCut(hScrollBar1.Value); | |
//xyplot | |
//xyplot(); | |
} | |
//--------------makeATurnBitmap() ------------------------------------------------ | |
private void makeATurnBitmap(int xdot)//seleNターン番号の展開時系列グラフ | |
{ | |
int mi; | |
int psa = 1;//120msec 1行 | |
gline = new lines[8]; | |
int gsel=0;//gline selector 0:headMot,1:mHead,2:gSpeed,3:pitch,4:yaw,5:DZB,6:relLm | |
//------ | |
tR[0].xdot = Convert.ToInt32(textBox8.Text); | |
//周期 | |
gline[0].period = 120;//headMot RED | |
gline[1].period = 120;//mHead BLUE | |
gline[2].period = 120;//gSpeed GREEN | |
gline[3].period = 40;//pitch YELLOW | |
gline[4].period = 40;//yaw AQUA | |
gline[5].period = 120;//DZB DEEP PINK | |
gline[6].period = 120;//roll1 //relLm ALMOND | |
gline[7].period = 120;//slip Orange | |
//列番号 | |
gline[0].colN = 18;//headMot | |
gline[1].colN = 25;//mHead | |
gline[2].colN = 17;//gSpeed | |
gline[3l].colN =30;//pitch1=30,pitch2=33,pitch3=36 | |
gline[4].colN = 29;//bnhosei26ダメ yaw129;//yaw1=29,yaw2=32,yaw3=35 | |
gline[5].colN = 16;//DZB | |
gline[6].colN = 31;//roll 1 //relLm | |
gline[7].colN = 28;//slipを新たに作成 BNO0をつぶす | |
//max値 | |
gline[0].max = 360;//headMot1deg | |
gline[1].max = 360;//mHead1deg | |
gline[2].max = 12000;//gSpeed 43kmh= | |
gline[3].max = 90;//pitch IMU EulerAngle 0.1deg | |
gline[4].max = 360;//yaw IMU EulerAngle 0.1deg | |
gline[5].max =300;//DZB 30000cm落差±300m上マイナス下プラス | |
gline[6].max = 90;//roll1 relLm Length 115cmave ma150cm | |
gline[7].max =180;//slipを新たに作成 BNO0をつぶす | |
//min値 | |
gline[0].min = 0;//headMot | |
gline[1].min = 0;//mHead | |
gline[2].min = 0;//gSpeed 43kmh | |
gline[3].min =-90;//pitch1=30,pitch2=33,pitch3=36 | |
gline[4].min = 0;//yaw1=29,yaw2=32,yaw3=35 | |
gline[5].min = -200;//DZB 30000cm落差±300m上マイナス下プラス | |
gline[6].min =-90;//roll1 //relLm Length 115cmave ma150cm | |
gline[7].max = -180;//slipを新たに作成 BNO0をつぶす | |
for (mi=0;mi<8;mi++) | |
{ | |
gline[mi].baseL =1; | |
} | |
gline[3].baseL = 2; | |
gline[5].baseL = 2;//DZB | |
gline[6].baseL = 2;//roll | |
gline[7].baseL = 2;//slip ベースラインセンター | |
//----------------------------------------------------------- | |
int irn; | |
int pw = 1000;// pictureBox1.Width;//1000dot | |
int ph = 500;// pictureBox1.Height;//500dot | |
int velMax = 10000;//mm/sec | |
int velMin = -10000; | |
int headMax = 36000000; | |
int headMin = 0; | |
//int xdot = 10;// timeScale(); | |
// double yscale = (double)ph / (velMax - velMin); | |
//Bitmap分解能 X軸10msec/dot=>1000dot10sec | |
// public Color[] samples = new Color[] { 0Color.Red, 1Color.Blue, 2Color.Green, 3Color.Yellow, 4Color.Aqua,5Color.DeepPink, 6Color.BlanchedAlmond }; | |
//Graphics g1 = Graphics.FromImage(trimmedBitmap);//188行 Bitmap sourceBitmap = new Bitmap(bw, pic1h);//(20000,500)軸bw個 data(10msec周期で300秒) Y軸 | |
Graphics g1 = Graphics.FromImage(sourceBitmap); | |
g1.Clear(Color.Black); | |
for (gsel = 0; gsel <8; gsel++) | |
{ | |
// if (gline[gsel].available == true) | |
//{ | |
//Turn構造体から範囲取得 | |
int pmsec = gline[gsel].period; | |
// int psa = gline[gsel].sa; | |
int pcoln = gline[gsel].colN; | |
double yscale = (double)ph / (gline[gsel].max - gline[gsel].min);//500/(360-0)= | |
//Debug.Print("gline[" + gsel.ToString() + "].colN=" + gline[gsel].colN.ToString()); | |
int itow0 = 0; | |
int y0, y0_1; | |
int startrowN = tR[1].startNo;//ターンNo1のスタートからプロット | |
int endrowN = tR[tR[0].lastNo].endNo;// tR[seleN+0].endNo; | |
for (irn = 1; irn < endrowN-startrowN; irn++) | |
{ | |
//Debug.Print("itow0=" + itow0.ToString() + "gline[" + gsel.ToString() + "].colN=" + gline[gsel].colN.ToString()); | |
Pen p = new Pen(samples[gsel], 1); | |
Brush b1 = new SolidBrush(samples[gsel]); | |
//if (itow0 % pmsec == 0 && irn > psa) | |
// { | |
// Debug.Print("irn=" + irn.ToString() + "psa=" + psa.ToString()); | |
// if (checkBox1.Checked == true) | |
//{ | |
double yd = Convert.ToDouble(dgv1.Rows[irn+startrowN].Cells[pcoln].Value); | |
double yd_1 = Convert.ToDouble(dgv1.Rows[irn+startrowN-1].Cells[pcoln].Value); | |
y0 = Convert.ToInt32(yd); | |
y0_1 = Convert.ToInt32(yd_1); | |
// Debug.Print("yscale="+yscale.ToString()+"yd,yd_1=" + yd.ToString() + "," + yd_1.ToString() + "y0,y0_1=" + y0.ToString() + "," + y0_1.ToString()); | |
//} | |
//else | |
//{ | |
// y0 = dgv[irn, pcoln]; | |
// y0_1 = dgv[irn - psa, pcoln]; | |
//} | |
int px = irn * tR[0].xdot; | |
int px_1 = (irn - psa) * tR[0].xdot; | |
int py0 = ph / gline[gsel].baseL - (int)((double)y0 * yscale); | |
int py0_1 = ph / gline[gsel].baseL - (int)((double)y0_1 * yscale); | |
// g1.DrawLine(Pens.Blue, px, py0, px - 1, py0_1); | |
// Debug.Print("irn+startrowN="+(irn+startrowN).ToString()+"[px,py]=[" + px.ToString() + "," + py0.ToString() + "],px_1,py0_1=[" + px_1.ToString() + "," + py0_1.ToString()+"]"); | |
g1.DrawLine(p, px, py0, px_1, py0_1); | |
Color c = samples[gsel]; | |
// pictureBox1.Image = trimmedBitmap; | |
// if (CKarry[gsel].Checked == true) { g1.FillEllipse(b1, px, py0, 5, 5); } | |
//Debug.Print("itow0="+itow0.ToString()+"px=" + px.ToString()+"py0="+py0.ToString()+"px_1="+px_1.ToString()+"py0_1="+py0_1.ToString()); | |
//} | |
} | |
// } | |
} | |
// pictureBox1.Image = trimmedBitmap; | |
}//makeATurnBitmap() end | |
//***************TimeScale Graph Source Bit Map make******************************************************************************* | |
/*参照構造体 lines[] gline | |
struct lines | |
{ | |
public string name;//LIne名 選択されたデータ名 | |
public bool available;//Lineが有効:true 無効:false | |
public int colN;//Column番号 | |
public Color clr; | |
public int sa;//data 間隔 | |
public int rN_avail; | |
public int period; | |
public int x; | |
public int x_1; | |
public int y; | |
public int y_1; | |
public int max; | |
public int min; | |
public int baseL;//Graph base Line 1/2 1/1 | |
public int uscale;//headMot=100000 | |
} | |
//Struct GraphLine | |
public Color[] samples = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Aqua, Color.DeepPink, Color.BlanchedAlmond }; | |
lines[] gline;//gline global | |
*/ | |
//*******************gline naming****************************************** | |
// soukrceBitamapを切り取って | |
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e) | |
{ | |
int cx = hScrollBar1.Value; | |
int pW = pictureBox1.Width; | |
// int dot = 1;// Convert.ToInt32(textBox10.Text); | |
// int posn = (int)cx / dot; | |
//textBox3.Text = posn.ToString(); | |
int xdot = timeScale(); | |
// int rcx = (int)((cx - pW / 2) / xdot); | |
//textBox13.Text = rcx.ToString(); | |
// Debug.Print("cx=" + cx.ToString() + "pW=" + pW.ToString() + "dot=" + dot.ToString() + "posn=" + posn.ToString() + "xdot=" + xdot.ToString() + "rcx=" + rcx.ToString()); | |
sourceCut(cx);//sourceBitmapからcxからcx-1000ドット切り取って、目盛り線と文字を書き込んでpictureBox1に表示 | |
/* | |
//----------センターカーソルのY値読み込み 表示-------------------------------------------------------- | |
string g0s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[0].colN].Value) / gline[0].uscale).ToString(); | |
string g1s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[1].colN].Value) / gline[1].uscale).ToString(); | |
string g2s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[2].colN].Value) / gline[2].uscale).ToString(); | |
string g3s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[3].colN].Value) / gline[3].uscale).ToString(); | |
string g4s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[4].colN].Value) / gline[4].uscale).ToString(); | |
string g5s = (Convert.ToDouble(dgv1.Rows[rcx].Cells[gline[5].colN].Value) / gline[5].uscale).ToString(); | |
*/ | |
} | |
private void sourceCut(int cx)//cxはスクロールバー現在位置 | |
{ | |
Graphics g2 = Graphics.FromImage(trimmedBitmap); | |
g2.Clear(Color.Black); | |
int pW = 1000; | |
int startX = 0; | |
if (cx > pW) | |
{ | |
startX = cx - pW; | |
} | |
else | |
{ | |
startX = 0; | |
} | |
/* | |
if (checkBox10.Checked == true) | |
{ | |
pictureBox1.Visible = true; | |
} | |
else | |
{ | |
pictureBox1.Visible = false; | |
} | |
*/ | |
Rectangle srcRect = new Rectangle(startX, 0, pW, 500); | |
Rectangle desRect = new Rectangle(0, 0, pW, 500); | |
g2.DrawImage(sourceBitmap, desRect, srcRect, GraphicsUnit.Pixel); | |
//Center Cursor | |
g2.DrawLine(Pens.White, pW / 2, 0, pW / 2, pictureBox1.Height); | |
g2.DrawLine(Pens.White, 0, pictureBox1.Height / 2, pW , pictureBox1.Height/2); | |
// =================センターカーソル座標での各数値表示==================================== | |
//0:headMot,1:mHead,2:gSpeed,3:pitch,4:yaw1,5:DZB,6:relLm,7:slip | |
//----sourceBitmapX座標の cxから行番号を計算 ([0].endNo-[1]startNo)*xdotが全幅 cx=0がtR[1].startNo行になる------ | |
int rncx = (int)(cx / tR[0].xdot) - (int)(500 / tR[0].xdot) + tR[1].startNo;// (int)(cx / tR[0].xdot); | |
double hmot = Convert.ToDouble(dgv1.Rows[rncx].Cells[18].Value); | |
double mhead = Convert.ToDouble(dgv1.Rows[rncx].Cells[25].Value); | |
double slip = hmot - mhead; | |
double gspd = Convert.ToDouble(dgv1.Rows[rncx].Cells[17].Value)/1000000*3600;//mm/sec=>kmh | |
double pit = Convert.ToDouble(dgv1.Rows[rncx].Cells[30].Value); | |
double yw = Convert.ToDouble(dgv1.Rows[rncx].Cells[29].Value); | |
double roll = Convert.ToDouble(dgv1.Rows[rncx].Cells[31].Value); | |
double dzb = Convert.ToDouble(dgv1.Rows[rncx].Cells[16].Value); | |
double lens = Convert.ToDouble(dgv1.Rows[rncx].Cells[27].Value); | |
// | |
Debug.Print("rncx=" + rncx.ToString() + "hmot=" + hmot.ToString()); | |
//文字列を表示する範囲を指定する | |
// 0:headMot,1:mHead,2:gSpeed,3:pitch,4:yaw1,5:DZB,6:relLm | |
int haba = 110; | |
RectangleF rectall = new RectangleF(0, 0,1000, 20);//行全体 | |
RectangleF rect = new RectangleF(500,470,240, 20);//行番号をセンターライン下に表示 | |
RectangleF rect0 = new RectangleF(0,0,haba, 20);//hMot位置 | |
RectangleF rect1 = new RectangleF(haba, 0, haba, 20);//slip位置 | |
RectangleF rect2 = new RectangleF(haba*2, 0, haba, 20);//gspd位置 | |
RectangleF rect3 = new RectangleF(haba*3, 0, haba, 20);//pit位置 | |
RectangleF rect4 = new RectangleF(haba*4, 0, haba, 20);//mhead位置 | |
RectangleF rect5 = new RectangleF(haba * 5, 0, haba, 20);//yw位置 | |
RectangleF rect6 = new RectangleF(haba*6, 0, haba, 20);//roll位置 | |
RectangleF rect7 = new RectangleF(haba * 7, 0, haba, 20);//dzb位置 | |
RectangleF rect8 = new RectangleF(haba * 8, 0, haba, 20);//length位置 | |
g2.FillRectangle(Brushes.Black, rect);//rectの四角を描く | |
g2.FillRectangle(Brushes.Black, rectall);//rectの四角を描く | |
//フォントオブジェクトの作成 | |
Font fnt = new Font("MS UI Gothic", 16); | |
// string | |
//itowから経過時間表示をrncxの後に追加 | |
double timeitow =(Convert.ToDouble(dgv1.Rows[rncx].Cells[13].Value)- Convert.ToDouble(dgv1.Rows[2].Cells[13].Value)) /1000; | |
string timeitows = timeitow.ToString("F2"); | |
//----------------------------------- | |
string strrowN = timeitows + "sec"+ "[" + rncx.ToString() + "]"; | |
string strhmot = "hmot=" + hmot.ToString("F1"); | |
string strmhead = "mhed=" + mhead.ToString("F1"); | |
string strslip = "slip=" +slip.ToString("F1"); | |
string strgspd = "gspd=" + gspd.ToString("F1"); | |
string strpit = "pit1=" + pit.ToString("F1"); | |
string stryw = "yaw1=" + yw.ToString("F1"); | |
string strroll = "rol1=" + roll.ToString("F1"); | |
string strdzb = "dzb =" + dzb.ToString("F1"); | |
string strlens = "lens =" + lens.ToString("F1"); | |
//描画 public Color[] samples = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Aqua, Color.DeepPink, Color.BlanchedAlmond }; | |
g2.DrawString(strrowN, fnt, Brushes.White, rect);//rowN描画 | |
g2.DrawString(strhmot, fnt, Brushes.Red, rect0);//hMot描画 | |
g2.DrawString(strslip, fnt, Brushes.Orange, rect1); | |
g2.DrawString(strgspd, fnt, Brushes.Green, rect2); | |
g2.DrawString(strpit, fnt, Brushes.Yellow, rect3); | |
g2.DrawString(strmhead, fnt, Brushes.Blue, rect4); | |
g2.DrawString(stryw, fnt, Brushes.Aqua, rect5); | |
g2.DrawString(strroll, fnt, Brushes.BlanchedAlmond, rect6); | |
g2.DrawString(strdzb, fnt, Brushes.DeepPink, rect7); | |
g2.DrawString(strlens, fnt, Brushes.White, rect8); | |
/* | |
// Font fnt = new Font("MS UI Gothic", 15); | |
//文字列を表示する範囲を指定する | |
// RectangleF rect = new RectangleF(10, 30, 150, 100); | |
//rectの四角を描く | |
g2.FillRectangle(Brushes.Black, rect); | |
//dgv ブロックNo 行番号 | |
string gyon = "rowN=" + pointrowN.ToString("D"); | |
g2.DrawString(gyon, fnt, Brushes.White, rect); | |
//gSpeed | |
float gspeedkph = (float)dgv[pointrowN, 2] / 1000000 * 3600; | |
float gspeedmps = (float)dgv[pointrowN, 2] / 1000; | |
string speeds = "gSpeed=" + ((float)dgv[pointrowN, 2] / 100000).ToString(); | |
g2.DrawString(gspeedkph.ToString("F2") + " km/h", fnt, Brushes.White, 10, 50); | |
g2.DrawString(gspeedmps.ToString("F2") + " m/sec", fnt, Brushes.White, 10, 70); | |
*/ | |
pictureBox1.Image = trimmedBitmap; | |
} | |
//******************************************************************************************************* | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
private int timeScale() | |
{ | |
int dot = 1;// Convert.ToInt32(textBox1.Text); | |
// if (dot * dgv1.RowCount >bw) | |
if (dot * rowN > bw) | |
{ | |
//dot = (int)(bw / dgv1.RowCount); | |
dot = (int)(bw / rowN); | |
if (dot == 0) { dot = 1; } | |
} | |
return dot; | |
} | |
//=========================================================================================================================== | |
//======================TURNカット Nutral()================================================================================= | |
//headMOTの極値をニュートラル(切り替え)ポイントとして抽出して、配列データとしてもって、ターングラフに重ねる | |
//headMOTを5回MAして 微分してプラスマイナス変化点をポイントとする | |
//=========================================================================================================================== | |
//=========================================================================================================================== | |
private void button12_Click(object sender, EventArgs e) | |
{ | |
int tsNo = Convert.ToInt32(textBox10.Text); | |
Nutral(dc.smode_startNo[tsNo], dc.smode_endNo[tsNo]); | |
button13.Enabled = true; | |
} | |
private void Nutral(int stNo,int endNo)//Turn NutralPointを探す | |
{ | |
// int stNo = Convert.ToInt32(textBox1.Text); | |
// int endNo = Convert.ToInt32(textBox2.Text); | |
int ic, i5; | |
int icR_1, icL_1; | |
double sum5R, sum5L; | |
double headR =0; | |
double headL=0; | |
string gspeedRs =""; | |
int nuNR, nuNL ; | |
int numN = 0; | |
int num = endNo - stNo; | |
double[] MA5headR= new double[endNo] ; | |
double[] DifheadR=new double[endNo]; | |
double[] MA5headL= new double[endNo] ; | |
double[] DifheadL= new double[endNo] ; | |
int turnCountR, turnCountL ; | |
int pared = 0; | |
turnCountR = 0; | |
turnCountL = 0; | |
nuNR = 0; | |
nuNL = 0; | |
icR_1 = -8; | |
icL_1 = -8; | |
int[] NutralR=new int[endNo]; | |
int[] NutralL = new int[endNo]; | |
int[] turnNoR = new int[endNo]; | |
int[] turnNoL = new int[endNo]; | |
int TurnNumR, TurnNumL; | |
//loop ic------------------------------- | |
for ( ic = stNo; ic< endNo - 5;ic++) | |
{ | |
numN += 1; | |
sum5R = 0; | |
sum5L = 0; | |
for( i5 = ic;i5< 4 + ic;i5++)//5回の移動平均でheadMotを平均化 | |
{ | |
int col_lon = 0; | |
int col2_lon = 0; | |
int headMotBR = 18; | |
int headMotBL = 25; | |
// headR = (double)(dgv1.Rows[i5].Cells[col_lon + 10].Value )* 0.00001; | |
// headL = (double)(dgv1.Rows[i5].Cells[col2_lon + 10].Value)* 0.00001; | |
headR = Convert.ToDouble(dgv1.Rows[i5].Cells[headMotBR].Value); | |
headL = Convert.ToDouble(dgv1.Rows[i5].Cells[headMotBL].Value); | |
sum5R = sum5R + headR; | |
sum5L = sum5L + headL; | |
}// for i5 end | |
MA5headR[ic] = sum5R / 5; | |
MA5headL[ic] = sum5L / 5; | |
// gspeedRs = dgv1.Rows[i5].Cells[24].Value.ToString(); | |
{ | |
DifheadR[ic] = MA5headR[ic] - MA5headR[ic - 1]; | |
DifheadL[ic] = MA5headL[ic] - MA5headL[ic- 1]; | |
// Debug.Print("DifheadR[,"+ic.ToString()+",]=,"+DifheadR[ic].ToString()+",hedR=,"+headR.ToString()+",gSpeedRs=,"+gspeedRs); | |
//*******************************************ターン判定********************************************************** | |
// 微分正負変化点&&ターン長7データ&&gspeed >5000 時速18kmh以上で切る | |
double gsp = Convert.ToDouble(dgv1.Rows[ic].Cells[17].Value); | |
if ((DifheadR[ic] * DifheadR[ic - 1]) < 0 && ic - icR_1 > 7 && gsp>5000) //前回から8個以上離れて正負逆転した場合NutralPointと判断 | |
{ | |
Debug.Print("ifNUTRAL:gsp=" + gsp.ToString()); | |
icR_1 = ic; | |
if (DifheadR[ic] < 0 ) | |
{ | |
NutralR[ic] = -1; //左ターン | |
tR[turnCountR].direction = "Rturn"; | |
} | |
else | |
{ | |
NutralR[ic] = 1;//右ターン | |
tR[turnCountR].direction = "Lturn"; | |
} | |
// Debug.Print("NutralR=," + tR[turnCountR].direction); | |
//CheckBox12.Checked = True; | |
turnNoR[nuNR] = ic ;//ニュートラルポイントでの行番号記録 | |
//*****ターン構造体記録**************************** | |
//nuNR=1でtr.turnNo=0,nuNR=2でtr.turnNo=1 | |
if (nuNR > 0 ) | |
{ | |
tR[turnCountR].turnNo = turnCountR; //構造体へターン番号記録 | |
tR[turnCountR].startNo = turnNoR[nuNR - 1];//構造体へスタート行番号記録 | |
tR[turnCountR].endNo = turnNoR[nuNR]; //構造体へスタート行番号記録 | |
//RichTextBox2.AppendText("tR(" + CStr(turnCountR) + ") = " + CStr(turnCountR) + ":tr.startNo=" + CStr(tR(turnCountR).startNo) + ",tr.endNo=" + CStr(tR(turnCountR).endNo) + vbCrLf); | |
// Debug.Print("turnNoR[," + nuNR.ToString() + ",]=," + turnNoR[nuNR].ToString()); | |
Debug.Print("tR.turnNo=," + tR[turnCountR].turnNo.ToString() + ",tR.startNo=," + tR[turnCountR].startNo.ToString() + ",tR.endNo=," + tR[turnCountR].endNo.ToString()); | |
turnCountR++; | |
} | |
else | |
{ | |
NutralR[ic] = turnCountR + 2;// // ターンNOを2個多く記憶 | |
} | |
nuNR += 1; | |
}//if DifheadR end | |
/* | |
if (DifheadL[ic] * DifheadL[ic - 1] < 0 && ic - icL_1 > 7 )// //前回から8個以上離れて正負逆転した場合NutralPointと判断 | |
{ | |
icL_1 = ic; | |
if( DifheadL[ic] < 0 ) | |
{ | |
NutralL[ic-stNo] = -1; | |
tL[turnCountL].direction = "Rturn"; | |
} | |
else | |
{ | |
NutralL[ic-stNo] = 1; | |
tL[turnCountL].direction = "Lturn"; | |
} | |
//CheckBox12.Checked = True; | |
turnNoL[nuNL-stNo] = ic; | |
//*****ターン構造体記録**************************** | |
//nuNR=1でtr.turnNo=0,nuNR=2でtr.turnNo=1 | |
if (nuNL > 0 ) | |
{ | |
tL[turnCountL].turnNo = turnCountL;// //構造体へターン番号記録 | |
tL[turnCountL].startNo = turnNoL[nuNL - 1];// //構造体へスタート行番号記録 | |
tL[turnCountL].endNo = turnNoL[nuNL];// //構造体へスタート行番号記録 | |
//RichTextBox2.AppendText("tL(" + CStr(turnCountL) + ") = " + CStr(turnCountL) + ":tL.startNo=" + CStr(tL(turnCountL).startNo) + ",tL.endNo=" + CStr(tL(turnCountL).endNo) + vbCrLf) | |
turnCountL += 1; | |
} | |
//************************************************* | |
//RichTextBox2.AppendText("NutralheadL(" + CStr(ic) + ")=" + CStr(1) + "TurnNoL(" + CStr(nuNL) + ")=" + CStr(ic) + "DifheadL(ic)=" + CStr(DifheadL(ic)) + vbCrLf) | |
nuNL += 1; | |
}//if DifheadL | |
else | |
{ | |
NutralL[ic-stNo] = turnCountL + 2;// // ターンNOを2個多く記憶 | |
}//if DifheadL end | |
*/ | |
TurnNumR = nuNR; | |
tR[0].lastNo = turnCountR - 1;// //ターン最後番号をtR(0).lastNoに収納 | |
textBox9.Text = tR[0].lastNo.ToString(); | |
TurnNumL = nuNL; | |
tL[0].lastNo = turnCountL - 1;// //ターン最後番号をtL(0).lastNoに収納 | |
}//if DifheadL end | |
}//if C>0 end | |
}//for ic end | |
}// Nutral end | |
/*VB.NETでつくってある 2022年最終 | |
https://gist.github.com/dj1711572002/3fd4a496dda9140cd027f68a687ba482 | |
http://shinshu-makers.net/shinshu_makers/2022/02/12/%e3%80%90sta22%e3%80%91rtk%e3%83%87%e3%83%bc%e3%82%bf%e8%a7%a3%e6%9e%90%e7%94%a8%e3%82%b0%e3%83%a9%e3%83%95%e3%82%a3%e3%83%83%e3%82%af%e6%a9%9f%e8%83%bd%e9%96%8b%e7%99%ba%e3%83%bc%e3%81%9d%e3%81%ae5/ | |
//========================TURN Calculation============================================================================ | |
Private void turnCalc(int tN ) //ターン構造体型配列番号を引き渡して左右ターンをまとめて計算する | |
//Nutral() //Nutral点をカウントしておく | |
//***************************TURN パラメータリスト**************************************************** | |
//==========================TURNの各パラメータ計算======== | |
int it, iu ;// Integer | |
int RturnstartNo, RturnendNo ;// Integer | |
int LturnstartNo, LturnendNo ;// Integer | |
int initXR, initYR, endXR, endYR ;// Integer | |
int initXL, initYL, endXL, endYL ;// Integer | |
double initHiR, initHiL, endHiR, endHiL ;// Double | |
RpybMax = 0 | |
RpyrMax = 0 | |
LpybMax = 0 | |
LpyrMax = 0 | |
//ターン番号を回しながら左右同時ターンパラメータ計算して得る----------------- | |
//For it = 0 To tR(0).lastNo - 1 //TurnNumR - 2 //Nutral番号のitとit+1の間のターン番号がitとする:右ターン番号基準= | |
RturnstartNo = tR(tN).startNo //turnNoR(it) | |
RturnendNo = tR(tN).endNo //turnNoR(it + 1) | |
LturnstartNo = tL(tN).startNo //turnNoR(it) | |
LturnendNo = tL(tN).endNo //turnNoR(it + 1) | |
int tNumR ;// Integer = RturnendNo - RturnstartNo + 1 //Rターン内のデータ数 | |
intm tNumL ;// Integer = LturnendNo - LturnstartNo + 1 //Lターン内のデータ数 | |
ReDim Rpxb(tNumR), Rpyb(tNumR), Rpxr(tNumR), Rpyr(tNumR) //座標配列再宣言 | |
ReDim Lpxb(tNumL), Lpyb(tNumL), Lpxr(tNumL), Lpyr(tNumL) //座標配列再宣言 | |
ReDim tR(tN).Speed(tNumR), tR(tN).headMot(tNumR), tR(tN).headSki(tNumR), tR(tN).Skid(tNumR) | |
ReDim tL(tN).Speed(tNumL), tL(tN).headMot(tNumL), tL(tN).headSki(tNumL), tL(tN).Skid(tNumL) | |
ReDim tR(tN).Gacc(tNumR), tL(tN).Gacc(tNumL) //加速度配列 | |
//====================TURN 時間計算============================= | |
tR(tN).turnTime = (RturnendNo - RturnstartNo - 1) * 0.125 | |
tL(tN).turnTime = (LturnendNo - LturnstartNo - 1) * 0.125 | |
If tN > 0 Then | |
tR(tN).turnTimesum = tR(tN - 1).turnTimesum + tR(tN).turnTime | |
tL(tN).turnTimesum = tL(tN - 1).turnTimesum + tL(tN).turnTime | |
Else //tN=0の時 | |
tR(tN).turnTimesum = tR(tN).turnTime | |
tL(tN).turnTimesum = tL(tN).turnTime | |
End If | |
//---------フォールライン回転角度と距離------------------------------------------------- | |
//Debug.Print("turnCald 1stgetpos") | |
GetPos(RturnstartNo) //RNlon,RNlat,RNheight,RNrelN,RNrelE,RNreLD | |
initXR = RNlon | |
initYR = RNlat | |
initHiR = RNheight / 10 //Height mm=> cm | |
initXL = LNlon | |
initYL = LNlat | |
initHiL = LNheight / 10 //Height mm=> cm | |
tR(tN).initX = initXR | |
tR(tN).initY = initYR | |
tR(tN).initHeight = initHiR | |
tL(tN).initX = initXL | |
tL(tN).initY = initYL | |
tL(tN).initHeight = initHiL | |
//Debug.Print("turnCald 2nd getpos ") | |
GetPos(RturnendNo) | |
endXR = RNlon | |
endYR = RNlat | |
endHiR = RNheight / 10 //Height mm=> cm | |
endXL = LNlon | |
endYL = LNlat | |
endHiL = LNheight / 10 //Height mm=> cm | |
tR(tN).endX = endXR | |
tR(tN).endY = endYR | |
tR(tN).endHeight = endHiR | |
tL(tN).endX = endXL | |
tL(tN).endY = endYL | |
tL(tN).endHeight = endHiL | |
//Debug.Print("RturnstartNo=," + CStr(RturnstartNo) + ",RturnendNo=," + CStr(RturnendNo) + ",initX=," + CStr(initX) + ",initY=," + CStr(initY) + ",endX=," + CStr(endX) + ",endY=," + CStr(endY)) | |
Dim thetaR ;// Double = Math.Atan((endYR - initYR) / (endXR - initXR)) | |
tR(tN).theta = thetaR | |
Dim SinthR ;// Double = Math.Sin(-thetaR) | |
Dim CosthR ;// Double = Math.Cos(-thetaR) | |
Dim fallR ;// Double = Math.Sqrt((endXR - initXR) ^ 2 + (endYR - initYR) ^ 2) | |
Dim fallL ;// Double = Math.Sqrt((endXL - initXL) ^ 2 + (endYL - initYL) ^ 2) | |
//================================================================================ | |
//Dim minorDia, majorDia ;// Integer | |
Dim fallRX, fallLX ;// Double //回転正規化後のfallRの長さ検算 | |
//横滑り角度Skidの最大最小 | |
Dim SkidRsum ;// Double = 0 | |
Dim SkidLsum ;// Double = 0 | |
Dim ArcsumR ;// Double = 0 | |
Dim ArcsumL ;// Double = 0 | |
Dim speedsumR ;// Double = 0 | |
Dim speedsumL ;// Double = 0 | |
Dim GaccsumR ;// Double = 0 | |
Dim GaccmaxR ;// Double = 0 | |
Dim GaccminR ;// Double = 10000 | |
Dim GaccsumL ;// Double = 0 | |
Dim GaccmaxL ;// Double = 0 | |
Dim GaccminL ;// Double = 10000 | |
//大小比較初期値 | |
tR(tN).maxSkid = 0 | |
tR(tN).minSkid = 360 | |
tL(tN).maxSkid = 0 | |
tL(tN).minSkid = 360 | |
//-------------------------------------------------------------------------------------------------------------------- | |
// Debug.Print("======TurnNo it=" + CStr(it) + "thetaR=" + CStr(thetaR) + "fallR=" + CStr(fallR)) | |
//正規化座標計算 iuがターン内のデータ番号スタートが0,エンドが tNR-1 | |
//========================================================================================================== | |
//Rスキー計算=============================================================================================== | |
//========================================================================================================== | |
For iu = 0 To tNumR - 1 | |
// Debug.Print("turnCald 3rd getpos iu= " + CStr(iu)) | |
GetPos(iu + RturnstartNo) //dgv1からRTK座標,角度、速度読取り | |
//turnNOとrNの配列作成 | |
//--Right Ski--------------- | |
Rpxb(iu) = CInt((RNlon * CosthR - RNlat * SinthR))// theata だけ座標回転 | |
Rpyb(iu) = CInt((RNlon * SinthR + RNlat * CosthR)) // theata だけ座標回転 | |
Rpxr(iu) = CInt(((RNlon + RNrelE) * CosthR - (RNlat + RNrelN) * SinthR)) // theata だけ座標回転 | |
Rpyr(iu) = CInt(((RNlon + RNrelE) * SinthR + (RNlat + RNrelN) * CosthR)) // theata だけ座標回転 | |
If iu > 0 Then | |
Dim rR ;// Double = Math.Sqrt((Rpxb(iu) - Rpxb(iu - 1)) ^ 2 + (Rpyb(iu) - Rpyb(iu - 1)) ^ 2) | |
ArcsumR = ArcsumR + rR | |
//Debug.Print("ArcR:rR=" + CStr(rR) + "ArcsumR=" + CStr(ArcsumR)) | |
End If | |
//Right head角度 Speed 配列代入 | |
tR(tN).headMot(iu) = RNheadmot | |
tR(tN).headSki(iu) = RNskihead | |
tR(tN).Speed(iu) = speedR | |
speedsumR = speedsumR + speedR | |
tR(tN).Skid(iu) = slipAngleR // RNheadmot - (RNskihead) //Math.Abs(RNheadmot - RNskihead) | |
SkidRsum = SkidRsum + tR(tN).Skid(iu) | |
If Math.Abs(tR(tN).maxSkid) <= Math.Abs(tR(tN).Skid(iu)) Then | |
tR(tN).maxSkid = Math.Abs(tR(tN).Skid(iu)) | |
End If | |
If Math.Abs(tR(tN).minSkid) >= Math.Abs(tR(tN).Skid(iu)) Then | |
tR(tN).minSkid = Math.Abs(tR(tN).Skid(iu)) | |
End If | |
//-Max check------------ | |
If Math.Abs(Rpyb(iu) - Rpyb(0)) > RpybMax Then | |
RpybMax = Math.Abs(Rpyb(iu) - Rpyb(0)) | |
End If | |
fallRX = Rpxb(iu) - Rpxb(0) | |
//----------------------------Gacc計算-------------------------------------- | |
If iu > 0 Then | |
Dim Alfa ;// Double = Math.Abs(tR(tN).headMot(iu) - tR(tN).headMot(iu - 1)) | |
Dim Alfarad ;// Double = Alfa * Math.PI / 180 | |
Dim cosAlfa ;// Double = Math.Cos(Alfarad) | |
Dim sinAlfa ;// Double = Math.Sin(Alfarad) | |
Dim V0 ;// Double = tR(tN).Speed(iu) * 0.277778 //kmh=>m/sec | |
Dim V1 ;// Double = tR(tN).Speed(iu - 1) * 0.277778 //kmh=>m/sec | |
Dim L ;// Double = V0 * sinAlfa | |
Dim m ;// Double = V1 - V0 * cosAlfa | |
Dim deltaV ;// Double = Math.Sqrt(L ^ 2 + m ^ 2) | |
Dim G01R ;// Double = deltaV / 0.125 | |
tR(tN).Gacc(iu) = G01R | |
GaccsumR = GaccsumR + G01R | |
If G01R > GaccmaxR Then | |
GaccmaxR = G01R | |
End If | |
If G01R < GaccminR Then | |
GaccminR = G01R | |
End If | |
End If | |
Next iu | |
//====GaccR加速度代入========================================== | |
tR(tN).Gaccave = GaccsumR / (tNumR - 1) | |
tR(tN).Gaccmax = GaccmaxR | |
tR(tN).Gaccmin = GaccminR | |
//============================================================================== | |
//tR() 代入 | |
//============================================================================== | |
//フォールライン距離fallen | |
tR(tN).fallen = fallR | |
//==============標高差:fallHeightと斜度計算:Slopedeg================================================ | |
tR(tN).fallHeight = initHiR - endHiR | |
tR(tN).Slopedeg = Math.Atan((initHiR - endHiR) / fallR) * 180 / Math.PI | |
//=========ForLoopの結果=================================== | |
tR(tN).aveSpeed = speedsumR / tNumR | |
tR(tN).Arclen = CInt(ArcsumR) | |
If tN > 0 Then | |
tR(tN).fallensum = tR(tN - 1).fallensum + tR(tN).fallen //フォールラインの距離累計 | |
tR(tN).Arclensum = tR(tN - 1).Arclensum + tR(tN).Arclen //ターン弧の距離累計 | |
tR(tN).fallHeightsum = tR(tN - 1).fallHeightsum + tR(tN).fallHeight //累積標高差 | |
Else //tN=0の時 | |
tR(tN).Arclensum = tR(tN).fallen | |
tR(tN).Arclensum = tR(tN).Arclen | |
tR(tN).fallHeightsum = tR(tN).fallHeight | |
End If | |
tR(tN).aveSpeed = speedsumR / tNumR | |
tR(tN).aveSkid = SkidRsum / tNumR | |
tR(tN).inSpeed = tR(tN).Speed(0) | |
tR(tN).outSpeed = tR(tN).Speed(tNumR) | |
//右円弧寸法 | |
tR(tN).fallen = fallRX | |
tR(tN).minorDia = RpybMax | |
tR(tN).majorDia = Rpxb(tNumR - 1) - Rpxb(0) | |
tR(tN).;//pectratio = tR(tN).minorDia / tR(tN).majorDia | |
tR(tN).Radius = (tR(tN).majorDia ^ 2 / 4 + tR(tN).minorDia ^ 2) / (2 * tR(tN).minorDia * 100) //cm=>m | |
//=================================================================================================== | |
//Lスキーの計算====================================================================================== | |
//=================================================================================================== | |
For iu = 0 To tNumL - 1 | |
//Debug.Print("tuenCald 4th getpos iu= " + CStr(iu)) | |
GetPos(iu + LturnstartNo) //dgv1からRTK座標読取り | |
//--Left Ski--------------- | |
Lpxb(iu) = CInt((LNlon * CosthR - LNlat * SinthR)) // theata だけ座標回転 | |
Lpyb(iu) = CInt((LNlon * SinthR + LNlat * CosthR)) // theata だけ座標回転 | |
Lpxr(iu) = CInt(((LNlon + LNrelE) * CosthR - (LNlat + LNrelN) * SinthR))// theata だけ座標回転 | |
Lpyr(iu) = CInt(((LNlon + LNrelE) * SinthR + (LNlat + LNrelN) * CosthR)) // theata だけ座標回転 | |
If iu > 0 Then | |
ArcsumL = ArcsumL + Math.Sqrt((Lpxb(iu) - Lpxb(iu - 1)) ^ 2 + (Lpyb(iu) - Lpyb(iu - 1)) ^ 2) | |
End If | |
//Left head角度 Speed 配列代入 | |
tL(tN).headMot(iu) = LNheadmot | |
tL(tN).headSki(iu) = LNskihead | |
tL(tN).Speed(iu) = speedL | |
speedsumL = speedsumL + speedL | |
tL(tN).Skid(iu) = slipAngleL//LNheadmot - (LNskihead) //Math.Abs(LNheadmot - LNskihead) | |
SkidLsum = SkidLsum + tL(tN).Skid(iu) | |
If Math.Abs(tL(tN).maxSkid) <= Math.Abs(tL(tN).Skid(iu)) Then | |
tL(tN).maxSkid = Math.Abs(tL(tN).Skid(iu)) | |
End If | |
If Math.Abs(tL(tN).minSkid) >= Math.Abs(tL(tN).Skid(iu)) Then | |
tL(tN).minSkid = Math.Abs(tL(tN).Skid(iu)) | |
End If | |
//--Max check------------ | |
If Math.Abs(Lpyb(iu) - Lpyb(0)) > LpybMax Then | |
LpybMax = Math.Abs(Lpyb(iu) - Lpyb(0)) | |
End If | |
fallLX = Lpxb(iu) - Lpxb(0) | |
//-----------------------------Gacc計算-------------------------------------- | |
If iu > 0 Then | |
Dim Alfa ;// Double = Math.Abs(tL(tN).headMot(iu) - tL(tN).headMot(iu - 1)) | |
Dim Alfarad ;// Double = Alfa * Math.PI / 180 | |
Dim cosAlfa ;// Double = Math.Cos(Alfarad) | |
Dim sinAlfa ;// Double = Math.Sin(Alfarad) | |
Dim V0 ;// Double = tL(tN).Speed(iu) * 0.277778 //kmh=>m/sec | |
Dim V1 ;// Double = tL(tN).Speed(iu - 1) * 0.277778 //kmh=>m/sec | |
Dim L ;// Double = V0 * sinAlfa | |
Dim m ;// Double = V1 - V0 * cosAlfa | |
Dim deltaV ;// Double = Math.Sqrt(L ^ 2 + m ^ 2) | |
Dim G01L ;// Double = deltaV / 0.125 | |
tL(tN).Gacc(iu) = G01L | |
GaccsumL = GaccsumL + G01L | |
If G01L > GaccmaxL Then | |
GaccmaxL = G01L | |
End If | |
If G01L < GaccminL Then | |
GaccminL = G01L | |
End If | |
// Debug.Print("L:tL(" + CStr(tN) + ").Gacc(" + CStr(iu) + ")=" + CStr(tL(tN).Gacc(iu)) + "GaccmaxL=" + CStr(GaccmaxL)) | |
End If | |
Next iu | |
//====GaccR加速度代入========================================== | |
tL(tN).Gaccave = GaccsumL / (tNumL - 1) | |
tL(tN).Gaccmax = GaccmaxL | |
tL(tN).Gaccmin = GaccminL | |
//============================================================================== | |
//tL() 代入 | |
//============================================================================== | |
//フォールライン距離fallen | |
tL(tN).fallen = fallL | |
//==============標高差:fallHeightと斜度計算:Slopedeg================================================ | |
tL(tN).fallHeight = initHiL - endHiL | |
tL(tN).Slopedeg = Math.Atan((initHiL - endHiL) / fallL) * 180 / Math.PI | |
//=========ForLoopの結果=================================== | |
tL(tN).aveSpeed = speedsumL / tNumL | |
tL(tN).Arclen = CInt(ArcsumL) | |
If tN > 0 Then | |
tL(tN).fallensum = tL(tN - 1).fallensum + tL(tN).fallen //フォールラインの距離累計 | |
tL(tN).Arclensum = tL(tN - 1).Arclensum + tL(tN).Arclen //ターン弧の距離累計 | |
tL(tN).fallHeightsum = tL(tN - 1).fallHeightsum + tL(tN).fallHeight //累積標高差 | |
Else //tN=0の時 | |
tL(tN).Arclensum = tL(tN).fallen | |
tL(tN).Arclensum = tL(tN).Arclen | |
tL(tN).fallHeightsum = tL(tN).fallHeight | |
End If | |
tL(tN).aveSpeed = speedsumL / tNumL | |
tL(tN).Arclen = CInt(ArcsumL) | |
tL(tN).aveSkid = SkidLsum / tNumL | |
SkidLsum = 0 | |
tL(tN).inSpeed = tL(tN).Speed(0) | |
tL(tN).outSpeed = tL(tN).Speed(tNumL) | |
//左円弧寸法 | |
tL(tN).fallen = fallLX | |
tL(tN).minorDia = LpybMax | |
tL(tN).majorDia = Lpxb(tNumL - 1) - Lpxb(0) | |
tL(tN).;//pectratio = tL(tN).minorDia / tL(tN).majorDia | |
tL(tN).Radius = (tL(tN).majorDia ^ 2 / 4 + tL(tN).minorDia ^ 2) / (2 * tL(tN).minorDia * 100) //cm=>m | |
//------------------------------------------------------------ | |
// Debug.Print("TURN Calc: ,minorDia=," + CStr(minorDia) + "cm,majorDia =," + CStr(majorDia) + "cm, ;//pectRatio=," + (minorDia / majorDia).ToString("0.00") + "===============================") | |
//------------------------------dgv2へ書き込み------------------------ | |
dgv2.ColumnCount = 100 | |
headText() | |
If dgv2.Rows.Count = 0 Then | |
End If | |
dgv2.Rows.Add(tR(tN).turnNo, "Rski", tR(tN).direction, tR(tN).Radius.ToString("0.0"), tR(tN).aveSkid.ToString("0.0"), tR(tN).aveSpeed.ToString("0.0"), tR(tN).Gaccmax.ToString("0.00"), tR(tN).Slopedeg.ToString("0.0"), tR(tN).;//pectratio.ToString("0.00"), (tR(tN).fallensum / 100).ToString("0.0"), (tR(tN).Arclensum / 100).ToString("0.0"), (tR(tN).fallHeightsum / 100).ToString("0.0"), tR(tN).turnTime, tR(tN).turnTimesum) | |
dgv2.Rows.Add(tL(tN).turnNo, "Lski", tL(tN).direction, tL(tN).Radius.ToString("0.0"), tL(tN).aveSkid.ToString("0.0"), tL(tN).aveSpeed.ToString("0.0"), tL(tN).Gaccmax.ToString("0.00"), tL(tN).Slopedeg.ToString("0.0"), tL(tN).;//pectratio.ToString("0.00"), (tL(tN).fallensum / 100).ToString("0.0"), (tL(tN).Arclensum / 100).ToString("0.0"), (tL(tN).fallHeightsum / 100).ToString("0.0"), tL(tN).turnTime, tL(tN).turnTimesum) | |
dgv2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells | |
dgv2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None | |
End Sub | |
*/ | |
//**************************************************************************************************************************** | |
/*************xyplot*********************************************** | |
private void xyplot() | |
{ | |
Graphics srcxy = Graphics.FromImage(xyBitmap); | |
Graphics srcsxy = Graphics.FromImage(xysBitmap); | |
Graphics desxy = Graphics.FromImage(p2Bitmap); | |
srcxy.Clear(Color.Black); | |
srcsxy.Clear(Color.Black); | |
int ix, irow; | |
int px = 0; | |
int py = 0; | |
//prown クリック座標逆引き配列 宣言 | |
prownx = new int[blen]; | |
prowny = new int[blen]; | |
// int pic2w = 300; | |
// int PIC2H = 300; | |
int bitxyw = xysize;// 3000; | |
int bitxyh = xysize;// 3000; | |
int nutralflag = 0; | |
long valx, valy; | |
long valxi, valyi; | |
// | |
blockn_1 = blockn; | |
blockn = comboBox7.SelectedIndex + 1;//blen個毎にブロック切り替え | |
Debug.Print("XYPLOT:blockn=" + blockn.ToString() + "dbk[].minlon=" + dbk[blockn].minlon.ToString() + "dbk[].minlat=" + dbk[blockn].minlat.ToString()); | |
// int startrow = (blockn - 2) * blen; | |
//---------------Nutral Point Array set Block指定のみ---------------------------------------------------- | |
if (blockn < comboBox7.Items.Count) | |
{ | |
for (irow = dbk[blockn].startRow; irow < dbk[blockn].endRow - 2; irow++)//dgv1.RowCount - 3; irow++) | |
{ | |
int ni = irow - dbk[blockn].startRow; | |
long sa = dgv[irow + 1, 3] - dgv[irow, 3]; | |
long sa_1 = dgv[irow + 2, 3] - dgv[irow + 1, 3]; | |
if (sa * sa_1 < 0 && irow > 2)//headmotの極値変化 | |
{ | |
dbk[blockn].nutralN[ni] = 1;//ニポイントを1 | |
//Debug.Print("Nutral ON:headMot="+dgv[irow,3].ToString()+"irow=" + irow.ToString() + ",dbk[blockn].nutralN[" + ni.ToString() + "]=" + dbk[blockn].nutralN[ni].ToString()); | |
} | |
else if (irow > 2) | |
{ | |
dbk[blockn].nutralN[ni] = 0;//ニュートラルポイントでない0 | |
// Debug.Print("Nutral Off:headMot="+dgv[irow,3].ToString()+"irow=" + irow.ToString() + ",dbk[blockn].nutralN[" + ni.ToString() + "]=" + dbk[blockn].nutralN[ni].ToString()); | |
} | |
} | |
} | |
//------------------------------------------------------------------------------------------------- | |
// if (blockn == comboBox7.Items.Count)//all | |
//{ | |
// startrow = 1; | |
// } | |
// | |
lonW = dbk[blockn].lonW; //maxlon[blockn] - minlon[blockn]; | |
latH = dbk[blockn].latH;//maxlat[blockn] - minlat[blockn]; | |
//Debug.Print("lonW=" + lonW.ToString() + ",latH=" + latH.ToString()); | |
//------------------------ソースxybitmap へ縮小プロット--------------------------------- | |
scalex = (double)(lonW * 1.1 / bitxyw);//lonWは、xysize 20000全幅cm/dot | |
scaley = (double)(latH * 1.1 / bitxyh);//latHは全高cm/dot | |
if (scalex > scaley) { scale0 = scalex; }//大きいスケールを採用 | |
if (scalex < scaley) { scale0 = scaley; } | |
//textBox14.Text = scale0.ToString(); | |
label3.Text = "縦=" + (latH / 100).ToString() + "m,横=" + (lonW / 100).ToString() + "m, 縮尺" + scale0.ToString("n2") + "cm/dot"; | |
//int endblock = 0; | |
//if (rowN > (blockn - 1) * blen) //最後のブロックでない場合のエンド行No | |
//{ | |
// endblock = (blockn - 1) * blen; | |
//} | |
//else | |
//{ | |
// endblock = rowN - 2; | |
//} | |
for (irow = dbk[blockn].startRow; irow < dbk[blockn].endRow; irow++)//dgv1.RowCount - 3; irow++) | |
{ | |
if (dgv[irow, 4] > 0 && dgv[irow, 5] > 0) | |
{ | |
if (checkBox1.Checked == true) | |
{ | |
valx = Convert.ToInt32(dgv1.Rows[irow].Cells[4].Value);//lon | |
valy = Convert.ToInt32(dgv1.Rows[irow].Cells[5].Value);//lat | |
} | |
else | |
{ | |
valx = dgv[irow, 4];//Convert.ToInt32(dgv1.Rows[irow].Cells[4].Value);//lon | |
valy = dgv[irow, 5];//Convert.ToInt32(dgv1.Rows[irow].Cells[5].Value);//lat | |
} | |
valxi = valx - dbk[blockn].minlon; | |
valyi = valy - dbk[blockn].minlat; | |
px_1 = px; | |
px = Convert.ToInt32((double)valxi / scale0); | |
py_1 = py; | |
py = Convert.ToInt32((double)valyi / scale0); | |
//prown 逆弾き代入 | |
if (blockn < comboBox7.Items.Count)//AllBlock 以外 | |
{ | |
prownx[irow - dbk[blockn].startRow] = px; | |
prowny[irow - dbk[blockn].startRow] = py; | |
} | |
// | |
// All block での色分け | |
Color cxy; | |
if (blockn > alln) | |
{ | |
a = Convert.ToInt32(Math.Ceiling((double)irow / blen)); | |
cxy = samples[a - 1]; | |
} | |
else | |
{ | |
cxy = samples[blockn - 1]; | |
} | |
// | |
if (checkBox11.Checked == true) | |
{ | |
// Pen p = new Pen(Color.LawnGreen, 2); | |
Pen p = new Pen(cxy, 4); | |
srcxy.DrawLine(p, px, py, px_1, py_1); | |
Pen p1 = new Pen(cxy, 1); | |
srcsxy.DrawLine(p1, px, py, px_1, py_1);//拡大用ソース | |
} | |
// Brush b1 = new SolidBrush(samples[blockn - 1]); | |
Brush b1 = new SolidBrush(cxy); | |
Brush b2 = new SolidBrush(Color.White); | |
//Nutral Point White | |
if (blockn < comboBox7.Items.Count)//AllBlock 以外 | |
{ | |
//Debug.Print("colorWhite:irow=" + irow.ToString() + "nutralN=" + dbk[blockn].nutralN[irow - dbk[blockn].startRow].ToString()); | |
if (dbk[blockn].nutralN[irow - dbk[blockn].startRow] == 1) | |
{ | |
nutralflag = 1; | |
} | |
} | |
// Debug.Print("irow=" + irow.ToString() + ",px=" + px.ToString() + "py=" + py.ToString()); | |
if (dgv[irow, 1] % 100 == 0)//F9P 100msec | |
{ | |
int diam = 16; | |
int pxd = px - diam / 2; | |
int pyd = py - diam / 2; | |
if (nutralflag == 1) { b1 = b2; } | |
srcxy.FillEllipse(b1, pxd, pyd, 24, 24); | |
srcsxy.FillEllipse(b1, pxd, pyd, 4, 4); | |
nutralflag = 0; | |
} | |
} | |
} | |
// Debug.Print("irow="+irow.otring()+"px,py="+px.ToString() +","+ py.ToString()); | |
//縮小表示 3000x3000を300x300へ縮小表示------------------------------------------------- | |
Rectangle srcrect = new Rectangle(0, 0, xysize, xysize); | |
Rectangle desrect = new Rectangle(0, 0, pic2w, pic2h); | |
desxy.DrawImage(xyBitmap, desrect, srcrect, GraphicsUnit.Pixel); | |
//p2sBitmap = p2Bitmap; | |
pictureBox2.Image = p2Bitmap; | |
Debug.Print("scale0=" + scale0.ToString() + "px,py=" + px.ToString() + "," + py.ToString()); | |
}//Picturebox2 xyplot****************************************************************************************************** | |
*////////////////////// | |
} | |
/* | |
if (checkBox2.Checked == true) | |
{ | |
//-----------------------------BinaryFilevread---------------------------------------------- | |
FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); | |
int fileSize = (int)fs.Length; // ファイルのサイズ | |
byte[] buf = new byte[fileSize]; // データ格納用配列 | |
int readSize; // Readメソッドで読み込んだバイト数 | |
int remain = fileSize; // 読み込むべき残りのバイト数 | |
int bufPos = 0; // データ格納用配列内の追加位置 | |
int bm = 0; | |
int bi; | |
while (remain > 0) | |
{ | |
// 1024Bytesずつ読み込む | |
readSize = fs.Read(buf, bufPos, Math.Min(1024, remain)); | |
bm++; | |
bufPos += readSize; | |
remain -= readSize; | |
//Debug.Print("bm=" + bm.ToString()); | |
} | |
fs.Dispose(); | |
int i; | |
for (i = 0; i < 200; i++) | |
{ | |
Debug.Print("fileSize=" + fileSize.ToString() + "buf[" + i.ToString() + "]=" + buf[i].ToString("X")); | |
} | |
// ubxcnv(buf, fileSize, ofd.FileName);//ubx 一括変換して、配列格納とファイルセーブ 任意でdgv,richtext表示 | |
}// binary read end | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment