Now sending Emails

This commit is contained in:
Bernardo Carvalho
2019-12-16 10:30:09 +00:00
parent 8869b40e1f
commit ab49f03b9a
7 changed files with 98 additions and 53 deletions

View File

@@ -1,4 +1,19 @@
###############
#############################################
## Project : ISTTOK slow Control
##
## File :
## Description : Records for ISTTOK Control I/O channels connected to 2 Velleman board
##
##
## Author : Bernardo Carvalho (IPFN-IST)
##
## Copyright (c) : IPFN-IST 2015-2020
## Created 3-Mar-2019
##
##
##########################################
################
###############
# REGISTER 56 #
###############
@@ -173,36 +188,35 @@ record(bo, "$(P)$(R)Buzzer" ) {
field(ONAM, "Pulse" )
field(HIGH, "2.5")
field(FLNK, "$(P)$(R)BuzzerInv" )
field(VAL,"0")
field(VAL, "0")
}
record(calcout, "$(P)$(R)BuzzerInv" ) {
field( INPA, "$(P)$(R)Buzzer NPP MS" )
field( OUT, "$(P)$(R)PCF8574:57:REGISTER.B3 PP MS" )
field( OOPT, "On Change" )
field( CALC, "A?0:1" )
field(INPA, "$(P)$(R)Buzzer NPP MS" )
field(OUT, "$(P)$(R)PCF8574:57:REGISTER.B3 PP MS" )
field(OOPT, "On Change" )
field(CALC, "A?0:1" )
}
##############################
# EMERGENCY MODE #
##############################
record(bi, "$(P)$(R)Emergency-PhysButton" ) {
field(DESC,"External Physical Emergency Button")
field( INP, "$(P)$(R)PCF8574:57:REGISTER:READ.B4 NPP NMS")
# field(OUT, "$(P)$(R)PCF8574:57:REGISTER.B4 PP" )
field(DESC,"External Physical Emergency Button")
field(INP, "$(P)$(R)PCF8574:57:REGISTER:READ.B4 NPP NMS")
field(ZNAM, "ON")
field(ONAM, "OFF" )
field(FLNK, "$(P)$(R)Emergency" )
}
record(bo, "$(P)$(R)Emergency-UserButton" ) {
field(DESC,"Soft User Emergency Button")
field(DESC,"Soft User Emergency Button")
field(ZNAM, "OFF" )
field(ONAM, "ON")
field(FLNK, "$(P)$(R)Emergency" )
}
record(calc, "$(P)$(R)Emergency" ) {
field(DESC,"Emergency State")
field(INPA,"$(P)$(R)Emergency-PhysButton.RVAL NPP" )
field(INPB,"$(P)$(R)Emergency-UserButton.RVAL NPP" )
field(DESC, "Emergency State")
field(INPA, "$(P)$(R)Emergency-PhysButton.RVAL NPP" )
field(INPB, "$(P)$(R)Emergency-UserButton.RVAL NPP" )
field(CALC, "A || B" ) # ! Not
}
@@ -223,8 +237,7 @@ record(calc, "$(P)$(R)Emergency" ) {
# ROTARY1 PUMP #
#############################
record( bo, "$(P)$(R)RPump1-Motor" ) {
# field(DESC," Liga a alimentação da bomba rotatória 1 ")
#record( bo, "$(P)$(R)RotatoryPump" ) {
field(DESC,"Power to Rotatory Pump 1. Relay 5")
field(OUT, "$(P)$(R)PCF8574:60:REGISTER.B0 PP" )
field(ZNAM, "Off" )
field(ONAM, "On" )
@@ -236,8 +249,7 @@ record( bo, "$(P)$(R)RPump1-Motor" ) {
# ROTARY1 VALVE #
#############################
record( bo, "$(P)$(R)RPump1-Valve" ) {
field(DESC,"Abre a valvula da bomba rotatoria 1 ")
# record( bo, "$(P)$(R)RotatoryValve" ) {
field(DESC,"Abre a valvula da bomba rotatoria 1. Relay 4")
field(OUT, "$(P)$(R)PCF8574:60:REGISTER.B1 PP" )
field(ZNAM, "Closed" )
field(ONAM, "Open" )
@@ -261,9 +273,9 @@ record( bo, "$(P)$(R)RPump2-Motor" ) {
#############################
record( bo, "$(P)$(R)RPump2-Valve" ) {
field(DESC," Abre a valvula da bomba rotatoria 2 ")
field(OUT, "$(P)$(R)PCF8574:60:REGISTER.B3 PP" )
field(ZNAM, "Closed" )
field(ONAM, "Open" )
field(OUT,"$(P)$(R)PCF8574:60:REGISTER.B3 PP" )
field(ZNAM,"Closed" )
field(ONAM,"Open" )
field(VAL,"1")
}

View File

@@ -9,6 +9,7 @@ DB += ISTTOKmachineControl.db
DB += ISTTOKpcf8574.db
DB += ISTTOKpcf8591.db
DB += ISTTOKpfeiffer.db
DB += sendmail.db
# If <anyname>.db template is not named <anyname>*.template add
# <anyname>_TEMPLATE = <templatename>

View File

@@ -0,0 +1,7 @@
record(stringout, $(P)$(R)sendmail){
field(DESC, "Send email")
field(DTYP, "stream")
field(OUT, "@sendmail.proto send(isttok@ipfn.tecnico.ulisboa.pt,bernardo.brotas@gmail.com) $(PORT) $(A)")
# field(PINI, "YES")
}

View File

@@ -235,7 +235,10 @@ monitor IsttokTTSystem_tzero;
/* Trace message record limited to 40 characters */
string msg;
assign msg to "ISTTOK:central:TraceMessage.VAL";
monitor msg;
//monitor msg;
string sendMail;
assign sendMail to "ISTTOK:central:sendmail";
/* Main Pulse State Set */
ss PulseSequence {
@@ -352,8 +355,6 @@ ss PulseSequence {
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n",msg);
/* Pulse state change to Starting */
// IsttokOPSTATE = POS_Starting;
// pvPut(IsttokOPSTATE);
} state Starting
}
/* State Starting */
@@ -367,24 +368,18 @@ ss PulseSequence {
pvPut(msg);
errlogSevPrintf(MAJOR, "%s\n",msg);
/* Pulse state change to Emergency*/
// IsttokOPSTATE = POS_Starting;
// pvPut(IsttokOPSTATE);
} state Emergency
when (IsttokOPREQ == STOP) {
strcpy(msg, "State to Stopping");
pvPut(msg);
errlogSevPrintf(MINOR, "%s\n",msg);
/* Pulse state change to Stopping */
// IsttokOPSTATE = POS_Stopping;
// pvPut(IsttokOPSTATE);
} state Stopping
when (STARTINGSTATE == STRST_StartingEnd ) {
strcpy(msg, "State to Process");
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n",msg);
/* Pulse state change to Process*/
// IsttokOPSTATE = POS_Process;
// pvPut(IsttokOPSTATE);
} state Process
}
/* State Process */
@@ -409,6 +404,8 @@ ss PulseSequence {
/* Vacuum emergency: Pulse state change to Stopping */
IsttokOPREQ = STOP;
pvPut(IsttokOPREQ);
strcpy(sendMail, "Vacuum Emergency while Process");
pvPut(sendMail);
} state Stopping
when (IsttokOPREQ==STOP || IsttokTMPump1_ManualValve == OFF) {
@@ -634,8 +631,6 @@ ss StartingSequence {
strcpy(msg, "Starting1 Out");
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n",msg);
// IsttokSTARTINGSTATE = STRST_NonStarting;
// pvPut(IsttokSTARTINGSTATE);
} state NonStarting
when (delay(5.0)) {
strcpy(msg, "Rotary Valve1 OPEN");
@@ -688,17 +683,6 @@ ss StartingSequence {
errlogSevPrintf(NO_ALARM, "%s\n",msg);
IsttokTMPump2_Motor = PCF_RELAY_ON;
pvPut(IsttokTMPump2_Motor);
/*
if(TMPump1NormalOperation == PCF_INPUT_ON){
sprintf(tmp1_stat, "ON");
}else{
sprintf(tmp1_stat, "OFF");
}
sprintf(msg, "TMPNO = [1:%s]", tmp1_stat);
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n",msg);
*/
STARTINGSTATE = STRST_Starting4;
pvPut(STARTINGSTATE);
} state Starting4
@@ -1079,21 +1063,10 @@ ss ShotSequence {
} state ShotEnd
}
state ShotEnd {
/*
when ((IsttokOPSTATE != POS_WaitShot ) && (IsttokShotCountdown == 160) ) {
strcpy(msg, "Shoting13 Out");
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n", msg);
WSHOTINGSTATE = WSHTST_NonShoting;
pvPut(WSHOTINGSTATE);
} state NonShoting
*/
when (IsttokShotCountdown > 160) {
strcpy(msg, "Terminated");
pvPut(msg);
errlogSevPrintf(NO_ALARM, "%s\n", msg);
// IsttokShotCountdown = 0;
// pvPut(IsttokShotCountdown);
WSHOTINGSTATE = WSHTST_WaitTrg;
pvPut(WSHOTINGSTATE);
} state ShotWaitTrg

View File

@@ -30,6 +30,7 @@ ISTTOKrpi_DBD += asyn.dbd
ISTTOKrpi_DBD += stream.dbd
ISTTOKrpi_DBD += drvAsynI2C.dbd
ISTTOKrpi_DBD += drvAsynSerialPort.dbd
ISTTOKrpi_DBD += drvAsynIPPort.dbd
ISTTOKrpi_DBD += asSupport.dbd
# Add all the support libraries needed by this IOC

View File

@@ -35,6 +35,12 @@ asynSetOption("RS0", 0, "crtscts", "N")
dbLoadRecords("db/ISTTOKpfeiffer.db","P=ISTTOK:,R=central:,bus=RS0")
# connect to the MAIL server mail.ipfn.tecnico.ulisboa.pt
# ,priority,noAutoConnect,noProcessEos
drvAsynIPPortConfigure("L0","193.136.136.3:25",0,1,0)
dbLoadRecords("db/sendmail.db", "P=ISTTOK:,PORT=L0,R=central:,L=0,A=0")
# Uncomment to Debug STREAM serial activity
#var streamError 1
#var streamDebug 1

View File

@@ -0,0 +1,45 @@
# https://epics.anl.gov/tech-talk/2013/msg02051.php
Terminator = CR LF;
ExtraInput = Ignore;
ReplyTimeout = 1000;
@mismatch { out "QUIT"; disconnect; }
mail_start {
connect 10000;
in "220";
out "HELO ipfn.tecnico.ulisboa.pt";
in "250";
out "AUTH LOGIN";
in "334";
out "YmVybmFyZG8=";
in "334";
out "RjJjb21ldA==";
in "235";
out "MAIL FROM:\$1";
in "250";
out "RCPT TO:\$2";
in "250";
out "RCPT TO: halves@ipfn.tecnico.ulisboa.pt";
in "250";
out "DATA";
in "354";
out "From: \$1";
out "To: \$2";
out "Subject: Report from ISTTOK";
out "";
}
mail_end {
out ".";
in "250";
out "QUIT";
disconnect;
}
send {
mail_start;
out "Problem is: %s";
mail_end;
}