Senseforce 2.0 Manual
  • Welcome to Senseforce 2.0
  • SF MQTT API
  • SF Edge
    • Edge Package Overview
    • Edge Installation
      • Using the SF Edge Service installer in command shell
      • Headless SF Edge Servie execution
    • Edge Configuration
      • Which Plugins to load (appsettings.xml)
      • Edge Data Routing (EventDefinition.xml)
      • OTA configuration (otasettings.xml)
      • Edge Logging
      • Input plugins
        • SQL Plugin
        • SQLite Plugin
        • OPC UA Plugin
          • OPC UA server browser
        • SIEMENS S7/SINUMERIK Plugin
          • Creating connection definition file
        • S7 Plugin
        • REST Plugin
        • TCP Listener Plugin
        • XML File Parsing Plugin
        • Heidenhain Plugin
      • Output Plugins
        • MQTT Plugin
        • SQLite Plugin
    • Edge Compute plugins
      • Creating compute plugins
      • Using compute plugins
  • SF Edge Asset Management
    • Edge version repository
  • SF Platform
    • Navigation
      • Overview Screen
    • Dataset Builder
      • Filters, Aggregations and Groupings
      • Functions of the Formula Editor
      • Additional Settings
      • Special Events
      • FAQ and Troubleshooting
    • Script Editor
      • Details of the Script Editor
      • Installed Packages
      • Working with Timestamps
        • Working with Timestamps in Python
        • Working with Timestamps in R
      • FAQ and Troubleshooting
    • Widgets
      • Text
      • Headline
      • Image
      • Progress Bar & Gauge Chart
      • Table
      • Map
      • Line, Bar, Scatter and Area Chart
      • Pie Chart
      • Gantt Chart
      • Histogram
      • Overview
      • Log
      • Default colors and color conditions
      • FAQ and Troubleshooting
    • Dashboards
      • Dashboard Filters
      • Favorites
      • Data Drilldown & Widget Interaction
      • Editing multiple dashboard widgets
      • Time Zones
      • Synchronized Zooming
      • Sharable Dashboard URL
      • Multi-chart layout options
      • Default sort for table widgets
      • Releases
      • Reporting
      • FAQ and Troubleshooting
      • Applying zoom to global timestamp filter
      • Optimise the layout for different devices
    • Machine Master Data
      • Dimensions
      • Instances
      • Things
      • Use Case
      • FAQ and Troubleshooting
    • Automation
      • Trigger
      • Scheduling overview
      • Actions
      • Test your Automation
      • Zapier integration (necessary internal steps)
      • Zapier integration
      • Subscriptions
      • FAQ and Troubleshooting
    • Event Schema Management
      • Importing a Event Schema
      • FAQ and Troubleshooting
    • Virtual Events
      • Creating a Virtual Event
      • Scheduling Overview
      • Permissions and Data Access
      • FAQ and Troubleshooting
    • Details modal for elements
    • Copy / Duplicate elements
    • Whitelabeling
    • Edge Device Management
    • Element History
    • Public API
      • Get your access token
      • Endpoints
      • Debugging scripts
      • FAQ and Troubleshooting
    • User & Group Management
      • FAQ and Troubleshooting
    • Active Directory & SSO Setup
Powered by GitBook
On this page
  • Versions
  • Performance
  • Data Input
  • Row Limit
  • Data Types
  • Disabled operations in Python
  • Importing External Models or Data Frames
  • Data Output
  • Data Types
  • Sorting
  • Unit and Decimals
  • Comments in the Code
  • Printing out variables in Python

Was this helpful?

  1. SF Platform
  2. Script Editor

Details of the Script Editor

Versions

The Python service is currently running Python 3.9.2 (2021-02-19) The R service is currently running R 4.0.2 (2020-06-23)

Performance

The Senseforce Python service uses native python integration which makes it extremely reliable and highly performant. Up to 64 scripts can run concurrently. Any additional request above that number is being queued for later execution. Every executed script has its own thread with its own timeout set to 30 min.

