i'm able to connect to A&D weight scale(UC-351PBT-Ci) and fetch(from bluetooth) raw data from it, but not able to parse it to get the measured weight from it. Please find the data i get from weight scale, and help me in parsing it to get the measured vale.
e2000032800000000001002a50790026800000008000800000000000000000800000000800091ffffe80b50140000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
This is second data
e7000026002410000101001e0000ffffffff0d1e0014f00000000001000c0065000100060a4c00020001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
This is the third data
e70000c000be0024020300b80000000a00b20a5a000800010004100f00010928001c000c412644204d65646963616c00000c55432d3335315042542d43690984000a000800091ffffe80b5010a4400024000092d00280002002400010000000a3531343033303031303200050000000e332e362e38207461672d3939364d0987000820160107180528000a4b00160002001202010008010500010002400f0202000200000a450010c0101f00ffffffff0064000000000000095500024000099c000200640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
This is the fourth one
e60000020002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
you need to convert the data to from hex like using http://codebeautify.org/hex-string-converter
taking your "third data" the output is
çÀ¾$¸
²
Z (A&D MedicalUC-351PBT-Ci
ÿþµ
D# -($
51403001023.6.8 tag-996M (
K#
EÀÿÿÿÿd U# d
so you can see that this is probably the make and model number passed with the data.
you just have to breakdown each byte into its string representation
StringBuffer result = new StringBuffer();
for (byte b : bytes) {
result.append(String.format("%02X", b));
}
return result.toString();
there will then be documentation to workout which byte represents what bit of data so assuming there would be a measurement date and the weight and the weight units etc.
Related
CATEGORY MILES
Business 5.1
Business 4.6
Business 3.9
Personal 8.5
Business 3.7
Personal 6.2
Personal 11
This is an excerpt from the excel sheet
So you have a text file in CSV format, and you need to read it, convert it into combinations of [Category, Miles], and you want for every Category "% of miles", whatever that may be.
Category Miles
X 1
X 4
X 2
Y 3
I think that you want: "Category X has 70% of the miles, Category Y also has 30% of the miles".
To solve this, it is best to cut your problem into smaller pieces.
Given a string fileName, read the file as text
Given a string in CSV format, convert it into a sequence of class BusinessMiles
Given a sequence of BusinessMiles, convert it to "% of miles", according to the definition above.
Cutting your problem into smaller pieces has several advantages:
The function of each piece will be easier to understand
Easier to unit test.
Easier to change, for instance if you don't read from a CSV file, but from a database, or if you don't read from a CSV string, but from an XML or JSON file.
Most important: you will be able to reuse the pieces for other tasks, like: "How many of my rows are about Business?"
The reusability is demonstrated most clearly, because several of these pieces already exist and can be used freely: reading the file and converting the file to CSV.
For this, consider to use Nuget Package CSV helper. Easy to use, versatile, and thus one of the most used CSV packages.
So let's assume you have procedures to read the CSV file and to convert it to a sequence of BusinessMiles
enum Category
{
Business,
Personal,
}
class BusinessMile // TODO: invent proper name
{
public Category Category {get; set;}
public Decimal Miles {get; set;}
}
By using an enum you can be certain that after reading the CSV there won't be any incorrect Categories. It will be easy to add new Categories for a future version. If you don't know at compile time which Categories are allowed, consider to use a string for it. This has the danger that someone might have a typing error, which leads to a complete new Category, without anyone noticing "Personnel" instead of "Personal"
IEnumerable<BusinessMile> ReadBusinessMiles(string csvText)
{
// use CSVHelper to convert the csvText to the sequence
}
IEnumerable<BusinessMile> ReadBusineMilesFile(string fileName)
{
// either use CSVHelper, or read the file and call the other method
}
After this, your problem will be easy:
string fileName = ...
IEnumerable<BusinessMile> businessMiles = ReadBusinesMilesFile(fileName);
Make groups of BusinessMiles that have the same Category:
var categoryGroups = businessMiles.GroupBy(
businessMile => businessMile.Category,
// parameter resultSelector: for every Category, and all BusinessMiles
// that have this Category to make one new
(category, businessMilesInThisCategory) => new
{
Category = category,
TotalMiles = businesMilesInThisCategory
.Select(businessMile => businessMile.Miles)
.Sum(),
});
So now you've got:
Category TotalMiles
X 7
Y 3
If you really want to have percentages, you need to get the total of all Miles of all Categories (=6), and divide TotalMiles by this total
var totalMiles = categorieGroups.Select(group => group.TotalMiles).Sum();
var result = categoryGroups.Select(group => new
{
Category = group.Category,
TotalMilesPercentage = 100.0M * group.TotalMiles / totalMiles,
})
In my definition of BusinessMiles, the Miles are a decimal. Take care to convert it if your Miles are integers.
In one of my use case, I need the current address(Geolocation) of my mobile device. How to get current Geolocation in Movilizer.
Anyone knows, Please let me know
Thanks,
Krish
Using MEl, first of all you need to activate the continuous GPS capturing, using the method startGPSCapturing(). After it, you can use method getGPSCoordinates() that returns an array with this information:
{
timestamp:
{
'ac' : accuracy in meters;
'lt' : latitude;
'lg' : longitude;
's' : source;
};
};
This method returns the GPS location data from the queue as a two-dimensional array. The array includes the timestamp, the accuracy in meters, the latitude, the longitude, and the source of the GPS data.
My SwiftUI segmented control picker uses plain Int ".tag(1)" etc values for its selection.
CoreData only has Int16, Int32 & Int64 options to choose from, and with any of those options it seems my picker selection and CoreData refuse to talk to each other.
How is this (??simple??) task achieved please?
I've tried every numeric based option within CoreData including Int16-64, doubles and floats, all of them break my code or simply just don't work.
Picker(selection: $addDogVM.gender, label: Text("Gender?")) {
Text("Boy ♂").tag(1)
Text("?").tag(2)
Text("Girl ♀").tag(3)
}
I expected any of the 3 CoreData Int options to work out of the box, and to be compatible with the (standard) Int used by the picker.
Each element of a segmented control is represented by an index of type Int, and this index therefore commences at 0.
So using your example of a segmented control with three segments (for example: Boy ♂, ?, Girl ♀), each segment is represented by three indexes 0, 1 & 2.
If the user selects the segmented control that represents Girl ♀, then...
segmentedControl.selectedSegmentIndex = 2
When storing a value using Core Data framework, that is to be represented as a segmented control index in the UI, I therefore always commence with 0.
Everything you read from this point onwards is programmer preference - that is and to be clear - there are a number of ways to achieve the same outcome and you should choose one that best suits you and your coding style. Note also that this can be confusing for a newcomer, so I would encourage patience. My only advice, keep things as simple as possible until you've tested and debugged and tested enough to understand the differences.
So to continue:
The Apple Documentation states that...
...on 64-bit platforms, Int is the same size as Int64.
So in the Core Data model editor (.xcdatamodeld file), I choose to apply an Integer 64 attribute type for any value that will be used as an Int in my code.
Also, somewhere, some time ago, I read that if there is no reason to use Integer 16 or Integer 32, then default to the use of Integer 64 in object model graph. (I assume Integer 16 or Integer 32 are kept for backward compatibility.) If I find that reference I'll link it here.
I could write about the use of scalar attribute types here and manually writing your managed object subclass/es by selecting in the attribute inspector Class Codegen = Manual/None, but honestly I have decided such added detail will only complicate matters.
So your "automatically generated by Core Data" managed object subclass/es (NSManagedObject) will use the optional NSNumber? wrapper...
You will therefore need to convert your persisted/saved data in your code.
I do this in two places... when I access the data and when I persist the data.
(Noting I assume your entity is of type Dog and an instance exists of dog i.e. let dog = Dog())
// access
tempGender = dog.gender as? Int
// save
dog.gender = tempGender as NSNumber?
In between, I use a "temp" var property of type Int to work with the segmented control.
// temporary property to use with segmented control
private var tempGender: Int?
UPDATE
I do the last part a little differently now...
Rather than convert the data in code, I made a simple extension to my managed object subclass to execute the conversion. So rather than accessing the Core Data attribute directly and manipulating the data in code, now I instead use this convenience var.
extension Dog {
var genderAsInt: Int {
get {
guard let gender = self.gender else { return 0 }
return Int(truncating: gender)
}
set {
self.gender = NSNumber(value: newValue)
}
}
}
Your picker code...
Picker(selection: $addDogVM.genderAsInt, label: Text("Gender?")) {
Text("Boy ♂").tag(0)
Text("?").tag(1)
Text("Girl ♀").tag(2)
}
Any questions, ask in the comments.
I have multiple instances of vtkImageData representing a window of one large dataset. The instances are adjacent and non-overlapping.
I would like to slice through all the imageData with a single vtkPlaneWidget, so I have to somehow combine the imageData into a single input connection. I also want to be able to efficiently add or remove any instance of vtkImageData from the connection.
Right now I have the vtkImageData in a vtkMultiBlockDataSet. I thought I could filter the data using a filter with the executive vtkCompositeDataPipeline as in the Tcl snippet below.
# propogate the multiblock
MultiBlockDataSet mb
mb SetNumberOfBlocks [llength $image_data_list]
for {set i 0} {$i < [llength $image_data_list]} {incr i} {
mb SetBlock $i [lindex $image_data_list $i]}
}
vtkSimpleToSimpleImageFilter fltr
vtkCompositeDataPipeline cdp
fltr SetExecutive cdp
fltr SetInput cdp
vtkImagePlaneWidget plane
plane SetInputConnection [fltr GetOutputPort]
However, the plane doesn't seem like the input connection, and moreover I'm not terribly familiar with Vtk, so I'm wondering if this is the most suitable way to do this. Any suggestions?
By not knowing your code and how you read in your data ... one possible way would be to initialize a new vtkImageData object and add your slice data.
(quick example assuming three vtkImageData objects mySlice1, mySlice2 and myTotalSlices)
myTotalSlices->GetPointData->AddArray(mySlice1->GetPointData()->GetScalars());
myTotalSlices->GetPointData->AddArray(mySlice2->GetPointData()->GetScalars());
myTotalSlices->SetExtent(0, 511, 0, 511, 0, 1);
myTotalSlices->Update();
The values in SetExtent are just a example, of course you need to adjust them to fit to your data extent.
It would be also possible to remove an array i.e. index based
myTotalSlices->GetPointData->RemoveArray(0);
I'm currently working on a poc to model time series data.
The initial datapoint structure:
- the name of a sensor: 192.168.1.1:readCount
- a timestamp
- a value
I use the sensor name as rowid, the timestamp as column id. This approach works very fine.
However I want to add tags to add additional data.
public class Datapoint {
public String metricName;
public long timestampMs;
public long value;
public Map<String, String> tags = new HashMap<String, String>();
}
Datapoint datapoint = new Datapoint();
datapoint.metricName = "IMap.readCount";
datapoint.value = 10;
datapoint.timestampMs = System.currentTimeMillis();
datapoint.tags.put("cluster", "dev");
datapoint.tags.put("member", "192.168.1.1:5701");
datapoint.tags.put("id", "map1");
datapoint.tags.put("company", "Foobar");
I want to use it to say:
- aggregate all metrics for all different machines with the same id. E.g. if machine 1 has 10 writes for mapx, and machine2 did 20 writes for mapx, I want to know that 30.
- aggregate metrics for for all maps: if machine 1 did 20 writes on mapx and 30 writes on mapy, I want to know the total of 50.
The question is how I should model this.
I know that a composite can be used for the column id. So in theory I could add each tag as a an element in that composite. But can a column be efficiently searched for when it has a variable number of elements in the composite?
I know my question is a bit foggy, but I think this reflects my understanding of Cassandra since I just started with it.
#pveentjer
"I know that a composite can be used for the column id. So in theory I could add each tag as a an element in that composite. But can a column be efficiently searched for when it has a variable number of elements in the composite?"
There are some rules and restrictions when using multiple composites, read here and here
For CQL3, there are further limitations, read here