Package com.serotonin.m2m2.util.chart

Examples of com.serotonin.m2m2.util.chart.PointTimeSeriesCollection


        se.setInactiveHour(inactiveHour);
        se.setInactiveMinute(inactiveMinute);
        se.setInactiveSecond(inactiveSecond);
        se.setInactiveCron(inactiveCron);

        ProcessResult response = new ProcessResult();
        ScheduledEventDao scheduledEventDao = new ScheduledEventDao();

        if (StringUtils.isBlank(xid))
            response.addContextualMessage("xid", "validate.required");
        else if (!scheduledEventDao.isXidUnique(xid, id))
            response.addContextualMessage("xid", "validate.xidUsed");

        se.validate(response);

        // Save the scheduled event
        if (!response.getHasMessages())
            RTMDefinition.instance.saveScheduledEvent(se);

        response.addData("seId", se.getId());
        return response;
    }
View Full Code Here


        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss");

        // Basic validation
        String[] nextLine = csvReader.readNext();
        if (nextLine == null)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noData"));
        if (nextLine.length < 2)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noPoints"));

        // Find the points by XID
        DataPointVO[] vos = new DataPointVO[nextLine.length - 1];

        for (int i = 1; i < nextLine.length; i++) {
            if (StringUtils.isBlank(nextLine[i]))
                throw new TranslatableException(new TranslatableMessage("dataImport.import.badXid", i));

            DataPointVO vo = dataPointDao.getDataPoint(nextLine[i]);
            if (vo == null)
                throw new TranslatableException(new TranslatableMessage("dataImport.import.xidNotFound", nextLine[i]));

            vos[i - 1] = vo;
        }

        // Find the RTs for the points if they are enabled
View Full Code Here

        String text = jsonObject.getString("outputScale");
        if (text != null) {
            outputScale = OUTPUT_SCALE_CODES.getId(text);
            if (outputScale == -1)
                throw new TranslatableJsonException("emport.error.invalid", "outputScale", text,
                        OUTPUT_SCALE_CODES.getCodeList());
        }
    }
View Full Code Here

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("attributeId");
        if (text == null)
            throw new TranslatableJsonException("emport.error.missing", "attributeId", ATTRIBUTE_CODES.getCodeList());
        attributeId = ATTRIBUTE_CODES.getId(text);
        if (!ATTRIBUTE_CODES.isValidId(attributeId))
            throw new TranslatableJsonException("emport.error.invalid", "attributeId", text,
                    ATTRIBUTE_CODES.getCodeList());
    }
View Full Code Here

    if (value != null)
      dataTypeId = value;

    JsonObject ctjson = jsonObject.getJsonObject("changeType");
    if (ctjson == null)
      throw new TranslatableJsonException("emport.error.missingObject",
          "changeType");

    String text = ctjson.getString("type");
    if (text == null)
      throw new TranslatableJsonException("emport.error.missing", "type",
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    changeTypeId = ChangeTypeVO.CHANGE_TYPE_CODES.getId(text);
    if (changeTypeId == -1)
      throw new TranslatableJsonException("emport.error.invalid",
          "changeType", text,
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    reader.readInto(getChangeType(), ctjson);
  }
View Full Code Here

    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("alarmLevel");
        if (text != null) {
            alarmLevel = AlarmLevels.CODES.getId(text);
            if (!AlarmLevels.CODES.isValidId(alarmLevel))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "alarmLevel", text,
                        AlarmLevels.CODES.getCodeList());
        }

        text = jsonObject.getString("scheduleType");
        if (text != null) {
            scheduleType = TYPE_CODES.getId(text);
            if (!TYPE_CODES.isValidId(scheduleType))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "scheduleType", text,
                        TYPE_CODES.getCodeList());
        }
    }
View Full Code Here

* @author Matthew Lohbihler
*/
public class VMStatDataSourceVO extends DataSourceVO<VMStatDataSourceVO> {
    @Override
    protected void addEventTypes(List<EventTypeVO> ets) {
        ets.add(createEventType(VMStatDataSourceRT.DATA_SOURCE_EXCEPTION_EVENT, new TranslatableMessage(
                "event.ds.dataSource"), EventType.DuplicateHandling.IGNORE_SAME_MESSAGE, AlarmLevels.URGENT));
        ets.add(createEventType(VMStatDataSourceRT.PARSE_EXCEPTION_EVENT, new TranslatableMessage("event.ds.dataParse")));
    }
View Full Code Here

