public class FileManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.lang.String |
axisX
x value
|
java.lang.String |
axisY
y value
|
java.lang.String |
axisZ
z value
|
java.lang.String |
fileName
file name
|
java.lang.String |
latitude
latitude
|
java.lang.String |
longitude
longitude
|
double |
minGPSboundarie |
boolean |
ortLowerTreshold |
boolean |
pstLowerTreshold |
static int |
SAVING_SOUND_HAS_COMPLETED
state that the writting of the sound into the file is completed
|
Constructor and Description |
---|
FileManager(java.lang.String provided_file_name,
java.lang.Boolean isToappend,
android.content.Context ctx)
allocate outputStream and inputstream so as to write or read a file
* during the creation of the file, there are two option : create an empty
* file or append always to the end of the file
isToappend defines if we will append the text at the end of the file
or if instead we erase the file to write the text
|
FileManager(java.lang.String provided_file_name,
java.lang.Boolean isToappend,
android.content.Context ctx,
java.lang.String where)
Create a file
allocate outputStream and inputstream so as to write or read a file
during the creation of the file, there are two option : create an empty
file or append always to the end of the file
|
Modifier and Type | Method and Description |
---|---|
void |
addFileListener(FileListener toadd)
add a file listener
|
int |
close()
close the file
|
double |
deg2rad(double deg)
degree to radian
|
void |
deleteFilesAftZip(java.io.File[] files)
delete all the files
|
java.lang.Double |
distZones(double lat1,
double lon1,
double lat2,
double lon2)
distance
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extract(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix)
scan a matrix
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extractCommontimeSeries(java.util.List<FileManager> remoteFilelist)
extract the samples included in the list of files and the local file that is calling the
function whenever they have common time stamps
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extractCommontimeSeries(java.util.List<FileManager> remoteFilelist,
ContextData ctx)
extract the samples included in the list of files and the local file that is calling the
function whenever they have common time stamps
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extractFilterGPSorientation(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix,
ContextData ctx)
scan a matric
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extractFilterMatrix(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix,
ContextData ctx)
scan a matrix
|
java.util.ArrayList<java.util.ArrayList<java.lang.Double>> |
extractGPSorientation(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix)
scan a matrix
|
java.lang.String |
findIntersectionTime(java.lang.Long timeBaseLine,
java.util.ArrayList<java.lang.String> time2compare,
boolean isFirstStep,
boolean isLowerThenTreshold)
finds intersecion time
|
java.lang.String |
getFilename()
returns the file name
|
int |
getFileSize()
returns if there are some files
|
java.lang.String |
getLastPathComponent(java.lang.String filePath)
return the file name of the given path
|
double |
getMaxXFromTimeSeries(java.util.List<java.lang.Double> sampleList)
extract the maximul value of X
|
double |
getMaxYFromTimeSeries(java.util.List<java.lang.Double> sampleList)
return the max Y value from a list of measurements
|
double |
getMinXFromTimeSeries(java.util.List<java.lang.Double> sampleList)
extarct the maximum value of Y
|
double |
getMinYFromTimeSeries(java.util.List<java.lang.Double> sampleList)
get the min value of Y
|
java.util.List<java.lang.Double> |
getNewCommonTimeSeries(FileManager aremoteFileManager,
int upto)
extract the samples that have been taken at the same time from the two provided files
|
java.nio.DoubleBuffer |
getSound()
extract the sound
|
double |
getStartTime()
return when the sound started being recorded
|
FileManager |
getWeightedSound(double slope,
double intercept,
java.lang.String provided_file_name,
android.content.Context ctx)
Weight the sound with provided parameters (slope and intercept) and store it
|
boolean |
isEmpty()
return false
|
void |
plot_both_old_calibration(com.androidplot.xy.XYPlot plot,
android.content.Context ctx,
FileManager aremoteFileManager)
plot the two time series (local and remote)
|
void |
plot_calibration(com.androidplot.xy.XYPlot plot,
android.content.Context ctx,
FileManager aremoteFileManager,
int upto)
plot the measurements and the regression line
|
void |
plot_old_calibration(com.androidplot.xy.XYPlot plot,
android.content.Context ctx,
FileManager aremoteFileManager,
int upto)
plot the time series (local and remote)
|
void |
plot_several_calibration(com.androidplot.xy.XYPlot plot,
android.content.Context ctx,
java.util.List<FileManager> remoteFileManager)
plot the two time series (local and remote)
|
java.lang.StringBuilder |
printCommonTimeSeries(FileManager aremoteFileManager) |
double |
rad2deg(double rad)
radian to degree
|
boolean |
re_write_delay_calibration_buffer(java.nio.DoubleBuffer buffer,
double startTime,
double slot,
java.nio.DoubleBuffer remotebuffer,
long delay)
write in the file the raw sound provided by buffer starting at synchronised time starttime and with a time slot
between two sound record given by slot
|
java.lang.StringBuilder |
read_txt()
return the content of the file
|
void |
removeFileListener(FileListener toremove)
remove a file listener
|
java.lang.StringBuilder |
scan()
scan a file
|
java.util.List<java.lang.Double> |
scan2list()
extract from the file the content and provide the related list
|
java.util.List<java.lang.Double> |
scanLine(java.lang.String line)
scan a line
|
java.util.List<java.lang.Double> |
scanLineGps(java.lang.String line)
scan the parameters
|
java.util.List<java.lang.Double> |
scanLineOrtGps(java.lang.String line)
return the scanned parameters
|
void |
setFilename(java.lang.String provided_name)
set the file name
|
int |
write_calibration_buffer_gps_orientation(java.nio.DoubleBuffer buffer,
double startTime,
double slot,
ContextData ctx)
write in the file the raw sound provided by buffer starting at synchronised time starttime and with a time slot
* between two sound record given by slot
|
int |
write_calibration_buffer_gps(java.nio.DoubleBuffer buffer,
double startTime,
double slot,
ContextData ctx)
write in the file the raw sound provided by buffer starting at synchronised time starttime and with a time slot
* between two sound record given by slot
|
boolean |
write_calibration_buffer_recordActiv(java.nio.DoubleBuffer buffer,
double startTime,
double slot,
ContextData ctx)
write in the file the raw sound provided by buffer starting at synchronised time starttime and with a time slot
between two sound record given by slot
|
boolean |
write_calibration_buffer(java.nio.DoubleBuffer buffer,
double startTime,
double slot)
write in the file the raw sound provided by buffer starting at synchronised time starttime and with a time slot
* between two sound record given by slot
|
void |
write_calibration_bufferThread_gps_orientation(java.nio.DoubleBuffer buffer,
double startTime,
double slot,
ContextData ctx)
write in a file the content of the sound (given buffer), adding time stamps starting from the (synchronised) time
that determines when the recording started
and given the time slot between two noise recorded
|
void |
write_calibration_bufferThread(java.nio.DoubleBuffer buffer,
double startTime,
double slot)
write in a file the content of the sound (given buffer), adding time stamps starting from the (synchronised) time
that determines when the recording started
and given the time slot between two noise recorded
|
boolean |
write_txt(java.lang.String aTextToWrite)
add the sting at the end of the file
|
boolean |
zipFileAtPath(java.lang.String name2zipFile,
java.lang.String lastTest)
zip a folder
|
public java.lang.String fileName
public static final int SAVING_SOUND_HAS_COMPLETED
public java.lang.String axisX
public java.lang.String axisY
public java.lang.String axisZ
public java.lang.String latitude
public java.lang.String longitude
public boolean ortLowerTreshold
public boolean pstLowerTreshold
public double minGPSboundarie
public FileManager(java.lang.String provided_file_name, java.lang.Boolean isToappend, android.content.Context ctx)
provided_file_name
- file nameisToappend
- determine if the information should be placed at the end of the file or should replacectx
- contextpublic FileManager(java.lang.String provided_file_name, java.lang.Boolean isToappend, android.content.Context ctx, java.lang.String where)
provided_file_name
- file nameisToappend
- determine if the information should be placed at the end of the file or should replacectx
- contextwhere
- public java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extractCommontimeSeries(java.util.List<FileManager> remoteFilelist, ContextData ctx)
remoteFilelist
- list of files from which the samples are extractedctx
- contextpublic boolean zipFileAtPath(java.lang.String name2zipFile, java.lang.String lastTest)
name2zipFile
- path of the folder that need to be zippedlastTest
- id the define the test id and will be used to generate the name of the zip filepublic java.lang.String getLastPathComponent(java.lang.String filePath)
filePath
- file path
Example: getLastPathComponent("downloads/example/fileToZip");
Result: "fileToZip"public void deleteFilesAftZip(java.io.File[] files)
files
- public int getFileSize()
public java.lang.String getFilename()
public void setFilename(java.lang.String provided_name)
provided_name
- file namepublic void addFileListener(FileListener toadd)
toadd
- file listenerpublic boolean isEmpty()
public void removeFileListener(FileListener toremove)
toremove
- file listener to removepublic void write_calibration_bufferThread(java.nio.DoubleBuffer buffer, double startTime, double slot) throws java.lang.Exception
buffer
- bufferstartTime
- time wen the recording startedslot
- delay between two measurementsjava.lang.Exception
- we could not write the sound in the filepublic void write_calibration_bufferThread_gps_orientation(java.nio.DoubleBuffer buffer, double startTime, double slot, ContextData ctx)
buffer
- bufferstartTime
- time wen the recording startedslot
- delay between two measurementsctx
- contextpublic int write_calibration_buffer_gps_orientation(java.nio.DoubleBuffer buffer, double startTime, double slot, ContextData ctx)
buffer
- bufferstartTime
- time wen the recording startedslot
- delay between two measurementsctx
- contextpublic int write_calibration_buffer_gps(java.nio.DoubleBuffer buffer, double startTime, double slot, ContextData ctx)
buffer
- bufferstartTime
- time wen the recording startedslot
- delay between two measurementsctx
- contextpublic java.lang.String findIntersectionTime(java.lang.Long timeBaseLine, java.util.ArrayList<java.lang.String> time2compare, boolean isFirstStep, boolean isLowerThenTreshold)
timeBaseLine
- time2compare
- isFirstStep
- isLowerThenTreshold
- public boolean re_write_delay_calibration_buffer(java.nio.DoubleBuffer buffer, double startTime, double slot, java.nio.DoubleBuffer remotebuffer, long delay)
buffer
- sound measurement (i.e. buffer)startTime
- time when we started recordingslot
- delay between two measurementsremotebuffer
- other sound we need to synchronise withdelay
- biaspublic boolean write_calibration_buffer(java.nio.DoubleBuffer buffer, double startTime, double slot)
buffer
- sound measurementsstartTime
- time when we start recordingslot
- detaly between two measruementspublic boolean write_calibration_buffer_recordActiv(java.nio.DoubleBuffer buffer, double startTime, double slot, ContextData ctx)
buffer
- sound measurementsstartTime
- time at which we begin recordingslot
- delay between two measurementsctx
- contextpublic boolean write_txt(java.lang.String aTextToWrite)
aTextToWrite
- string to add at the end of the filepublic java.lang.StringBuilder read_txt()
public java.lang.StringBuilder scan()
public java.nio.DoubleBuffer getSound()
public FileManager getWeightedSound(double slope, double intercept, java.lang.String provided_file_name, android.content.Context ctx)
slope
- slope that serve as weightintercept
- intercept that serve to weightprovided_file_name
- name of the file containing the sound that will be weightedctx
- contextpublic double getStartTime()
public java.util.List<java.lang.Double> scan2list()
public int close()
public void plot_old_calibration(com.androidplot.xy.XYPlot plot, android.content.Context ctx, FileManager aremoteFileManager, int upto)
plot
- plotctx
- contextaremoteFileManager
- file when the time series are storedupto
- up to how many elements should be plotedpublic void plot_calibration(com.androidplot.xy.XYPlot plot, android.content.Context ctx, FileManager aremoteFileManager, int upto)
plot
- plotctx
- contextaremoteFileManager
- file name where measurements are providedupto
- up to how many elements should be plotedpublic void plot_several_calibration(com.androidplot.xy.XYPlot plot, android.content.Context ctx, java.util.List<FileManager> remoteFileManager)
plot
- plotctx
- contextremoteFileManager
- file name where information is storedpublic void plot_both_old_calibration(com.androidplot.xy.XYPlot plot, android.content.Context ctx, FileManager aremoteFileManager)
plot
- plotctx
- contextaremoteFileManager
- file name where information is storedpublic java.lang.StringBuilder printCommonTimeSeries(FileManager aremoteFileManager)
public java.util.List<java.lang.Double> scanLine(java.lang.String line)
line
- to scanpublic java.util.List<java.lang.Double> scanLineOrtGps(java.lang.String line)
line
- line to scanpublic java.util.List<java.lang.Double> scanLineGps(java.lang.String line)
line
- line 2 scanpublic java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extract(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix)
_matrix
- mastric to scanpublic java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extractGPSorientation(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix)
_matrix
- mastric to scanpublic java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extractFilterMatrix(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix, ContextData ctx)
_matrix
- mastric to scanctx
- contextpublic java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extractFilterGPSorientation(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> _matrix, ContextData ctx)
_matrix
- matric to scanctx
- contextpublic java.lang.Double distZones(double lat1, double lon1, double lat2, double lon2)
lat1
- latitude srclon1
- longitude srclat2
- latitude destlon2
- longiture destpublic double deg2rad(double deg)
deg
- degreepublic double rad2deg(double rad)
rad
- radianpublic java.util.ArrayList<java.util.ArrayList<java.lang.Double>> extractCommontimeSeries(java.util.List<FileManager> remoteFilelist)
remoteFilelist
- file listpublic java.util.List<java.lang.Double> getNewCommonTimeSeries(FileManager aremoteFileManager, int upto)
aremoteFileManager
- file where the sound is includedupto
- up to how many samples should be extractedpublic double getMaxXFromTimeSeries(java.util.List<java.lang.Double> sampleList)
sampleList
- list of samplespublic double getMinXFromTimeSeries(java.util.List<java.lang.Double> sampleList)
sampleList
- sample listpublic double getMaxYFromTimeSeries(java.util.List<java.lang.Double> sampleList)
sampleList
- measurementspublic double getMinYFromTimeSeries(java.util.List<java.lang.Double> sampleList)
sampleList
- measurements