コード例 #1
0
        public static VIPData FromStream(System.IO.BinaryReader br)
        {
            VIPData data = new VIPData();

            data.VIPNo     = br.ReadInt32();
            data.VIP_Chain = br.ReadDouble();
            data.VIP_level = br.ReadDouble();
            data.VCL1      = br.ReadDouble();
            data.VCL2      = br.ReadDouble();

            return(data);
        }
コード例 #2
0
        void WriteDataFile()
        {
            List <VVIP>  listparam    = this.GetParamData();
            string       TempFilePath = Path.Combine(this.app.AppDataPath, "VAL1.TMP");
            BinaryWriter bw           = new BinaryWriter(new FileStream(TempFilePath, FileMode.Create), Encoding.Default);

            FirstLine firstline = new FirstLine();

            firstline.ModelName  = this.tbModelName_.Text;
            firstline.StringName = this.tbStringlabel_.Text;
            firstline.Code       = 1;
            firstline.AcceptCode = 0;
            firstline.ToStream(bw);

            SecondLineVIP secondline = new SecondLineVIP();

            secondline.TotalVIPs  = this.dataGridParams_.Rows.Count;
            secondline.StartChain = this.tbStartChainage_.Value;
            secondline.EndChain   = this.tbEndChainage_.Value;
            secondline.Interval   = this.tbChainageInterval_.Value;
            secondline.ToStream(bw);


            for (int i = 0; i < listparam.Count; i++)
            {
                VVIP    data  = listparam[i];
                VIPData vdata = new VIPData();
                vdata.VIPNo     = i + 1;
                vdata.VIP_Chain = data.chainx;
                vdata.VIP_level = data.chainy;
                if (data.sym == true)
                {
                    vdata.VCL1 = data.vcl1 / 2;
                    vdata.VCL2 = data.vcl1 / 2;
                }
                else
                {
                    vdata.VCL1 = data.vcl1;
                    vdata.VCL2 = data.vcl2;
                }
                vdata.ToStream(bw);
            }
            bw.Close();
        }
コード例 #3
0
        void vip_input()
        {
            FirstLine     val1;
            SecondLineVIP val2;
            VIPData       val3;

            StreamWriter fptmp;

            pathfile = Path.Combine(path, "VAL1.TMP");
            fp1      = new BinaryReader(new FileStream(pathfile, FileMode.Open, FileAccess.Read), Encoding.Default);

            //strcpy(pathfile, path);
            //strcat(pathfile, "val1.tmp");

            //if ((fp1 = fopen(pathfile, "rb")) == NULL)
            //{
            //    sprintf(msgstr, " Data file %s not found...", pathfile);
            //    AfxMessageBox(msgstr);
            //    return;
            //    //no_file_msg();
            //}

            pathfile = Path.Combine(path, "VAL1.TXT");
            fptmp    = new StreamWriter(pathfile, false);

            //strcpy(pathfile, path);
            //strcat(pathfile, "val1.txt");

            //if ((fptmp = fopen(pathfile, "w")) == NULL)
            //{
            //    sprintf(msgstr, " Data file %s not found...", pathfile);
            //    AfxMessageBox(msgstr);
            //    return;
            //    //no_file_msg();
            //}

            val1 = FirstLine.FromStream(fp1);

            modnam = val1.ModelName;
            stglbl = val1.StringName;

            val2 = SecondLineVIP.FromStream(fp1);

            vips   = val2.TotalVIPs;
            chn1   = val2.StartChain;
            endchn = val2.EndChain;
            inc    = val2.Interval;

            fptmp.WriteLine("VIP = " + vips.ToString());

            pts = 0;

            for (ip = 0; ip < vips; ip++)
            {
                val3 = VIPData.FromStream(fp1);

                vip[ip]   = new double();
                level[ip] = new double();
                level[ip] = new double();
                level[ip] = new double();
                grad[ip]  = new double();

                vip[ip]   = 0.0;
                level[ip] = 0.0;
                vcl1[ip]  = 0.0;
                vcl2[ip]  = 0.0;

                vipno     = val3.VIPNo;
                vip[ip]   = val3.VIP_Chain;
                level[ip] = val3.VIP_level;
                vcl1[ip]  = val3.VCL1;
                vcl2[ip]  = val3.VCL2;

                fptmp.WriteLine("303\t" + vip[ip].ToString() + "\t" + level[ip].ToString() + "\t" + ((double)(vcl1[ip] + vcl2[ip])).ToString());

                if (ip > 0)
                {
                    if (vip[ip] <= vip[ip - 1])
                    {
                        //chain_error();
                        error_flag = 1;
                        msgstr     = "Chainage data inconsistent at VIP " + ((int)(vipno - 1)).ToString();
                        System.Windows.Forms.MessageBox.Show(msgstr, HeadsUtils.Constants.ProductName);
                        fpm.WriteLine("    In Process : " + msgstr);
                        fp3.Close();
                        fp1.Close();
                        return;
                    }

                    grad[ip] = (level[ip] - level[ip - 1]) / (vip[ip] - vip[ip - 1]) / 100.0;
                }
            }
            fp1.Close();
            fptmp.Close();

            if (endchn > vip[vips - 1])
            {
                endchn = vip[vips - 1];/*NEW*/
            }
        }