Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6023 srw watchpoint panels #6120

Merged
merged 15 commits into from
Aug 1, 2023
8 changes: 8 additions & 0 deletions sirepo/package_data/static/css/sirepo.css
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@
.sr-panel-running .sr-panel-wait {
font-weight: bold;
}
.sr-panel-waiting {
background-color: #777;
}
.sr-panel-waiting .sr-panel-wait {
color: white;
display: block;
z-index: 1000;
}
.sr-hide-report {
opacity: 0;
height: 0;
Expand Down
48 changes: 35 additions & 13 deletions sirepo/package_data/static/js/sirepo-beamline.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ SIREPO.app.directive('watchPointList', function(appState, beamlineService) {
};
});

SIREPO.app.directive('beamlineAnimation', function(appState, frameCache, persistentSimulation) {
SIREPO.app.directive('beamlineAnimation', function(appState, frameCache, panelState, persistentSimulation) {
return {
restrict: 'A',
scope: {},
Expand All @@ -865,7 +865,7 @@ SIREPO.app.directive('beamlineAnimation', function(appState, frameCache, persist
</div>
<div style="margin-bottom: 1em" class="clearfix"></div>
<div data-ng-repeat="report in reports" data-ng-if="simState.hasFrames()">
<div data-watchpoint-report="" data-item-id="report.id"></div>
<div data-watchpoint-report="" data-item-id="report.id" data-ng-if="showReport(report)"></div>
<div class="clearfix hidden-xl" data-ng-hide="($index + 1) % 2"></div>
<div class="clearfix visible-xl" data-ng-hide="($index + 1) % 3"></div>
</div>
Expand All @@ -878,6 +878,13 @@ SIREPO.app.directive('beamlineAnimation', function(appState, frameCache, persist
$scope.reports = [];
});

$scope.showReport = report => {
if ($scope.simState.isStateRunning()) {
return true;
}
return frameCache.getFrameCount(report.modelAccess.modelKey) !== SIREPO.nonDataFileFrame;
};

$scope.start = function() {
$rootScope.$broadcast('saveLattice', appState.models);
appState.models.simulation.framesCleared = false;
Expand All @@ -887,24 +894,39 @@ SIREPO.app.directive('beamlineAnimation', function(appState, frameCache, persist
};

$scope.simHandleStatus = (data) => {
function getReport(id) {
for(const r of $scope.reports) {
if (id === r.id) {
return r;
}
}
return null;
}

if (appState.models.simulation.framesCleared) {
return;
}
if (! data.outputInfo) {
return;
}
for (let i = 0; i < data.frameCount; i++) {
if ($scope.reports.length != i) {
continue;
}

for (let i = 0; i < data.outputInfo.length; i++) {
let info = data.outputInfo[i];
$scope.reports.push({
id: info.id,
modelAccess: {
modelKey: info.modelKey,
},
});
frameCache.setFrameCount(info.frameCount || 1, info.modelKey);
if (! getReport(info.id)) {
$scope.reports.push(
{
id: info.id,
modelAccess: {
modelKey: info.modelKey,
},
}
);
}
frameCache.setFrameCount(
info.waitForData ? SIREPO.nonDataFileFrame : (info.frameCount || 1),
info.modelKey
);
panelState.setWaiting(info.modelKey, ! ! info.waitForData);
}
frameCache.setFrameCount(data.frameCount || 0);
};
Expand Down
3 changes: 2 additions & 1 deletion sirepo/package_data/static/js/sirepo-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,8 @@ SIREPO.app.directive('showLoadingAndError', function(panelState) {
modelKey: '@',
},
template: `
<div data-ng-class="{\'sr-panel-loading\': panelState.isLoading(modelKey), \'sr-panel-error\': panelState.getError(modelKey), \'sr-panel-running\': panelState.isRunning(modelKey), \'has-transclude\': hasTransclude()}" class="panel-body" data-ng-hide="panelState.isHidden(modelKey)">
<div data-ng-class="{'sr-panel-loading': panelState.isLoading(modelKey), 'sr-panel-error': panelState.getError(modelKey), 'sr-panel-running': panelState.isRunning(modelKey), 'sr-panel-waiting': panelState.isWaiting(modelKey), 'has-transclude': hasTransclude()}" class="panel-body" data-ng-hide="panelState.isHidden(modelKey)">
<div data-ng-show="panelState.isWaiting(modelKey)" class="lead sr-panel-wait"><span class="glyphicon glyphicon-hourglass"></span> Waiting for Data</div>
<div data-ng-show="panelState.isLoading(modelKey)" class="lead sr-panel-wait"><span class="glyphicon glyphicon-hourglass"></span> {{ panelState.getStatusText(modelKey) }}</div>
<div data-ng-show="panelState.getError(modelKey)" class="lead sr-panel-wait"><span class="glyphicon glyphicon-exclamation-sign"></span> {{ panelState.getError(modelKey) }}</div>
<div data-ng-transclude=""></div>
Expand Down
8 changes: 8 additions & 0 deletions sirepo/package_data/static/js/sirepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,10 @@ SIREPO.app.factory('panelState', function(appState, requestSender, simulationQue
return queueItems[name] && queueItems[name].qState == 'processing' ? true : false;
};

self.isWaiting = name => {
return getPanelValue(name, 'waiting') ? true : false;
};

self.maybeSetState = function(model, state) {
if (!model) {
return;
Expand Down Expand Up @@ -1854,6 +1858,10 @@ SIREPO.app.factory('panelState', function(appState, requestSender, simulationQue

self.setData = (name, data) => setPanelValue(name, 'data', data);

self.setWaiting = (name, isWaiting) => {
setPanelValue(name, 'waiting', isWaiting);
};

self.showEnum = function(model, field, value, isShown) {
var eType = SIREPO.APP_SCHEMA.enum[appState.modelInfo(model)[field][SIREPO.INFO_INDEX_TYPE]];
var optionIndex = -1;
Expand Down
2 changes: 2 additions & 0 deletions sirepo/template/srw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ def _beamline_animation_percent_complete(run_dir, res):
if item.type == "watch":
res.outputInfo.append(
PKDict(
waitForData=True,
modelKey=f"beamlineAnimation{item.id}",
filename=_wavefront_pickle_filename(item.id),
id=item.id,
Expand All @@ -1166,6 +1167,7 @@ def _beamline_animation_percent_complete(run_dir, res):
# TODO(pjm): instead look at last byte == pickle.STOP, see template_common.read_last_csv_line()
wfr = pickle.load(f)
count += 1
info.waitForData = False
except Exception as e:
break
res.frameCount = count
Expand Down