        OUTPUT_SCALE_CODES.addElement(VMStatDataSourceVO.OutputScale.UPPER_M, "UPPER_M", "dsEdit.vmstat.scale.M");
    }

    @Override
    public TranslatableMessage getConnectionDescription() {
        return new TranslatableMessage("dsEdit.vmstat.dsconn", pollSeconds);
    }
View Full Code Here

    }

    @Override
    public TranslatableMessage getConfigurationDescription() {
        if (ATTRIBUTE_CODES.isValidId(attributeId))
            return new TranslatableMessage(ATTRIBUTE_CODES.getKey(attributeId));
        return new TranslatableMessage("common.unknown");
    }
View Full Code Here

            osName = "linux";
            command = "vmstat -n ";
        }
        else if(osName.startsWith("Win")){
            osName = "windows";
            raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage(
                    "event.initializationError", "OS: " + osName + " Not Supported"));
            return;
        }//since 0.9.0 ->
        else if(osName.equals("SunOS")){
            osName = "solaris";
            raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage(
                    "event.initializationError", "OS: " + osName + " Not Supported"));
            return;
        }
        else if(osName.equals("Mac OS X") || osName.equals("Darwin")){//os.name "Darwin" since 2.6.0
            osName = "mac_os_x";
            command = "vm_stat -n"; //TODO Implement this for OSX, output format is different
            raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage(
                    "event.initializationError", "OS: " + osName + " Not Supported"));
            return;
          
        }else{
            raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage(
                    "event.initializationError", "OS: " + osName + " Not Supported"));
            return;
        }

        switch (vo.getOutputScale()) {
        case VMStatDataSourceVO.OutputScale.LOWER_K:
            command += "-S k ";
            break;
        case VMStatDataSourceVO.OutputScale.UPPER_K:
            command += "-S K ";
            break;
        case VMStatDataSourceVO.OutputScale.LOWER_M:
            command += "-S m ";
            break;
        case VMStatDataSourceVO.OutputScale.UPPER_M:
            command += "-S M ";
            break;
        }

        command += vo.getPollSeconds();

        try {
            vmstatProcess = Runtime.getRuntime().exec(command);

            // Create the input stream readers.
            in = new BufferedReader(new InputStreamReader(vmstatProcess.getInputStream()));

            // Read the first two lines of output. They are the headers.
            in.readLine();
            String headers = in.readLine();

            // Create a mapping of attribute ids to split array positions.
            attributePositions = new HashMap<Integer, Integer>();
            headers = headers.trim();
            String[] headerParts = headers.split("\\s+");
            for (int i = 0; i < headerParts.length; i++) {
                int attributeId = -1;
                if ("r".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.PROCS_R;
                else if ("b".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.PROCS_B;
                else if ("swpd".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.MEMORY_SWPD;
                else if ("free".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.MEMORY_FREE;
                else if ("buff".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.MEMORY_BUFF;
                else if ("cache".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.MEMORY_CACHE;
                else if ("si".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.SWAP_SI;
                else if ("so".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.SWAP_SO;
                else if ("bi".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.IO_BI;
                else if ("bo".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.IO_BO;
                else if ("in".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.SYSTEM_IN;
                else if ("cs".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.SYSTEM_CS;
                else if ("us".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.CPU_US;
                else if ("sy".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.CPU_SY;
                else if ("id".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.CPU_ID;
                else if ("wa".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.CPU_WA;
                else if ("st".equals(headerParts[i]))
                    attributeId = VMStatPointLocatorVO.Attributes.CPU_ST;

                if (attributeId != -1)
                    attributePositions.put(attributeId, i);
            }

            // Read the first line of data. This is a summary of beginning of time until now, so it is no good for
            // our purposes. Just throw it away.
            in.readLine();

            returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
        }
        catch (IOException e) {
            raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage(
                    "event.initializationError", e.getMessage()));
        }
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.util.chart.PointTimeSeriesCollection

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.