cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to setting Alert location value?

CHASEONHO
18-Opal

How to setting Alert location value?

i want if select a Row about AlertQueryHistory

make mark on google map.

but Alert location Value was 000000:000000

how to set them?

if it was QueryPropertieHistory i can do that using addLocationValueStream or Me.Thing = item.GPS (item has real time data)

but i don't know how to set Alert location Value..

help me please~ and have a nice weekend ~~ thank you~

5 REPLIES 5
supandey
19-Tanzanite
(To:CHASEONHO)

Hi Seonho, how is your Alert setup on the Property? Is it on the property storing Location? As to highlighting the location on the map which corresponds to a Location value you are displaying on the Mashup, you can simply use the same service for both widgets for e.g.

1. Create mashup with horizontal layout with 2 columns

2. In one column use Grid and in another Google Map widget

3. Call the service which is returning Location for you

4. Drag and drop all the data returned by that same service in both Grid and Google Map widget, like so

5. View the Mashup and you shall have the Grid widget and Google map with same data to reference so clicking on the row in Grid will highlight the marker on the map, like so

i don't need propertievalue

i just want set Alert 'location value'

i can view on the google map with QueryPropertieHistory

but i want set location value in Alert history

and my Alert set on String value

when is it equal some String

it's make Alert , and this time i want make location value

when run a Alert

seonho Cha​,

I checked the location field for Alerts and found following:

The AlertHistory DataShape doesn't contain location field.

The location actually shows because the AlertHistoryStream is a Stream.

I didn't find a way it ca be set from the Thin where the alert is generating.

It would actually require an update in the Stream entry directly in AlertHistoryStream but as per my understanding it will not be supported by PTC.

As a workaround you can try following:

Create a DataTable with Fields AlertId and location.

Now subscribe to the alert and add code to create a new entry in the DataTable when the alert is generated.

We can further use this DataTable in our mashup.

really thank you for your kind.

i have another question

right is timestamp and this is QuerypropertyHistory

i don't know why Come out two

sometime come out one QuerypropertyHistory

here my subscription

-------------------------------------------

var params = {

  oldestFirst: false /* BOOLEAN */,

  maxItems: 1 /* NUMBER */, 

  endDate: undefined /* DATETIME */,

  query: undefined /* QUERY */,

  startDate: undefined /* DATETIME */

};

// latestEntry: INFOTABLE dataShape: "undefined"

var latestEntry = me.QueryPropertyHistory(params);

//logger.warn("latestEntry : " + latestEntry.getRowCount());

var truckData;

var Time = new Date();

if (latestEntry.getRowCount()==0) {

    var params = {

        cdma_no: me.cdma_number /* STRING */,

    };

    // truckData: INFOTABLE

    truckData = Things["TruckDBThing"].GetTruckAllData(params);

} else {  

    var params = {

        cdma_no: me.cdma_number /* STRING */,

        datetime: latestEntry.timestamp /* DATETIME */,

    };

    // truckData: INFOTABLE

    truckData = Things["TruckDBThing"].GetTruckData(params);

}

//logger.warn("Truck Data : " + truckData.getRowCount());

for (var i=0;i<truckData.getRowCount();i++){

    var item = truckData.getRow(i);

    var location = new Object();

    location.latitude = item.latitude/100;

    location.longitude = item.longitude/100;

    location.elevation = 0;

    location.units ="WGS84";

    //////////////////////

    me.GPS = location; 

    me.DataCheck = item.kst_datetime;//?

    me.Weight = item.weight_total;//?

    me.Speed = item.speed;

   

    if (item.weight_total > 5000 && latestEntry.Weight > 5000) {

            var params = {

  propertyName: "WeightResult" /* STRING */,

    value: "만차" /* STRING */,

  timestamp: undefined /* DATETIME */

};

me.AddStringValueStreamEntry(params);

        }

    //공차

    else if(item.weight_total <= 5000 && latestEntry.Weight <= 5000){

var params = {

  propertyName: "WeightResult" /* STRING */,

    value: "공차" /* STRING */,

  timestamp: undefined /* DATETIME */

};

me.AddStringValueStreamEntry(params);

    }

    else if(item.weight_total > 5000 && latestEntry.Weight <= 5000 && me.Speed < 5){

        me.WeightResult="상차";

        me.TimePickUp = item.kst_datetime;

    }

    else if(item.weight_total <= 5000 && latestEntry.Weight > 5000 && me.Speed < 5){

        me.WeightResult="하차";

        me.TimePickDown = item.kst_datetime;

    }

                  //Status

    if(item.speed <= 5 && me.Cheack < 1){

        me.Cheack =  1;

        if(me.Cheack == 1){

            me.Status = "정차예정";

            me.beforeTime = latestEntry.timestamp;

        }

    }

    else if(item.speed > 5){

        me.Cheack = 0

    if(item.weight_total <= 5000 && latestEntry.Weight <= 5000){       

var params = {

  propertyName: "Status" /* STRING */,

  value: "이동" /* STRING */,

  timestamp: undefined /* DATETIME */

};

me.AddStringValueStreamEntry(params);

}

        else if (item.weight_total > 5000 && latestEntry.Weight > 5000){

var params = {

  propertyName: "Status" /* STRING */,

  value: "운송" /* STRING */,

  timestamp: undefined /* DATETIME */

};

me.AddStringValueStreamEntry(params);

}

    }

    if(((((Time - me.beforeTime)/1000) > 360) && me.Cheack == 1) && (((Time - me.beforeTime)/1000) < 1800) ){

        me.Status="정차";}

}

----------------------

why often come out two ?

thanks

Hi seonho Cha​,

Could you please close this Thread by marking correct & helpful answers and open a separate Thread for the new question with more details.

I am not sure if I understand your query clearly; I suppose you are getting two entries with almost same timestamp.

This usually occurs if we try to write different properties in the same service. The service could take some milliseconds to update the first property and then after some milliseconds update the second property. So, it would show as two different entries.

To avoid this we can use UpdatePropertyValues service. The special feature about this service is that it also takes timestamp as input. So, we can get the current time by using following code:

var now = new Date();

And use the same in all Property value params.

I hope it helps.

Thanks,

Ankit Gupta

Announcements


Top Tags