#!/bin/bash

#
# This script was made to create an integration between the POS and
# Miravision. The ideia is to create a system where multiple POS call
# a single queue of persons (like Primark)
#

CLERK=$1
STATION=$2
AREA=$3
CHECK=$4

#MIRA_IP="192.168.1.6"
MIRA_IP=""
MIRA_STATION_AREA=3

if [ "$MIRA_IP" = "" ]; then
  xmessage -center -timeout 5 "Edit common/data/custom_scripts/miravision_station_caller and define MIRA_IP"
  echo "STOP"
  exit
fi

export DISPLAY=:0.0

#xmessage "ALERT MESSAGE! CLERK: $CLERK, STATION: $STATION, AREA: $AREA, CHECK: $CHECK"

STATION_NUMBER=`cat /opt/pos/etc/config.ini | grep STATION_NUMBER= | cut -f2 -d=`
STATION_NUMBER=`expr $STATION_NUMBER + 1`

wget -O /dev/null "http://$MIRA_IP:3001/text/set/$MIRA_STATION_AREA?text=$STATION_NUMBER"
wget -O /dev/null "http://$MIRA_IP:3001/beep"
wget -O /dev/null "http://$MIRA_IP:3001/blink"

echo "STOP"

