Package com.serotonin.m2m2.rt.script

Examples of com.serotonin.m2m2.rt.script.ScriptExecutor


      }
    } else if (dataTypeId == DataTypes.NUMERIC) {
      try {
        startObject = NumericValue.parseNumeric(startValue);
      } catch (NumberFormatException e) {
        startObject = new NumericValue(0);
      }
    } else {
      if (startValue == null)
        startObject = new AlphanumericValue("");
      else
View Full Code Here


        double newValue = currentValue.getDoubleValue() + change;
        if (newValue > vo.getMax())
            newValue = vo.getMax();
        if (newValue < vo.getMin())
            newValue = vo.getMin();
        return new NumericValue(newValue);
    }
View Full Code Here

    @DwrPermission(user = true)
    public ProcessResult validateScript(String script, int sourcePointId, int targetPointId) {
        ProcessResult response = new ProcessResult();
        TranslatableMessage message;
        ScriptExecutor scriptExecutor = new ScriptExecutor();

        DataPointRT point = Common.runtimeManager.getDataPoint(sourcePointId);
        if (point == null)
            message = new TranslatableMessage("event.pointLink.sourceUnavailable");
        else {
            Map<String, IDataPointValueSource> context = new HashMap<String, IDataPointValueSource>();
            context.put(PointLinkRT.CONTEXT_VAR_NAME, point);
            int targetDataType = new DataPointDao().getDataPoint(targetPointId).getPointLocator().getDataTypeId();

            try {
                PointValueTime pvt = scriptExecutor.execute(script, context, System.currentTimeMillis(),
                        targetDataType, -1);
                if (pvt.getValue() == null)
                    message = new TranslatableMessage("event.pointLink.nullResult");
                else if (pvt.getTime() == -1)
                    message = new TranslatableMessage("pointLinks.validate.success", pvt.getValue());
View Full Code Here

        }

        int targetDataType = targetPoint.getVO().getPointLocator().getDataTypeId();

        if (!StringUtils.isBlank(vo.getScript())) {
            ScriptExecutor scriptExecutor = new ScriptExecutor();
            Map<String, IDataPointValueSource> context = new HashMap<String, IDataPointValueSource>();
            DataPointRT source = Common.runtimeManager.getDataPoint(vo.getSourcePointId());
            context.put(CONTEXT_VAR_NAME, source);

            try {
                PointValueTime pvt = scriptExecutor.execute(vo.getScript(), context, newValue.getTime(),
                        targetDataType, newValue.getTime());
                if (pvt.getValue() == null) {
                    raiseFailureEvent(newValue.getTime(), new TranslatableMessage("event.pointLink.nullResult"));
                    return;
                }
View Full Code Here

        return "publisherEdit.squwk";
    }

    @Override
    protected PublisherVO<? extends PublishedPointVO> createPublisherVO() {
        return new SquwkSenderVO();
    }
View Full Code Here

        model.put("NUMERIC", DataTypes.NUMERIC);
        model.put("IMAGE", DataTypes.IMAGE);

        // Create the individual point charts
        for (PointStatistics pointStat : pointStatistics) {
            PointTimeSeriesCollection ptsc = new PointTimeSeriesCollection(timeZone);

            if (pointStat.getNumericTimeSeries() != null)
                ptsc.addNumericTimeSeries(pointStat.getNumericTimeSeries().plainCopy());
            else if (pointStat.getDiscreteTimeSeries() != null)
                ptsc.addDiscreteTimeSeries(pointStat.getDiscreteTimeSeries().plainCopy());

            if (ptsc.hasData()) {
                if (inlinePrefix != null)
                    model.put("chartName", inlinePrefix + pointStat.getChartName());
                pointStat.setImageData(ImageChartUtils.getChartData(ptsc, POINT_IMAGE_WIDTH, POINT_IMAGE_HEIGHT,
                        reportInstance.getReportStartTime(), reportInstance.getReportEndTime()));
            }
        }

        PointTimeSeriesCollection ptsc = handler.getPointTimeSeriesCollection();
        if (ptsc.hasData()) {
            if (inlinePrefix != null)
                model.put("chartName", inlinePrefix + IMAGE_CONTENT_ID);
            else {
                chartName = "r" + reportInstance.getId() + ".png";
                // The path comes from the servlet path definition in web.xml.
View Full Code Here

        return KEY;
    }

    @Override
    public ChangeTypeRT createRuntime() {
        return new AlternateBooleanChangeRT();
    }
View Full Code Here

    return alternateBooleanChange;
  }

  @Override
  public PointLocatorRT createRuntime() {
    ChangeTypeRT changeType = getChangeType().createRuntime();
    String startValue = getChangeType().getStartValue();
    DataValue startObject;
    if (dataTypeId == DataTypes.BINARY)
      startObject = BinaryValue.parseBinary(startValue);
    else if (dataTypeId == DataTypes.MULTISTATE) {
View Full Code Here

        return KEY;
    }

    @Override
    public ChangeTypeRT createRuntime() {
        return new IncrementAnalogChangeRT(this);
    }
View Full Code Here

        return KEY;
    }

    @Override
    public ChangeTypeRT createRuntime() {
        return new RandomBooleanChangeRT();
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.rt.script.ScriptExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.