示例#1
0
        public string StringName; //[20];

        public static FirstLine FromStream(System.IO.BinaryReader br)
        {
            FirstLine data = new FirstLine();

            data.Code       = br.ReadInt16();
            data.AcceptCode = br.ReadInt16();
            data.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
            data.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(data);
        }
示例#2
0
        public bool Funcmain(string argv1)
        {
            path = argv1;
            //read_default();

            pathfile = Path.Combine(path, "VAL1.TMP");

            fp1 = new BinaryReader(new FileStream(pathfile, FileMode.Open, FileAccess.Read), Encoding.Default);
            FirstLine val1 = FirstLine.FromStream(fp1);

            fp1.Close();

            pathfile = Path.Combine(path, "VALIGN.TMP");
            fp2      = new StreamWriter(pathfile, false);

            pathfile = Path.Combine(path, "VAL2.TMP");
            fp3      = new BinaryWriter(new FileStream(pathfile, FileMode.Create), Encoding.Default);

            pathfile = Path.Combine(path, "ERRORMESSAGES.TXT");
            fpm      = new StreamWriter(pathfile, true);
            fpm.WriteLine("");
            fpm.WriteLine("    *************************************************");
            fpm.WriteLine("    Program [HEADS:Design:VALIGNMENT] was run on  " + DateTime.Now.ToString());

            code = (int)val1.Code;
            switch (val1.Code)
            {
            case 1:
                vip_method();
                break;

            default: break;
            }

            fpm.WriteLine("    *************************************************");

            fp2.Close();
            fp3.Close();
            fpm.Close();


            if (error_flag == 1)
            {
                System.Windows.Forms.MessageBox.Show("Check the file ERRORMESSAGES.TXT for all the details", HeadsUtils.Constants.ProductName);
            }

            //if (val1.AcceptCode == 1)
            //    save_valign();

            return((error_flag == 1) ? false : true);
        }
示例#3
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();
        }
示例#4
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*/
            }
        }