Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
60
RSN/Site_Info.m
Executable file
60
RSN/Site_Info.m
Executable file
@@ -0,0 +1,60 @@
|
||||
function [unitID,chainID,Chain_Scheme,num_nodi,alarms] = Site_Info(siteID,conn,FileName)
|
||||
|
||||
text = 'Site_Info function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% Scarico tutte le centraline presenti in sito
|
||||
comando = ['select id, name from units where site_id = ''' siteID ''' order by name']; % il rapporto centralina sito è di 1 a 1
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
unitID = curs.Data;
|
||||
|
||||
col = size(unitID);
|
||||
chainID = cell(1,4);
|
||||
ini = 1;
|
||||
for c = 1:col(1,1)
|
||||
% dalle centraline presenti, risalgo alle catene disponibili
|
||||
comando = ['select id, name from tools where unit_id = ''' num2str(cell2mat(unitID(c,1))) ''' order by name'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
chainID_down = curs.Data; % id tool, nome tool
|
||||
[fin,~] = size(chainID_down);
|
||||
fin = fin+ini-1;
|
||||
chainID(ini:fin,3:4) = chainID_down;
|
||||
for j = ini:fin
|
||||
chainID(j,1:2) = unitID(c,1:2); % Id centralina, nome centralina, id tool, nome tool
|
||||
end
|
||||
ini = fin+1;
|
||||
end
|
||||
|
||||
% Scarico gli schemi delle catene
|
||||
[col,~] = size(chainID); % Numero di Array
|
||||
Chain_Scheme = cell(1,3);
|
||||
num_nodi = zeros(col,1);
|
||||
ini = 1;
|
||||
cont = 1;
|
||||
for c = 1:col(1,1)
|
||||
comando = ['select nodetype_id, depth, num from nodes where tool_id = ''' num2str(cell2mat(chainID(c,3))) ''' order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
scheme_down = curs.Data; % id nodo, profondità, numero
|
||||
[fin,~] = size(scheme_down);
|
||||
num_nodi(cont) = fin;
|
||||
Chain_Scheme(1:fin,ini:ini+2) = scheme_down;
|
||||
ini = ini+3;
|
||||
cont = cont+1;
|
||||
end
|
||||
|
||||
% Scarico l'allarme relativo al sito
|
||||
comando = ['select id, name, ctrltype_id, alarm_phone, conn_usr, conn_pwd, duedate from ctrltools where site_id = ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
alarms = curs.Data;
|
||||
|
||||
text = 'Site_Info function worked correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user