I can't write to the RACP record to start the appropriate procedure on the glucose device and I don't know what's wrong:
Bluetooth powered on.
Device Contour7802H6798544 found, try to connect...
Connected to Contour7802H6798544
*******************************************************
Service: <CBService: 0x14566740, isPrimary = YES, UUID = Glucose>
<CBCharacteristic: 0x1466fdc0, UUID = 2A18, properties = 0x10, value = (null), notifying = NO>
... has notify
<CBCharacteristic: 0x1465bb00, UUID = 2A52, properties = 0x28, value = (null), notifying = NO>
... has write
*******************************************************
Characteristic's value subscribed
Subscribed. Notification has begun for: 2A18
Optional(Error Domain=CBATTErrorDomain Code=129 "Unknown ATT error." UserInfo={NSLocalizedDescription=Unknown ATT error.})
129 is 0x81 in HEX, the specification of the error message in the title can be found in the official Bluetooth docs of the Glucose Service: https://github.com/www378660084/BluetoothProfile/blob/master/GLS_SPEC_V10.pdf
I write op-code and operand to 0x2a52 as follows:
let data = Data([0x04,0x01]);
peripheral.writeValue(data , for: racp?, type: .withResponse);
And this is the specification of the characteristic:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML Studio Designer Edition 9.1.10.3537 (http://www.liquid-technologies.com) -->
<!--Copyright 2011 Bluetooth SIG, Inc. All rights reserved.-->
<Characteristic xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Record Access Control Point"
type="org.bluetooth.characteristic.record_access_control_point"
uuid="2A52" last-modified="2011-12-6" approved="Yes">
<InformativeText>
<Summary>This control point is used with a service to provide
basic management functionality for the Glucose Sensor patient
record database. This enables functions including counting
records, transmitting records and clearing records based on
filter criterion. The filter criterion in the Operand field is
defined by the service that references this characteristic as
is the format of a record (which may be comprised of one or
more characteristics) and the sequence of transferred
records.</Summary>
</InformativeText>
<Value>
<Field name="Op Code">
<Requirement>Mandatory</Requirement>
<Format>uint8</Format>
<Enumerations>
<Enumeration key="0"
value="Reserved for future use (Operator:N/A)" />
<Enumeration key="1"
value="Report stored records (Operator: Value from Operator Table)" />
<Enumeration key="2"
value="Delete stored records (Operator: Value from Operator Table)" />
<Enumeration key="3"
value="Abort operation (Operator: Null 'value of 0x00 from Operator Table')" />
<Enumeration key="4"
value="Report number of stored records (Operator: Value from Operator Table)" />
<Enumeration key="5"
value="Number of stored records response (Operator: Null 'value of 0x00 from Operator Table')" />
<Enumeration key="6"
value="Response Code (Operator: Null 'value of 0x00 from Operator Table')" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
</Field>
<Field name="Operator">
<Requirement>Mandatory</Requirement>
<Format>uint8</Format>
<Enumerations>
<Enumeration key="0" value="Null" />
<Enumeration key="1" value="All records" />
<Enumeration key="2" value="Less than or equal to" />
<Enumeration key="3" value="Greater than or equal to" />
<Enumeration key="4" value="Within range of (inclusive)" />
<Enumeration key="5"
value="First record(i.e. oldest record)" />
<Enumeration key="6"
value="Last record (i.e. most recent record)" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
</Field>
<Field name="Operand">
<InformativeText>The operands correspond to the Op Code
values (Keys 0 to 255) defined in the Op Code Field
above</InformativeText>
<Requirement>Mandatory</Requirement>
<Format>variable</Format>
<Enumerations>
<InformativeText>Op Code / Operand Value
Correspondence</InformativeText>
<Enumeration key="0" value="N/A" />
<Enumeration key="1"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="2"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="3" value="Not included" />
<Enumeration key="4"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="5"
value="Number of Records (Field size defined per service)" />
<Enumeration key="6"
value="Request Op Code, Response Code Value" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
<AdditionalValues>
<InformativeText>Response Code Values</InformativeText>
<Enumeration key="0" value="Reserved For Future Use"
description="N/A" />
<Enumeration key="1" value="Success"
description="Normal response for successful operation" />
<Enumeration key="2" value="Op Code not supported"
description="Normal response if unsupported Op Code is received" />
<Enumeration key="3" value="Invalid Operator"
description="Normal response if Operator received does not meet the requirements of the service (e.g. Null was expected)" />
<Enumeration key="4" value="Operator not supported"
description="Normal response if unsupported Operator is received" />
<Enumeration key="5" value="Invalid Operand"
description="Normal response if Operand received does not meet the requirements of the service" />
<Enumeration key="6" value="No records found"
description="Normal response if request to report stored records or request to delete stored records resulted in no records meeting criteria." />
<Enumeration key="7" value="Abort unsuccessful"
description="Normal response if request for Abort cannot be completed" />
<Enumeration key="8" value="Procedure not completed"
description="Normal response if unable to complete a procedure for any reason" />
<Enumeration key="9" value="Operand not supported"
description="Normal response if unsupported Operand is received" />
<ReservedForFutureUse start="10" end="255" />
</AdditionalValues>
</Field>
</Value>
<Note>The fields in the above table are in the order of LSO to
MSO. Where LSO = Least Significant Octet and MSO = Most
Significant Octet.</Note>
</Characteristic>
0x04 0x01 means I want to get the total number of stores records.
But I get always the error message mentioned above.
I used to have the same issue, but after checking the spec I found this:
Ensure that the client configures RACAP Charac for indication
by writing "0x0200" on the Client configuration descriptor related to RACAP
From section 3.4 of the specification.
Related
I am trying to get 3 options condition, but I am going crazy:
In a specific field may appear a number, a text or be an empty field
Conditions:
if any text = warning message pops up: "This in an error "
if any number= [pagedown] action
if empty = warning message pops up: "pls change code "
May someone help me?
Thanks!
<HAScript name="new condition" description="" timeout="60000" pausetime="300" promptall="te" blockinput="false" author="gennaro" creationdate="Nov 19, 2022 8:07:14 PM" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true">
<vars>
<create name="$text$" type="string" value="" />
<create name="$num$" type="integer" value="0" />
<create name="$emptyfield$" type="field" />
</vars>
<screen name="Screen1" entryscreen="true" exitscreen="true" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$text$" />
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$num$" />
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$emptyfield$" />
<if condition="$string$" >
<input value="" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<message title="$string$" value="" />
</if>
<if condition="$num$" >
<input value="'[pagedn]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</if>
<if condition="$emptyfield$" >
<message title="$emptyfield$" value="" />
</if>
</actions>
<nextscreens timeout="0" >
</nextscreens>
</screen>
</HAScript>
I was expecting
Conditions:
if any text = warning message pops up: "This in an error "
if any mumber= [pagedoen] action
if empty = warning message pops up: "pls change code "
A little snippet of a database schema I'm trying to define in my "schema.xml" file:
<table name="hotelroom" phpName="hotelroom">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="room_number" type="varchar" size="10" required="true" />
<column name="price" type="numeric" defaultValue="1000" required="true" />
<unique>
<unique-column name="room_number" />
</unique>
</table>
In PostgreSQL for that "price" column I would've written CHECK (price > 0::numeric),but I can't seem to find any way to achieve this here.I've checked the documentation (http://propelorm.org/documentation/reference/schema.html), but couldn't find anything on this.
Thank you for the time.
You're using v1, but from the doc link above, looks like you're using v2,
I think you're looking for the GreaterThan which is only available from v2 onwards.
<behavior name="validate">
<parameter name="rule1" value="{column: price, validator: GreaterThan, options: {value: 0, message=Price is not valid}}" />
</behavior>
My model contain the following enumeration and entity:
<cf:enumeration name="Language" usePersistenceDefaultValue="false">
<cf:enumerationValue name="EN" value="1" default="true" />
<cf:enumerationValue name="NL" value="2" />
<cf:enumerationValue name="DE" value="3" />
</cf:enumeration>
<cf:entity name="Person" >
<cf:property name="Id" key="true" />
<cf:property name="Languages" typeName="CodeFluent.Runtime.Utilities.PersistentList<Language>">
<cf:message class="_doc">The languages that the person speaks</cf:message>
</cf:property>
<cf:method name="LoadPersonThatSpeaksOneOrMoreLanguages" checkLevel="None" memberAttributes="Public" >
<cf:body language="tsql" text="load(Language[] languages) from Person where Languages in (#languages)" />
</cf:method>
</cf:entity>
The method LoadPersonThatSpeaksOneOrMoreLanguages should return all persons that speak one or more of the provided languages.
The generated stored procedure for this method seems not to be correct:
ALTER PROCEDURE [dbo].[Person_LoadPersonThatSpeaksOneOrMoreLanguages]
(
#languages [dbo].[cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0] READONLY,
#_orderBy0 [nvarchar] (64) = NULL,
#_orderByDirection0 [bit] = 0
)
AS
SET NOCOUNT ON
DECLARE #_c_languages int; SELECT #_c_languages= COUNT(*) FROM #languages
SELECT DISTINCT [Person].[Person_Id], ...
FROM [Person]
WHERE [Person].[Person_Languages] IN (((SELECT * FROM #languages)))
Question 1:
How can I achieve the desired result?
Should I create a Language entity and specify an 1:n association between Person and Language? I prefer not to have a Language entity.
Or can I specify that the Languages property must be converted to the same type as the table-valued-parameter (cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0)?
Question 2:
The produced PersonCollection class contains the method LoadPersonThatSpeaksOneOrMoreLanguages. The parameter of this method is of type Language[]. Instead of an array I want an IEnumerable<Language>. How can I specify this in my XML model?
Question 1
The PersistentList is designed to store a collection of simple values (int, string, enum, ...), but not to query them directly in SQL. Indeed the PersistentList is translated to a NVARCHAR column in the database and this column contains values like EN|NL (pipe separated values). The database engine does not know how to extract single values from the string. Maybe you can use the cf_SplitString function to create a table from the column value and do what you want with it, but it does not seem to be the simplest solution...
Depending of your need you can use a multi-valued enumeration:
<cf:enumeration name="Language" flags="true">
<cf:enumerationValue name="Unspecified" /> <!-- value=0 -->
<cf:enumerationValue name="EN" /> <!-- value=1 -->
<cf:enumerationValue name="NL" /> <!-- value=2 -->
<cf:enumerationValue name="FR" /> <!-- value=4 -->
</cf:enumeration>
You can use them with CFQL:
-- Load Persons that speak the specified language
LOAD(Languages) WHERE (Languages & #Languages) = #Languages
-- Load Persons that speak at least one of the specified language
LOAD(Languages) WHERE (Languages & #Languages) <> 0
Of course the latest possibilities is to create a Language entity and use Table Valued Parameters.
http://blog.codefluententities.com/2014/07/16/persistent-list/
http://www.softfluent.com/documentation/Enumerations_Overview.html
Question 2
From the official blog of CodeFluent Entities:
Take what I say with a grain of salt as you are dealing with a topic I have looked into but never implemented. With that said another approach would be to use a multi-valued enumeration (flag)
http://blog.codefluententities.com/2013/05/29/using-flags-enumeration-with-aspnet-mvc-and-codefluent-entities
Using this approach you would create a relationship between the entity and the enumeration instead of making the Languages property a persistent list.
The following mostly works. When using the Modeler to create instances I was not able to select certain combinations of languages. Don't know if this was due to my inexperience in working with and setting up flag enumeration or if there is a flaw in the modeler. But I did manage to create the method and that part appears to be working.
<cf:enumeration name="Language" multivalue="true" usePersistenceDefaultValue="false" namespace="Demo1" categoryPath="/Demo1">
<cf:enumerationValue name="Unspecified" default="true" />
<cf:enumerationValue name="EN" />
<cf:enumerationValue name="NL" />
<cf:enumerationValue name="DE" />
</cf:enumeration>
<cf:entity name="Person" namespace="Demo1">
<cf:property name="Id" key="true" />
<cf:property name="Languages" usePersistenceDefaultValue="false" typeName="{0}.Language" />
<cf:property name="FirstName" />
<cf:property name="LastName" />
<cf:instance>
<cf:instanceValue name="Id">d13447c6-a709-4c87-891d-e83674821915</cf:instanceValue>
<cf:instanceValue name="FirstName">Jon</cf:instanceValue>
<cf:instanceValue name="LastName">Smith</cf:instanceValue>
</cf:instance>
<cf:instance>
<cf:instanceValue name="Id">77e3730c-2cc3-457d-8bc0-d9a5e224b96a</cf:instanceValue>
<cf:instanceValue name="FirstName">Sam</cf:instanceValue>
<cf:instanceValue name="Languages">DE, SP</cf:instanceValue>
<cf:instanceValue name="LastName">Newman</cf:instanceValue>
</cf:instance>
<cf:method name="LoadPersonThatSpeaksOneOrMoreLanguages" body="LOAD() WHERE Languages > 0" />
As I said take what I'm saying with a grain of salt. I ended up using an entity instead of an enumeration but only because that was what I was more familar with and had a deadline.
I am using mule to connect to a Postgres database server.
I can't use the datamapper since I am using the community edition.
The object to xml transformer is not giving a good formatted result.
Any ideas of how I can transform the jdbc response into a good format for parsing.
Here is my configuration file.
This is the datasource with the connector.
<jdbc:postgresql-data-source name="PostgreSQL_Data_Source"
user="USERNAME" password="PASSWORD"
url="jdbc:postgresql://*******:***/*****"
transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source" />
<jdbc:connector name="organizations" dataSource-ref="PostgreSQL_Data_Source"
validateConnections="true" queryTimeout="-1" pollingFrequency="0"
doc:name="JDBC">
<jdbc:query key="getOrganizations" value="SELECT * FROM organization" />
<jdbc:query key="getOrganizationApplications"
value="SELECT * FROM organization o,application a,organization_apps oa WHERE o.id=oa.org_id AND a.id=oa.app_id AND o.id=#[flowVars['org_id']]" />
<jdbc:query key="insertOrganization"
value="INSERT INTO organization(name, phone, email, address, website) VALUES (?, ?, ?, ?, ?)" />
<jdbc:query key="getOrganizationUsers"
value="SELECT * FROM "public".user WHERE org_id=#[flowVars['org_id']]" />
</jdbc:connector>
and this is the flow:
<flow name="logixy-platform-organizations-workflow" doc:name="logixy-platform-organizations-workflow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8082" doc:name="HTTP" path="organization" />
<set-variable variableName="choice"
value="#[message.inboundProperties['choice']]" doc:name="Set Choice" />
<choice doc:name="Choice">
<when expression="#[flowVars['choice'] == '0']">
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryTimeout="-1" doc:name="getAllOrganizations" connector-ref="organizations"
queryKey="getOrganizations" />
</when>
<when expression="#[flowVars['choice'] == '2']">
<set-variable variableName="org_id"
value="#[(int)(message.inboundProperties['org_id'])]" doc:name="Set Organization ID" />
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryKey="getOrganizationUsers" queryTimeout="-1" connector-ref="organizations"
doc:name="getOrganizationUsers" />
</when>
<when expression="#[flowVars['choice'] == '1']">
<set-variable variableName="#['org_id']"
value="#[(int)(message.inboundProperties['org_id'])]" doc:name="Set Organization ID" />
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryKey="getOrganizationApplications" queryTimeout="-1"
connector-ref="organizations" doc:name="getOrganizationApplications" />
</when>
</choice>
<mulexml:object-to-xml-transformer
doc:name="Object to XML" />
</flow>
You should really define "a good format for parsing", but I guess you don't like the "entry", "string", etc field names.
You have plenty of options to format the XML, for example:
use XSLT to transform the generated XML to your preferred format
define a class in Java or Groovy that corresponds to your return data and then either
use object-to-json and then json-to-object with your class as return class
assign the return data to objects of your class in Java or Groovy
Once you have your data as custom objects, object-to-xml-transformer will print produce a much cleaner output.
My question relates to the "table joining" function in the ADO.NET Entity Framework.
Imagine a database that contains a table "Product" and another table "ProductPrice". The price table stores a history of all price changes for a product, with a start and end date, where the line containing the current price is indicated by a NULL value in the end date column. This database structure could be useful for statistical purposes, for example the average daily sales volume could be mapped to each change in the product price. However, for the online ordering website, only the current price is required.
Here's the structure of the two tables:
Product
ProductID (PK, int, NOT NULL, auto increment)
Name (varchar 50, NOT NULL)
ProductPrice
ProductPriceID (PK, int, NOT NULL, auto increment)
ProductID (INT, NOT NULL)
StartDate (DATETIME, NOT NULL)
EndDate (DATETIME)
Price (MONEY, NOT NULL)
Here's an example of an SQL statement to retrieve the product plus the current price:
SELECT Product.ProductID, Product.Name, ProductPrice.Price AS CurrentPrice
FROM Product
LEFT JOIN ProductPrice
ON Product.ProductID = ProductPrice.ProductID
AND ProductPrice.EndDate IS NULL
I'd like to use the Entity Framework to join the entities Product and ProductPrice together, so that I can access the current price directly from the Product entity, as in the following example:
var product = (from p in context.Product where p.ProductID == 2 select p).FirstOrDefault();
Console.WriteLine(product.Name);
Console.WriteLine(product.CurrentPrice);
Unfortunately, I'm getting stuck with errors that I can't resolve.
Here are the entities from the storage model:
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductID" />
</Key>
<Property Name="ProductID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="varchar" Nullable="false" MaxLength="50" />
</EntityType>
<EntityType Name="ProductPrice">
<Key>
<PropertyRef Name="ProductPriceID" />
</Key>
<Property Name="ProductPriceID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="ProductID" Type="int" Nullable="false" />
<Property Name="Price" Type="money" Nullable="false" />
<Property Name="StartDate" Type="datetime" Nullable="false" />
<Property Name="EndDate" Type="datetime" />
</EntityType>
<Association Name="FK_ProductPrice_Product">
<End Role="Product" Type="TestingModel.Store.Product" Multiplicity="1" />
<End Role="ProductPrice" Type="TestingModel.Store.ProductPrice" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Product">
<PropertyRef Name="ProductID" />
</Principal>
<Dependent Role="ProductPrice">
<PropertyRef Name="ProductID" />
</Dependent>
</ReferentialConstraint>
</Association>
And from the conceptual model:
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductID" />
</Key>
<Property Name="ProductID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="false" FixedLength="false" />
<Property Name="SKU" Type="String" Nullable="false" MaxLength="50" Unicode="false" FixedLength="false" />
<Property Type="Decimal" Name="CurrentPrice" Nullable="false" Precision="19" Scale="4" />
</EntityType>
And finally the mapping between the two:
<EntitySetMapping Name="Product">
<EntityTypeMapping TypeName="TestingModel.Product">
<MappingFragment StoreEntitySet="Product">
<ScalarProperty Name="ProductID" ColumnName="ProductID" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="SKU" ColumnName="SKU" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(TestingModel.Product)">
<MappingFragment StoreEntitySet="ProductPrice">
<ScalarProperty Name="CurrentPrice" ColumnName="Price" />
<Condition ColumnName="EndDate" IsNull="true" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
And here are the error messages that I'm currently struggling with:
Error 1 Error 3024: Problem in mapping fragments starting at line 76:Must specify mapping for all key properties (Product.ProductID) of the EntitySet Product.
Error 2 Error 3025: Problem in mapping fragments starting at line 76:Must specify mapping for all key properties (ProductPrice.ProductPriceID) of table ProductPrice.
I'm not sure if this is even possible with the Entity Framework, maybe I should just do the join manually myself in LINQ.
Any suggestions would be greatly appreciated.
You do not meet the conditions for entity splitting:
You should only map an entity type to multiple tables if the following conditions are true:
The tables to which you are mapping share a common key.
The entity type that is being mapped has entries in each underlying table. In other words, the entity type represents data that has a one-to-one correspondence between the two tables; the entity type represents an inner join of the two tables.
You are smarter than EF. You know that the condition EndDate == null yields one record. EF has no clue to know that and thus never knows that it can create one object from the two tables. In terms of the exception message: PriceId and EndDate == null should somehow deliver all key properties of your ProductPrice records, which is impossible, obviously.
Alternatives:
A. You can create a one-to-many association between the two and query:
products.Where(p => p.ProductId == 2)
.Select(p => new
{
Product = p,
CurrentPrice = p.ProductPrices.Where(pp => pp.EndDate == null)
.FirstOrDefault()
})
Not as convenient as you'd like, but maybe not too bad when wrapped in a repository.
B. Create a database view and use separate paths for viewing and updating (which is not an uncommon thing to do).
You need to do a foreign key between the two tables (i.e. on column ProductID)
Then to retrieve all the products together with their prices you need to do the following:
var x = from p in context.Product where p.ProductID == 2 && p.ProductPrice.EndDate == null select new { p.ProductID, p.Name, p.ProductPrice.Price }.FirstOrDefault();