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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Vuforia View app crashes when the property value changes

MarcoNFT
9-Granite

Vuforia View app crashes when the property value changes

Hi,

I would like to play a certain sequence, which i already created in my Creo Illustrate model, when the bool value changes in the PLC.
After entering the JS code I have the problem that the app sporadically crashes.
But usually it happens when the value to be monitored changes.

 

I tried to play the sequence by using the watch function

 

$scope.PlaySequence = function ()
{
$timeout (function() {
$scope.app.view.Startseite.wdg["model-1"].currentStep = 17;
$timeout(function () {
$scope.$root.$broadcast('app.view["Startseite"].wdg["model-1"].svc.play');},250);},250);
$scope.$applyAsync(()=>{angular.element(document.getElementById('model-1')).scope().reset();});
return;

};

 

$scope.$watch(function(scope)
{
return $scope.app.mdl.HoRe_ALL.properties.TestBool
},

function ()
{
$scope.PlaySequence();
}
);

 

Can someone tell me what I'm doing wrong with this function?

 

 

Yours sincerely
Marco

4 REPLIES 4

@Hi @MarcoNFT ,

 

I believe one problem which may   occur - is  when you are loading your project and the value changed but the model is not loaded yet.  If this is the problem you can avoid it  when you embed the watch construct inside the model Load event:

 

$rootScope.$on('modelLoaded', function() {  
/////////////////////////////////////////////
$scope.$watch(function(scope)
{
return $scope.app.mdl.HoRe_ALL.properties.TestBool
},

function ()
{
$scope.PlaySequence();
}
);
/////////////////////////////////////////
})

 

Hi Roland,

 

first of all. Thanks for your help. Sounds like a possible solution.

I'm going to try this as soon as possible  and will give a feedback.

 

 

Best regards

Marco

sshevliakov
4-Participant
(To:MarcoNFT)

Hello Marco!

Did Roland's solution solve your problem?
I'm experiencing more or less similar issue - my experience crashes, after I overwrite currentStep-parameter, reload and try to play my model with $timeout().

 

Kind regards

Stanislav

 

Hi Stanislav,

 

no unfortunately we couldn't solve the problem with the code above. There was a problem

to write a new stepnumber in the model.

I think our problem was that one big .pvi data with about twenty steps data from Creo Illustrates.

 

I tried updating my Creo Illustrates model. Now i have twenty .pvi datas with only one step.

 

If a property changed we load the matching sequence (sorry i don't know how to format js code here, i attached screenshots for clarity):

_________________________________________________________________________________________

$scope.$root.$on("GetPropertyValues-complete", function(event, args) {

if(args.data["0"].Hochregallager_CPU_1511_1_PN_Bool_Signale_Sicherung_Lueftung_Schaltschrank)
{

$scope.app.view.Startseite.wdg["Alarm_icon"].visible = true;
$scope.app.view.Startseite.wdg["StoermeldeAnzeige1"].text = $scope.app.mdl['HoRe_String'].properties['Hochregallager_CPU_1511_1_PN_String_Signale_Stoer_1'];
$scope.app.view.Startseite.wdg["StoermeldeAnzeige1"].visible = true;
if ((WahlMeldungVisu == 1 && $scope.app.view.Startseite.wdg["StoermeldeAnzeige1"].text == $scope.app.mdl['HoRe_String'].properties['Hochregallager_CPU_1511_1_PN_String_Signale_Stoer_1'])|| AnzahlMeldungen == 0)
{
$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - Animation_5FSicherung_5FLuefter_5FStoer1.pvi'; //every property has a small pvi with the sequence
WahlMeldung = 1;
}

}

_________________________________________________________________________________________

 

After that I use the LoadSequence and PlaySequence functions:

_________________________________________________________________________________________

$scope.PlaySequence = function ()
{
$scope.app.view["Startseite"].wdg["popupStoermeldung"].visible = false;
$timeout(function ()
{
$timeout(function () {$scope.$root.$broadcast('app.view["Startseite"].wdg["model-1"].svc.play');},200);},200);
$scope.$applyAsync(()=>{angular.element(document.getElementById('model-1')).scope().reset();});
}
};

_________________________________________________________________________________________

$scope.LoadSequence = function (Textfeld)
{
WahlMeldungVisu = Textfeld;

};

_________________________________________________________________________________________

 

Now it's working fine to play the sequences.

 

Hope i could help you.

 

Best regards 

Marco

Announcements

Top Tags