Some guide about using variables please

Hi, I could not find much explanation about setting and using global variables. Let’s say I want to place dynamic text with system time etc. How do I create (or import ) particular variable?
I think there should be a column in the user manual dedicated to this topic.
-p-

1 Like

Hi! Yes, this topic will be extended in help. I can explain briefly

There are 3 kind of variables to use: built-in, system, user-defined

  1. Built-in variables:
  1. $date - current date in format yyyy/MM/dd
  2. $time - current time in format HH24:mm:ss.fff
  3. $fps - current fps value
  1. System - these ones are defined in in “Global Variables” section. It is created automatically:
  1. $global.cpuUsage - cpu usage in %
  2. $global.freeDiskSpace - free disk space in Mb
  3. $global.timeCounter
  1. User-defined
    User can define variables which are updated through local files or remote REST service. In case of JSON, it will expand object to flat structure, e.g. variable name is “myVariable” and json is {name:“aaa”, value: 2.0} - you will be able to use
    $global.myVariable.name=aaa
    $global.myVariable.value=2.0

Just a clarification, It looks like the built-in variable: $date also includes the time as well (as of Netcam Studio 1.7.2). You would think that if you wanted date and time you would do $date $time. Anyway to get just the date and no time?
Annotation%202019-06-24%20141340

Hi,
In principle I can agree with you. However, as of today that is what we have. Usually the IP camera also have overlay (on screen display) so test if that is more suitable. Or add a small box over the last part.
-Henrik

Is it possible to use the system variables as values in the Rule manager. ie: receive an e-mail with in the body $global.cpuUsage displayed as value in % ?

Thanks

Yes, according to explanation above. Have you tested a situation and it do not work?
-Henrik

yes, all the time actually. I prepared a rule to write to a file the contents of the license plate, but I only get the variable, both when running NCS as service and as serverX app.

  <Rule>
<Action>
  <ActionType>WriteFile</ActionType>
  <Id>-1</Id>
  <Parameters>C:\lpr.log;$global.cpuUsage</Parameters>
</Action>
<Conditions>
  <Condition>
    <ConditionOperator>Equal</ConditionOperator>
    <EventType>GlobalVariableChanged</EventType>
    <Id>0</Id>
    <Source>source.2.lpr</Source>
    <Value>ABC 123</Value>
  </Condition>
</Conditions>
<CreationDate>2021-07-01T20:48:16.3860713Z</CreationDate>
<Enabled>true</Enabled>
<Error>false</Error>
<ExecutionCount>86011</ExecutionCount>
<Id>3</Id>
<LastExecution>2021-07-14T08:08:13.8671825Z</LastExecution>
<RuleName>LPR car present</RuleName>

This is executed as a bat or cmd file outside of NCS?

no this is a simple rule inside NCS, created with the rule manager. an copied it here from it’s xml file.
eventually i would like to run a bat using this variable, but until now I can’t even manage to echo to a textfile