In case you experience performance degradation please contact your Senseforce agent.

Data Input

Row Limit

For performance reasons, there is a limit of 5.000.000 rows per dataset that can be imported to the script editor. If you need more rows consider aggregating them prior to your script.

Data Types

When selecting a dataset for input the data type of the columns may change after importing. In the following, we will list the transformation to the data types which are available in R/Python.

Type of dataset column

Data Type R

Data Type Python

Text

factor

str

Timestamp

numeric

str

Double

numeric

float

Integer

numeric

int

Long

numeric

int

Boolean

logical

bool

Time

numeric

str

Note, the Thing column is always a text column so it will be imported to the script editor as a factor vector if you are using R and not as a character vector.

Note, the Timestamp values are UNIX timestamps in milliseconds. Packages for handling timestamp usually expect a UNIX timestamp in seconds. If you are using such a package divide your timestamp by 1000.

Exceptions: numpy.float128 and numpy.complex256 are going to be converted to String.

'numpy.bool_' --> 'bool' 'numpy.int8' --> 'int' 'numpy.uint8' --> 'int' 'numpy.int16' --> 'int' 'numpy.uint16' --> 'int' 'numpy.int32' --> 'int' 'numpy.uint32' --> 'int' 'numpy.int64' --> 'int' 'numpy.uint64' --> 'int' 'numpy.longlong' --> 'int' 'numpy.ulonglong' --> 'int' 'numpy.float16' --> 'float' 'numpy.float16' --> 'float' 'numpy.float32' --> 'float' 'numpy.float64' --> 'float' 'numpy.float128' --> 'numpy.float128' 'numpy.complex64' --> 'complex' 'numpy.complex128' --> 'complex' 'numpy.complex256' --> 'numpy.complex256'

Disabled operations in Python

The following commands are not allowed for security reasons:

open()

to_csv()

__import__()

exec()

eval()

Importing External Models or Data Frames

By importing .rds or .pickle files to your script you can use R or Python objects in the script.

Data Output

Data Types

Available data types are,

  • String

  • Long

  • Double

  • Timestamp

  • Integer

  • Boolean

With the result data type you define how the widget should interpret your results. So if you want time to be displayed in a dynamic format depending on the viewed time frame make your result a timestamp (unix timestamp in milliseconds). If you want a fixed time format you can transform them into a string and define them as such. If you want to use your values as a value for the y-axis they need to be numerical (long, integer or double). If you use factors (which represent strings) in R make sure to transform them to a character vector when assigning them to your result variable.

Sorting

If you plan to use your results in a widget that only takes one value, like the single text widget, bar, or gauge chart, make sure the value you want to display is the first (or only) one in your results.

If the result is supposed to be used in a multi-chart using the auto-generated series feature and text on the x-axis the widget might display the data, not in the way you want it to. For more details please check the section about the widget editor.

Unit and Decimals

You can specify the unit of your result. Later you can use the unit to be displayed in your chart (e.g. in the legend). Decimals are only relevant for displaying results of type double. You can define how many digits are shown in the charts and widgets.

Comments in the Code

In R, you can use # to mark a line as a comment (or the end of a line).

In Python, you can use # (when the new Python Service is released to your tenant), or you can use single or triple " to mark a line as a comment sometimes.

Printing out variables in Python

You can print out a variable content, and check the result in the “Response Tab” of the browser.

Do not forget to delete or comment out all the print() statements after debugging otherwise your code won’t return a valid JSON.

PreviousScript EditorNextInstalled Packages

Last updated 3 years ago

Was this helpful?

Note, Numpy data types () are automatically converted to native Python data types.

Clicking Import Dataset or Model in the Data tab will open a window where you can drop a .rds or .pickle file (or search for one with the explorer). Confirm the import after the file was uploaded. The file can be accessed by clicking next to the Imported variable. Now you should see next to your imported file - click the to add the code to your script necessary to access the object stored in the file. Accessing the attributes of the object you imported now should work in the same way as if you would do it in any other coding environment.

https://numpy.org/doc/stable/user/basics.types.html