Skip to content

Instantly share code, notes, and snippets.

@neerajnagi
neerajnagi / safeSaveRDS.md
Created February 20, 2017 08:32
safe saveRDS
saveRDSCustom <- function(obj,fileName){
  tryCatch({
    fileConn<-file(fileName,blocking = TRUE)
    saveRDS(obj,fileConn)
    close(fileConn)
    return(TRUE)
  }
  ,error=function(e){
 cat(e)
@neerajnagi
neerajnagi / gist:1488f0013bc5014a95fd1496cdda8100
Created November 17, 2016 09:17
sensor status bit structure
{"t":1479255000,"c":0}
c is a number
convert it to binary
5bit are used
1st bit : unused , always 0
2nd bit : configured
3rd bit : discovered
4th bit : connected
5th bit : recieved
@neerajnagi
neerajnagi / persistence.md
Last active October 3, 2016 11:27
R persistence & running stats

Db

Db is a typical key-value store, key is a vector so you can track any number of metrics with various combinations

Db.new()
Db.get(Vector) 
Db.put(Vector, Object)

Stats

Stats can be used to track moments calculation over every N batches

@neerajnagi
neerajnagi / online_moment.md
Last active October 1, 2016 05:37
online moment algorithm

WINDOW is # of batches to be used

#define WINDOW = 24 //for 4 hours double n,m1,m2,m3,m4 //mN is Nth moment

function reset(){ n=0 m1=0 m2=0

@neerajnagi
neerajnagi / reroute.md
Last active September 26, 2016 09:08
datahub reroute

shell access of RPI

cd ~/prophecy-gateway/src/public/js

edit function.js line 66

redis-cli
> flushall ( inside redis console)
@neerajnagi
neerajnagi / router.md
Last active September 13, 2016 07:33
Gauge Router
[
  ["Custom.*", "Blower",
    ["Blower Vibration CUSTOM"]
  ],
  ["VPDB.*", "Blower", 
    ["Blower Vibration VPDB","Filter Status VPDB", "Oil Check VPDB", "Oil Overfill Indicator VPDB", "Belt Tension VPDB"]
  ],
  ["SVP.*", "Blower", 
 ["Blower Vibration SVP","Filter Status SVP", "Oil Check SVP", "Oil Overfill Indicator SVP", "Belt Tension SVP"]
@neerajnagi
neerajnagi / reason.md
Created September 6, 2016 03:48
gauge_error_messages
color       description                                                    appropriate_reason

white       machine stationary                                              Machine is idle                         
white       batch rejected                                                  Poor quality of data
white       autobaseline input missing in json                              Baseline pending 
black       non-autobaseline input missing in json                          Unexpected Error
black       R code failure,exception etc                                    Unexpected Error
black       batch missing                                                   Link Error
@neerajnagi
neerajnagi / guideline_R_model_and_input_json.md
Last active September 1, 2016 10:25
guidelines for R code modification w.r.t ( json input and multimodel )

R algo will require multiple algos for a particular gauge based on model information. Also there is a frequent change in input structure of input.

To handle these things a unified json will be provided which will have following #####1) header containing machine details ( model, name, company, zone etc ) #####2) All the available statistics for all the collectors of all the subassemblies of a machines. #####3) raw data in 2d array format under collector

This will be the only input everything else will be sourced statically.

@neerajnagi
neerajnagi / gauge_testing.md
Last active September 5, 2016 12:55
gauge testing

prerequisite

company
machineName ( svp_10 ) 
machineID (machine-a39x9d...... )
dataviewer login(  sumin1  / sumin1 ) 

Check that baseline is set for gauge if its applicable

@neerajnagi
neerajnagi / Wc.md
Last active August 20, 2016 22:31
Wrapper checklist

supress all warning messages

options(warn=-1)

suppress all library messages

 suppressMessages(library("dplyr"))