基本信息
源码名称:遥远工具箱(FarToolBox-工程篇)
源码大小:35.86M
文件格式:.zip
开发语言:Java
更新时间:2024-11-21
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
通过android平台编写的工程项目上常用的设备选型计算,如发电机、变压器、搅拌站、通风机、水泵、电力、风管、运输费用等。另外还有一个生活篇程序。
package eng.toolbox.far; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.app.Activity; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.WindowManager; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Toast; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import eng.toolbox.far.Adapter.SBBYQInfoAdapter; import eng.toolbox.far.Adapter.SBListBYQ; import eng.toolbox.far.Adapter.SBListTFJ; public class FarToolEng_GCGJ_BYQXZ_Activity extends Activity implements OnClickListener { private EditText edtZFH,edtTSL,edtGLYS,edtGLYSMB,edtSYXL,edtYGGL,edtWGGL,edtSZGL,edtSZGLBC,edtBYQRL,edtBYQRLBC,edtBCRL,edtBCRLDR; private Button bJS,bJSXX; private Button bAdd,bSub; private ListView listView; private List<SBListBYQ> sblist;//=new ArrayList<SBListBYQ>(); private long exitTime; private SBBYQInfoAdapter adapterSB=new SBBYQInfoAdapter(this,sblist);; private UserInfoSharedPre userInfoSharedPre;//=new UserInfoSharedPre(null); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //��title //requestWindowFeature(Window.FEATURE_NO_TITLE); //ȫ�� getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN); setContentView(R.layout.fartooleng_gcgj_byqxz_activity); bJS =(Button)findViewById(R.id.btnJS_BYQXZ); bJSXX =(Button)findViewById(R.id.btnJSXX_BYQXZ_GCGJ); bAdd=(Button)findViewById(R.id.btnAddSB_BYQXZ_GCGJ); bSub=(Button)findViewById(R.id.btnSubSB_BYQXZ_GCGJ); listView=(ListView) findViewById(R.id.listSB_BYQXZ_GCGJ); edtZFH=(EditText)findViewById(R.id.edt_ZFH_BYQXZ); edtTSL=(EditText)findViewById(R.id.edt_TSL_BYQXZ); edtGLYS=(EditText)findViewById(R.id.edt_GLYS_BYQXZ); edtGLYSMB=(EditText)findViewById(R.id.edt_GLYSMB_BYQXZ); edtSYXL=(EditText)findViewById(R.id.edt_SYXL_BYQXZ); edtYGGL=(EditText)findViewById(R.id.edt_YGGL_BYQXZ); edtWGGL=(EditText)findViewById(R.id.edt_WGGL_BYQXZ); edtSZGL=(EditText)findViewById(R.id.edt_SZGL_BYQXZ); edtSZGLBC=(EditText)findViewById(R.id.edt_SZGLBC_BYQXZ); edtBYQRL=(EditText)findViewById(R.id.edt_BYQRL_BYQXZ); edtBYQRLBC=(EditText)findViewById(R.id.edt_BYQRLBC_BYQXZ); edtBCRL=(EditText)findViewById(R.id.edt_BCRL_BYQXZ); edtBCRLDR=(EditText)findViewById(R.id.edt_BCRLDR_BYQXZ); bJS.setOnClickListener(this); bJSXX.setOnClickListener(this); bAdd.setOnClickListener(this); bSub.setOnClickListener(this); userInfoSharedPre=new UserInfoSharedPre(); sblist=userInfoSharedPre.getUserInfo(this);//读保存数据 adapterSB=new SBBYQInfoAdapter(this,sblist); listView.setAdapter(adapterSB); //自定义事件 adapterSB.setMyValueChangeListener(new SBBYQInfoAdapter.MyValueChangeListener() { @Override public void myValueChangeListener(int position) { double sz=0.0; for(int i=0;i<sblist.size();i ){ SBListBYQ sbListBYQItem =sblist.get(i); if(sbListBYQItem.getSel()==true){ sz=sz sbListBYQItem.getPe(); } } if(sz>=0){ edtZFH.setText(String.valueOf(sz)); } Log.v("BYQ_信息检测", "myValueChangeListener:" position ",总功率=" sz); } @Override public void onCheckChange(int position) { } @Override public void onTextChange(int position) { } }); } @Override public void onClick(View v) { String s1,s2,s3,s4,s5,s6,s7; double d1,d2,d3,d4,d5,d6,d7,d8,d10,d11,d12,d13,d14,d15,d16,d17; Integer ib=0; Double d9=0.0; DecimalFormat df=new DecimalFormat("0.0"); switch (v.getId()){ case R.id.btnJS_BYQXZ: case R.id.btnJSXX_BYQXZ_GCGJ: if(edtZFH.getText().toString().equals("")){ edtZFH.setText("860"); } if(edtTSL.getText().toString().equals("")){ edtTSL.setText("0.7"); } if(edtGLYS.getText().toString().equals("")){ edtGLYS.setText("0.9"); } if(edtGLYSMB.getText().toString().equals("")){ edtGLYSMB.setText("0.95"); } if(edtSYXL.getText().toString().equals("")){ edtSYXL.setText("0.9"); } if(v.getId()==R.id.btnJS_BYQXZ){//原来的方法 d1=Double.parseDouble(edtZFH.getText().toString());//总负荷 d2=Double.parseDouble(edtTSL.getText().toString());//同时率 d3=Double.parseDouble(edtGLYS.getText().toString());//功率因数 d4=Double.parseDouble(edtSYXL.getText().toString());//使用效率 d14=Double.parseDouble(edtGLYSMB.getText().toString());//目标功率因数 d5=d1*d2;//有功功率 edtYGGL.setText(df.format(d5)); d6=d5/(d3*d4);//视在功率 edtSZGL.setText(df.format(d6)); d16=d5/(d14*d4);//补偿后视在功率 edtSZGLBC.setText(df.format(d16)); d7=Math.acos(d3);//功率因素角 d8=d5*Math.tan(d7);//无功功率 edtWGGL.setText(df.format(d8)); // d9=0.0; // d10=0; // ib=0; // d13=d6/0.8; // if(d13<=30.0) ib = 30; // else if(d13<=50.0) ib = 50; // else if(d13<=63.0) ib = 63; // else if(d13<=80.0) ib = 80; // else if(d13<=100.0) ib = 100; // else if(d13<=125.0) ib = 125; // else if(d13<=160.0) ib = 160; // else if(d13<=20.0) ib = 200; // else if(d13<=25.0) ib = 250; // else if(d13<=315.0) ib = 315; // else if(d13<=400.0) ib = 400; // else if(d13<=500.0) ib = 500; // else if(d13<=630.0) ib = 630; // else if(d13<=800.0) ib = 800; // else if(d13<=1000.0) ib = 1000; // else if(d13<=1250.0) ib = 1250; // else if(d13<=1600.0) ib = 1600; // else if(d13<=2000.0) ib = 2000; // else { // d9=d6/0.8; // ib = d9.intValue(); // } // edtBYQRL.setText(df.format(ib));//变压器容量 // // d9=0.0; // d10=0; // ib=0; // d13=d16/0.8; // if(d13<=30.0) ib = 30; // else if(d13<=50.0) ib = 50; // else if(d13<=63.0) ib = 63; // else if(d13<=80.0) ib = 80; // else if(d13<=100.0) ib = 100; // else if(d13<=125.0) ib = 125; // else if(d13<=160.0) ib = 160; // else if(d13<=20.0) ib = 200; // else if(d13<=25.0) ib = 250; // else if(d13<=315.0) ib = 315; // else if(d13<=400.0) ib = 400; // else if(d13<=500.0) ib = 500; // else if(d13<=630.0) ib = 630; // else if(d13<=800.0) ib = 800; // else if(d13<=1000.0) ib = 1000; // else if(d13<=1250.0) ib = 1250; // else if(d13<=1600.0) ib = 1600; // else if(d13<=2000.0) ib = 2000; // else { // d9=d16/0.8; // ib = d9.intValue(); // } // edtBYQRLBC.setText(df.format(ib));//变压器容量 // ///补偿如何求 if(d3>=0.9){ d10 = 0; }else{ //d10 = ib * d4 * 0.691; d11=Math.tan(Math.acos(d14));//目标功率因素角 d12=Math.tan(Math.acos(d3));//目前功率因素角 d10=d5*(d12-d11); } edtBCRL.setText(df.format(d10)); d15=d10/(0.31415926*0.400*0.400); edtBCRLDR.setText(df.format(d15)); }else{//列表的方法 double p=0.0,q=0.0,s=0.0; double p1=0.0,q1=0.0,s11=0.0; double cos1=0.0,B=0.0; for(int i=0;i<sblist.size();i ){ SBListBYQ sbListBYQItem =sblist.get(i); if(sbListBYQItem.getSel()==true){ p=p sbListBYQItem.getP();//有功 q=q sbListBYQItem.getQ(); //无功 s=s sbListBYQItem.getS();//视在 } } //已经按需用系统折减,则同时系数一般较高,有功一般为0.9-1.0取0.95,无功一般为0.93-0.97取0.97 p1=p*0.95; q1=q*0.97; s11=s*0.97; cos1=p1/s11;//折算综合功率因素 B=s11/0.8; //负荷率一般取70%~85%,取80%;假设计算结果为325,可选315或400kVA d6=s11;// edtYGGL.setText(df.format(p1));//有功功率 edtSZGL.setText(df.format(s11));//视在功率 d4=Double.parseDouble(edtSYXL.getText().toString());//使用效率 d14=Double.parseDouble(edtGLYSMB.getText().toString());//目标功率因数 d16=p1/(d14*d4);//补偿后视在功率 edtSZGLBC.setText(df.format(d16));//补偿后视在功率 // d7=Math.acos(d3);//功率因素角 // d8=d5*Math.tan(d7);//无功功率 edtWGGL.setText(df.format(q1));//无功功率 // ///补偿如何求 Log.v("BYQ_信息检测", "综合功率因素COS1=" cos1); if(cos1>=0.9){ d10 = 0; }else{ //d10 = ib * d4 * 0.691; d11=Math.tan(Math.acos(d14));//目标功率因素角 d12=Math.tan(Math.acos(cos1));//目前功率因素角--综合 d10=p1*(d12-d11); } edtBCRL.setText(df.format(d10)); d15=d10/(0.31415926*0.400*0.400); edtBCRLDR.setText(df.format(d15)); } d9=0.0; d10=0; ib=0; d13=d6/0.8; if(d13<=35.0) ib = 30; else if(d13<=55.0) ib = 50; else if(d13<=70.0) ib = 63; else if(d13<=88.0) ib = 80; else if(d13<=110.0) ib = 100; else if(d13<=140.0) ib = 125; else if(d13<=180.0) ib = 160; else if(d13<=220.0) ib = 200; else if(d13>220.0 && d13<=280) ib = 250; else if(d13>280.0 && d13<=350) ib = 315; else if(d13>350.0 && d13<=450) ib = 400; else if(d13>450.0 && d13<=550.0) ib = 500; else if(d13>550.0 && d13<=710.0) ib = 630; else if(d13>710.0 && d13<=900.0) ib = 800; else if(d13>900.0 && d13<=1100.0) ib = 1000; else if(d13>1150.0 && d13<=1450.0) ib = 1250; else if(d13>1400.0 && d13<=1750.0 ) ib = 1600; else if(d13>1750.0 && d13<=2250.0) ib = 2000; else { d9=d6/0.8; //d9=(long)Math.round(d9/10.0)*10; d9=(d9/10.0);//除以10 //d9=d9.intValue()*10; ib = (d9.intValue()*10); } edtBYQRL.setText(df.format(d13));//变压器容量 edtBYQRLBC.setText(df.format(ib));//变压器容量--补偿 break; case R.id.btnAddSB_BYQXZ_GCGJ: SBListBYQ sbListBYQItem =new SBListBYQ("设备",100.0,0.70,0.80,0.0,0.0,0.0,0.0,true); sblist.add(sbListBYQItem); adapterSB.notifyDataSetChanged(); listView.smoothScrollToPosition(sblist.size()-1); //listView.addHeaderView();//添加头部View //listView.setAdapter(adapterSB);//有了这一句,每增加一行就会让前一行重置 //如何直接启动计算??? // adapterSB.setMyValueChangeListener(null);//有这一句就无法动作 break; case R.id.btnSubSB_BYQXZ_GCGJ: //int i=adapterSB.getItemId(); for(int i=0;i<sblist.size();i ){ if(sblist.get(i).getSel()==true){ sblist.remove(i);//删除后size自动会减1,但为什么全选时始终会有一个不会删除——总是第一个没删除 } } adapterSB.notifyDataSetChanged(); break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. //getMenuInflater().inflate(R.menu.far_tool_eng_gcgi__ssb, menu); return true; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN){ //也可以检测按的次数,一次提醒,两次关闭,下面是检测间隔时间 if((System.currentTimeMillis()-exitTime) > 2000){//间隔大于2秒 Toast.makeText(getApplicationContext(), "再点一次退出!", Toast.LENGTH_SHORT).show(); exitTime = System.currentTimeMillis(); } else { //退出前进行保存 if(sblist.size()>0){ userInfoSharedPre=new UserInfoSharedPre(sblist); userInfoSharedPre.saveUserInfo(this);//保存数据 } finish();//退出本界面 //System.exit(0); //按BACK键:目的是让其隐藏而不FINISH //moveTaskToBack(true); } return true; } return super.onKeyDown(keyCode, event); } public static class UserInfoSharedPre { private List<SBListBYQ> sblist; private List<SBListBYQ> sblistpre; private UserInfoSharedPre(){ this.sblist=sblist; } private UserInfoSharedPre(List<SBListBYQ> sblist){ this.sblist=sblist; } // 用户数据的存储 public boolean saveUserInfo(Context context) { try{ // 获取SharedPreferences对象,同时指定文件名称和访问权限 SharedPreferences sp = context.getSharedPreferences("MyData", Context.MODE_PRIVATE); // 获取获取SharedPreferences的编辑器对象 SharedPreferences.Editor edit = sp.edit(); //没有修改功能,如果原来有数据,只能删除后再保存。 sblistpre=getUserInfo(context); if(sblistpre.size()>0){ edit.remove("VALUEBYQ"); //editor.remove(“name”); // 根据key删除数据 //editor.clear(); // 删除所有数据 } // 通过编辑器进行数据的存储 String ss = "",s1=""; for(int i=0;i<this.sblist.size();i ){ ss=ss sblist.get(i).getSel() "," sblist.get(i).getDevName() "," sblist.get(i).getPe() "," sblist.get(i).getKd() "," sblist.get(i).getCos() "="; } Log.v("BYQ_信息检测", "ValueSave=" ss); edit.putString("VALUEBYQ",ss); edit.commit(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } // 读取用户数据 public static List<SBListBYQ> getUserInfo(Context context) { // 获取SharedPreferences对象,同时指定文件名称和访问权限 List<SBListBYQ>sblist =new ArrayList<SBListBYQ>(); SharedPreferences sp = context.getSharedPreferences("MyData", Context.MODE_PRIVATE); String ss = sp.getString("VALUEBYQ", ""); Log.v("BYQ_信息检测", "ValueGet=" ss); if(ss.trim().equals("")) return sblist; String [] s1=ss.split("=",-1);//条 if(s1.length>0){ for(int i=0;i<s1.length;i ){ Log.v("BYQ_信息检测", "S1=" s1[i]); String [] s2=s1[i].split(",",-1); if(s2.length>=5){ boolean sel = s2[0].equals("true")?true:false; String devName=s2[1]; double Pe=Double.parseDouble(s2[2]); double Kd=Double.parseDouble(s2[3]); double Cos=Double.parseDouble(s2[4]); SBListBYQ sbListBYQ=new SBListBYQ(devName,Pe,Kd,Cos,0.0,0.0,0.0,0.0,sel); sblist.add(sbListBYQ); } } } //String password = sp.getString("Pwd",""); //Map<String,String> userMap = new HashMap<>(); //userMap.put("username",username); //userMap.put("password",password); return sblist; } } //Android 保存到本地 android文件储存 //https://blog.51cto.com/u_16099246/6307215 // //自定义鉴定事件 // @Override // public void myTextChangeListener(View v, int position) { //// SBList sbListItem=sblist.get(position); //// double Pe=Double.parseDouble(sbListItem.getPe().toString()); //// double Kd=Double.parseDouble(sbListItem.getKd().toString()); //// double Cos=Double.parseDouble(sbListItem.getCos().toString()); //// double Tan=Math.tan(Math.acos(Cos)); //// double P=Pe* Kd; //// double Q=Tan*P; //// double S=Math.sqrt(Math.pow(P,2) Math.pow(Q,2)); //// sblist.get(position).setTan(Tan); //// sblist.get(position).setP(P); //// sblist.get(position).setQ(Q); //// sblist.get(position).setS(S); //// adapterSB.notifyDataSetChanged(); // adapterSB.setMyTextChangeListener(new SBInfoAdapter.MyTextChangeListener() { // @Override // public void myTextChangeListener(View v, int position) { // SBList sbListItem=sblist.get(position); // double Pe=Double.parseDouble(sbListItem.getPe().toString()); // double Kd=Double.parseDouble(sbListItem.getKd().toString()); // double Cos=Double.parseDouble(sbListItem.getCos().toString()); // double Tan=Math.tan(Math.acos(Cos)); // double P=Pe* Kd; // double Q=Tan*P; // double S=Math.sqrt(Math.pow(P,2) Math.pow(Q,2)); // sblist.get(position).setTan(Tan); // sblist.get(position).setP(P); // sblist.get(position).setQ(Q); // sblist.get(position).setS(S); // adapterSB.notifyDataSetChanged(); // } // }); // // //adapterSB.notify(); // //listView.notify(); // Log.v("BYQ_信息检测", "myTextChangeListener:" position ",Item:" sblist.get(position)); // } }