Advertisement
Guest User

csgo tradingbot

a guest
Dec 7th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. package com.wiematic.www.sensor;
  2.  
  3. import android.graphics.Color;
  4. import android.location.Location;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.TextView;
  10. import android.widget.Toast;
  11.  
  12. import com.google.android.gms.maps.model.LatLng;
  13.  
  14. import java.util.ArrayList;
  15. import java.util.List;
  16.  
  17. import static android.R.attr.button;
  18.  
  19. public class Auswertung extends AppCompatActivity {
  20. List<Location> listNetworkLocation = new ArrayList<Location>();
  21. List<Location> listGPSLocation = new ArrayList<Location>();
  22. List<Location> listInterpolationLocation = new ArrayList<Location>();
  23. Button bttnabweichung;
  24. private SensorDataSource dataSource;
  25. TextView tvStatus,tvfehler;
  26. @Override
  27. protected void onCreate(Bundle savedInstanceState) {
  28. super.onCreate(savedInstanceState);
  29. setContentView(R.layout.activity_auswertung);
  30. dataSource = new SensorDataSource(this);
  31. init();
  32. fillgps();
  33. fillNetwork();
  34. fillInterpol();
  35. //Toast.makeText(getApplicationContext(),sensorDataSource.getAllSensorDataObjects().get(1).getWifiBesch(), Toast.LENGTH_LONG).show();
  36. //getErrorvalues(listtestInterpol,listtestGPS);
  37. }
  38. public double getDistance(Location location0, Location location)
  39. {
  40. String str = "";
  41. double dDistance = 0.0;
  42. double earthRadius = 6371000; //meters
  43. double dLat = Math.toRadians(location0.getLatitude()-location.getLatitude());
  44. double dLng = Math.toRadians(location0.getLongitude()-location.getLongitude());
  45. double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
  46. Math.cos(Math.toRadians(location.getLatitude())) * Math.cos(Math.toRadians(location0.getLatitude())) *
  47. Math.sin(dLng/2) * Math.sin(dLng/2);
  48. double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  49. dDistance= (earthRadius * c);
  50. return dDistance;
  51. }
  52. public void interpolation(Location location1, Location location2)
  53. {
  54. location1.setTime(0);
  55. location2.setTime(149261);
  56. long t1 = location1.getTime(); // in milliseconds;
  57. long t2 = location2.getTime();
  58. double last1,last2;
  59. double deltaLat = location2.getLatitude() - location1.getLatitude();
  60. double deltaLon = location2.getLongitude()- location1.getLongitude();
  61. long step = 1 * 1000; // 1 second in millis
  62. for (long t = t1; t < t2; t+= step)
  63. {
  64. double i1 = t - t1;
  65. double i2 = t2 - t1;
  66. double t0_1 = (i1) / (i2);
  67. double latInter = location1.getLatitude() + deltaLat * t0_1;
  68. double lonInter = location1.getLongitude() + deltaLon * t0_1;
  69. Location locInter = new Location("");
  70. locInter.setLatitude(latInter);
  71. locInter.setLongitude(lonInter);
  72. locInter.setTime(t);
  73. listInterpolationLocation.add(locInter);
  74. }
  75. }//
  76. public Location interpolation(Location location1, Location location2, Location location3)
  77. {
  78. long t1 = location1.getTime(); // in milliseconds;
  79. long t2 = location2.getTime();
  80. long t3 = location3.getTime();
  81. double deltaLat = location2.getLatitude() - location1.getLatitude();
  82. double deltaLon = location2.getLongitude()- location1.getLongitude();
  83. long step = t3 - t1;
  84. long t = t1 + step;
  85. double ts1 = t - t1;
  86. double ts2 = t2 - t1;
  87. double t0_1 = ts1 / ts2;
  88. double latInter = location1.getLatitude() + deltaLat * t0_1;
  89. double lonInter = location1.getLongitude() + deltaLon * t0_1;
  90. Location interPolLocation = new Location("");
  91. interPolLocation.setLongitude(lonInter);
  92. interPolLocation.setLatitude(latInter);
  93. return interPolLocation;
  94. }//
  95. public String getErrorvalues(List<Location> listInterpol, List<Location> listGPSNWLocation)
  96. {
  97. dataSource.open();
  98. double dStarttime = dataSource.getStartDataObjects().get(0).getTimeStamp();
  99. dataSource.close();
  100. String s = "Errorvalues";
  101. for(int i=0;i<listGPSNWLocation.size()-1;i++)
  102. {//For1-Start
  103. for (int j = 0;j<listInterpol.size()-1;j++)
  104. {//For2-Start
  105. if (listInterpol.get(j).getTime()==listGPSNWLocation.get(i).getTime()-dStarttime)
  106. {//If-Start
  107. s += "\n"+i+". "+ getDistance(listInterpol.get(j),listGPSNWLocation.get(i));
  108. }//If-End
  109. }//For2-End
  110. }//For1-End
  111. return s;
  112. }//Method-End
  113. public void fillgps()
  114. {
  115. tvStatus.setText("Status: Fülle GPSliste");
  116. dataSource.open();
  117. List<Location> listLocations= new ArrayList<Location>();
  118. for (int i = 0; i<dataSource.getGPSSensorDataObjects().size()-1;i++)
  119. {//For-Start
  120. dataSource.open();
  121. Location location = new Location("");
  122. location.setLatitude(dataSource.getGPSSensorDataObjects().get(i).getGPSlat());
  123. location.setLongitude(dataSource.getGPSSensorDataObjects().get(i).getGPSlong());
  124. location.setTime(dataSource.getGPSSensorDataObjects().get(i).getTimeStamp());
  125. listGPSLocation.add(location);
  126. }//For-End
  127. dataSource.close();
  128. }
  129. public void fillNetwork()
  130. {
  131. tvStatus.setText("Status: Fülle NWliste");
  132. dataSource.open();
  133. List<Location> listLocations= new ArrayList<Location>();
  134. for (int i = 0; i<dataSource.getNETWORKSensorDataObjects().size()-1;i++)
  135. {//For-Start
  136. dataSource.open();
  137. Location location = new Location("");
  138. location.setLatitude(dataSource.getNETWORKSensorDataObjects().get(i).getGPSlat());
  139. location.setLongitude(dataSource.getNETWORKSensorDataObjects().get(i).getGPSlong());
  140. location.setTime(dataSource.getNETWORKSensorDataObjects().get(i).getTimeStamp());
  141. listNetworkLocation.add(location);
  142.  
  143. }//For-End
  144. dataSource.close();
  145. }
  146. public void fillInterpol()
  147. {
  148. tvStatus.setText("Status: Fülle Interpolationsliste");
  149. dataSource.open();
  150. Location location1 = new Location("");
  151. location1.setLatitude(dataSource.getStartDataObjects().get(0).getGPSlat());
  152. location1.setLongitude(dataSource.getStartDataObjects().get(0).getGPSlong());
  153. location1.setTime(dataSource.getStartDataObjects().get(0).getTimeStamp());
  154. Location location2 = new Location("");
  155. location2.setLatitude(dataSource.getEndSensorDataObjects().get(0).getGPSlat());
  156. location2.setLongitude(dataSource.getEndSensorDataObjects().get(0).getGPSlong());
  157. location2.setTime(dataSource.getEndSensorDataObjects().get(0).getTimeStamp());
  158. interpolation(location1,location2);
  159. dataSource.close();
  160. tvStatus.setText("Status: Betriebsbereit");
  161. tvStatus.setTextColor(Color.GREEN);
  162. }
  163. public void init()
  164. {
  165. tvStatus = (TextView) findViewById(R.id.tv_Status);
  166. tvfehler = (TextView) findViewById(R.id.tv_abweichung);
  167. //BUTTONS
  168. bttnabweichung = (Button) findViewById(R.id.bttn_abweichung);
  169. bttnabweichung.setOnClickListener(new View.OnClickListener() {
  170. @Override
  171. public void onClick(View view) {
  172. tvfehler.setText(getErrorvalues(listInterpolationLocation,listGPSLocation));
  173. }
  174. });
  175. }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement