本文整理汇总了PHP中wm_warn函数的典型用法代码示例。如果您正苦于以下问题:PHP wm_warn函数的具体用法?PHP wm_warn怎么用?PHP wm_warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wm_warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReadData
/**
* @param string $targetString The string from the config file
* @param the $map A reference to the map object (redundant)
* @param the $mapItem A reference to the object this target is attached to
* @return array invalue, outvalue, unix timestamp that the data was valid
*/
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetString, $matches)) {
$timezone = $matches[1];
$offset = "now";
if (preg_match("/^([^:]+):(.*)\$/", $timezone, $matches2)) {
$timezone = $matches2[1];
$offset = $matches2[2];
// test that the offset is valid
$timestamp = strtotime($offset);
if ($timestamp === false || $timestamp === -1) {
warn("Time ReadData: Offset String ({$offset}) is bogus - ignoring [WMTIME03]\n");
$offset = "now";
}
}
$timezone_l = strtolower($timezone);
if (array_key_exists($timezone_l, $this->timezones)) {
$tz = $this->timezones[$timezone_l];
wm_debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime($offset, new DateTimeZone($tz));
$mapItem->add_note("time_time12", $dateTime->format("h:i"));
$mapItem->add_note("time_time12ap", $dateTime->format("h:i A"));
$mapItem->add_note("time_time24", $dateTime->format("H:i"));
$mapItem->add_note("time_timet", $dateTime->format("U"));
$mapItem->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data[OUT] = $dateTime->format("i");
$data_time = time();
$matches++;
}
if ($matches == 0) {
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetString} \n");
}
wm_debug("Time ReadData: Returning (" . WMUtility::valueOrNull($data[IN]) . "," . WMUtility::valueOrNull($data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例2: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match("/^dbplug:([^:]+)\$/", $targetString, $matches)) {
$database_user = $map->get_hint('dbplug_dbuser');
$database_pass = $map->get_hint('dbplug_dbpass');
$database_name = $map->get_hint('dbplug_dbname');
$database_host = $map->get_hint('dbplug_dbhost');
$key = mysql_real_escape_string($matches[1]);
// This is the one line you will certainly need to change
$SQL = "select in,out from table where host={$key} LIMIT 1";
if (mysql_connect($database_host, $database_user, $database_pass)) {
if (mysql_select_db($database_name)) {
$result = mysql_query($SQL);
if (!$result) {
wm_warn("dbplug ReadData: Invalid query: " . mysql_error() . "\n");
} else {
$row = mysql_fetch_assoc($result);
$data[IN] = $row['in'];
$data[OUT] = $row['out'];
}
} else {
wm_warn("dbplug ReadData: failed to select database: " . mysql_error() . "\n");
}
} else {
wm_warn("dbplug ReadData: failed to connect to database server: " . mysql_error() . "\n");
}
$data_time = now();
}
wm_debug("RRD ReadData dbplug: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[IN]) . ", {$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例3: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$matches = 0;
if (preg_match($this->regexpsHandled[0], $targetString, $matches)) {
$dataFileName = $matches[1];
$dataItemName = $matches[2];
}
if (!file_exists($dataFileName)) {
wm_warn("WMData ReadData: {$dataFileName} doesn't exist [WMWMDATA01]");
return array(null, null, 0);
}
$fileHandle = fopen($targetString, "r");
if (!$fileHandle) {
wm_warn("WMData ReadData: Couldn't open ({$dataFileName}). [WMWMDATA02]\n");
return array(null, null, 0);
}
list($found, $data) = $this->findDataItem($fileHandle, $dataItemName, $data);
if ($found === true) {
$stats = stat($dataFileName);
$data_time = $stats['mtime'];
} else {
wm_warn("WMData ReadData: Data name '{$dataItemName}' didn't exist in '{$dataFileName}'. [WMWMDATA03]\n");
}
wm_debug(sprintf("WMData ReadData: Returning (%s, %s, %s)\n", string_or_null($data[IN]), string_or_null($data[OUT]), $data_time));
return array($data[IN], $data[OUT], $data_time);
}
示例4: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
$itemname = $item->name;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetstring, $matches)) {
$timezone = $matches[1];
$timezone_l = strtolower($timezone);
$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach ($timezone_identifiers as $tz) {
if (strtolower($tz) == $timezone_l) {
wm_debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime("now", new DateTimeZone($tz));
$item->add_note("time_time12", $dateTime->format("h:i"));
$item->add_note("time_time12ap", $dateTime->format("h:i A"));
$item->add_note("time_time24", $dateTime->format("H:i"));
$item->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data_time = time();
$data[OUT] = $dateTime->format("i");
$matches++;
}
}
if ($matches == 0) {
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetstring} \n");
}
wm_debug("Time ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例5: getTimeForTimeZone
/**
* @param $timezone
* @param $offset
* @return array
* @internal param $mapItem
* @internal param $data
* @internal param $matches
* @internal param $timezone_l
*/
private function getTimeForTimeZone($timezone, $offset)
{
$timezone_l = strtolower($timezone);
if (array_key_exists($timezone_l, $this->timezones)) {
$timezone_name = $this->timezones[$timezone_l];
wm_debug("Time ReadData: Timezone exists: {$timezone_name}\n");
$dateTime = new DateTime($offset, new DateTimeZone($timezone_name));
return array($dateTime, $timezone_name);
}
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
return null;
}
示例6: validateAndOpenFile
/**
* @param $fullpath
* @return resource
*/
protected function validateAndOpenFile($fullpath)
{
wm_debug("Opening {$fullpath}\n");
if (!file_exists($fullpath)) {
wm_warn("File '{$fullpath}' doesn't exist.");
return null;
}
if (!is_readable($fullpath)) {
wm_warn("File '{$fullpath}' isn't readable.");
return null;
}
$fileHandle = fopen($fullpath, "r");
return $fileHandle;
}
示例7: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$itemname = $item->name;
$matches = 0;
if (preg_match("/^wmdata:([^:]*):(.*)", $targetstring, $matches)) {
$datafile = $matches[1];
$dataname = $matches[2];
}
if (file_exists($datafile)) {
$fd = fopen($targetstring, "r");
if ($fd) {
$found = false;
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
# strip out any Windows line-endings that have gotten in here
$buffer = str_replace("\r", "", $buffer);
$fields = explode("\t", $buffer);
if ($fields[0] == $dataname) {
$data[IN] = $fields[1];
$data[OUT] = $fields[2];
$found = true;
}
}
if ($found === true) {
$stats = stat($datafile);
$data_time = $stats['mtime'];
} else {
wm_warn("WMData ReadData: Data name ({$dataname}) didn't exist in ({$datafile}). [WMWMDATA03]\n");
}
} else {
wm_warn("WMData ReadData: Couldn't open ({$datafile}). [WMWMDATA02]\n");
}
} else {
wm_warn("WMData ReadData: {$datafile} doesn't exist [WMWMDATA01]");
}
wm_debug(sprintf("WMData ReadData: Returning (%s, %s, %s)\n", string_or_null($data[IN]), string_or_null($data[OUT]), $data_time));
return array($data[IN], $data[OUT], $data_time);
}
示例8: wm_module_checks
function wm_module_checks()
{
if (!extension_loaded('gd')) {
wm_warn("\n\nNo image (gd) extension is loaded. This is required by weathermap. [WMWARN20]\n\n");
wm_warn("\nrun check.php to check PHP requirements.\n\n");
return false;
}
if (!function_exists('imagecreatefrompng')) {
wm_warn("Your GD php module doesn't support PNG format. [WMWARN21]\n");
wm_warn("\nrun check.php to check PHP requirements.\n\n");
return false;
}
if (!function_exists('imagecreatetruecolor')) {
wm_warn("Your GD php module doesn't support truecolor. [WMWARN22]\n");
wm_warn("\nrun check.php to check PHP requirements.\n\n");
return false;
}
if (!function_exists('imagecopyresampled')) {
wm_warn("Your GD php module doesn't support thumbnail creation (imagecopyresampled). [WMWARN23]\n");
}
return true;
}
示例9: ReadData
public function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$timeout = intval($this->owner->get_hint("snmp_timeout", 1000000));
$abort_count = intval($this->owner->get_hint("snmp_abort_count"), 0);
$retries = intval($this->owner->get_hint("snmp_retries"), 2);
if (preg_match($this->regexpsHandled[0], $targetString, $matches)) {
$community = $matches[1];
$host = $matches[2];
$oids = array();
$oids[IN] = $matches[3];
$oids[OUT] = $matches[4];
if ($abort_count == 0 || $abort_count > 0 && (!isset($this->down_cache[$host]) || intval($this->down_cache[$host]) < $abort_count)) {
$this->changeSNMPSettings();
$channels = array("in" => IN, "out" => OUT);
foreach ($channels as $channelName => $channel) {
if ($oids[$channel] != '-') {
$result = snmpget($host, $community, $oids[$channel], $timeout, $retries);
if ($result !== false) {
$data[$channel] = floatval($result);
$mapItem->add_hint("snmp_" . $channelName . "_raw", $result);
} else {
$this->down_cache[$host]++;
}
}
wm_debug("SNMP ReadData: Got {$result} for {$channelName}\n");
}
$data_time = time();
$this->restoreSNMPSettings();
} else {
wm_warn("SNMP for {$host} has reached {$abort_count} failures. Skipping. [WMSNMP01]");
}
}
wm_debug("SNMP ReadData: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例10: imagecreatefromfile
function imagecreatefromfile($filename)
{
$bgimage = null;
if (is_readable($filename)) {
list(, , $type, ) = getimagesize($filename);
switch ($type) {
case IMAGETYPE_GIF:
if (imagetypes() & IMG_GIF) {
$bgimage = imagecreatefromgif($filename);
} else {
wm_warn("Image file {$filename} is GIF, but GIF is not supported by your GD library. [WMIMG01]\n");
}
break;
case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPEG) {
$bgimage = imagecreatefromjpeg($filename);
} else {
wm_warn("Image file {$filename} is JPEG, but JPEG is not supported by your GD library. [WMIMG02]\n");
}
break;
case IMAGETYPE_PNG:
if (imagetypes() & IMG_PNG) {
$bgimage = imagecreatefrompng($filename);
} else {
wm_warn("Image file {$filename} is PNG, but PNG is not supported by your GD library. [WMIMG03]\n");
}
break;
default:
wm_warn("Image file {$filename} wasn't recognised (type={$type}). Check format is supported by your GD library. [WMIMG04]\n");
break;
}
} else {
wm_warn("Image file {$filename} is unreadable. Check permissions. [WMIMG05]\n");
}
return $bgimage;
}
示例11: pre_render
//.........这里部分代码省略.........
$map->myimagestring($icon_im, $font, $rx - $twid / 2, $ry - $quarter + $thgt / 2, $instr, $ink->gdallocate($icon_im));
list($twid, $thgt) = $map->myimagestringsize($font, $outstr);
$map->myimagestring($icon_im, $font, $rx - $twid / 2, $ry + $quarter + $thgt / 2, $outstr, $ink->gdallocate($icon_im));
imageellipse($icon_im, $rx, $ry, $rx * 2, $ry * 2, $ink->gdallocate($icon_im));
// imagearc($icon_im, $rx,$ry,$quarter*4,$quarter*4, 0,360, $ink->gdallocate($icon_im));
}
// print "NINK ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
}
// XXX - needs proper colours
if ($this->iconfile == 'inpie' || $this->iconfile == 'outpie') {
# list($colpie,$node_iconscalekey,$icontag) = $map->NewColourFromPercent($pc, $this->useiconscale,$this->name);
if ($this->iconfile == 'inpie') {
$segment_angle = $this->inpercent / 100 * 360;
}
if ($this->iconfile == 'outpie') {
$segment_angle = $this->outpercent / 100 * 360;
}
$rx = $this->iconscalew / 2 - 1;
$ry = $this->iconscaleh / 2 - 1;
if ($fill !== NULL && !$fill->is_none()) {
imagefilledellipse($icon_im, $rx, $ry, $rx * 2, $ry * 2, $fill->gdallocate($icon_im));
}
if ($ink !== NULL && !$ink->is_none()) {
// imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style )
imagefilledarc($icon_im, $rx, $ry, $rx * 2, $ry * 2, 0, $segment_angle, $ink->gdallocate($icon_im), IMG_ARC_PIE);
}
if ($fill !== NULL && !$fill->is_none()) {
imageellipse($icon_im, $rx, $ry, $rx * 2, $ry * 2, $fill->gdallocate($icon_im));
}
// warn('inpie AICON not implemented yet [WMWARN99]');
}
// if($this->iconfile=='outpie') { warn('outpie AICON not implemented yet [WMWARN99]'); }
if ($this->iconfile == 'gauge') {
wm_warn('gauge AICON not implemented yet [WMWARN99]');
}
} else {
$this->iconfile = $map->ProcessString($this->iconfile, $this);
if (is_readable($this->iconfile)) {
imagealphablending($im, true);
// draw the supplied icon, instead of the labelled box
$icon_im = imagecreatefromfile($this->iconfile);
# $icon_im = imagecreatefrompng($this->iconfile);
if (function_exists("imagefilter") && isset($colicon) && $this->get_hint("use_imagefilter") == 1) {
imagefilter($icon_im, IMG_FILTER_COLORIZE, $colicon->r, $colicon->g, $colicon->b);
} else {
if (isset($colicon)) {
// debug("Skipping unavailable imagefilter() call.\n");
imagecolorize($icon_im, $colicon->r, $colicon->g, $colicon->b);
}
}
wm_debug("If this is the last thing in your logs, you probably have a buggy GD library. Get > 2.0.33 or use PHP builtin.\n");
if ($icon_im) {
$icon_w = imagesx($icon_im);
$icon_h = imagesy($icon_im);
if ($this->iconscalew * $this->iconscaleh > 0) {
imagealphablending($icon_im, true);
wm_debug("SCALING ICON here\n");
if ($icon_w > $icon_h) {
$scalefactor = $icon_w / $this->iconscalew;
} else {
$scalefactor = $icon_h / $this->iconscaleh;
}
$new_width = $icon_w / $scalefactor;
$new_height = $icon_h / $scalefactor;
$scaled = imagecreatetruecolor($new_width, $new_height);
imagealphablending($scaled, false);
示例12: DrawMap
function DrawMap($filename = '', $thumbnailfile = '', $thumbnailmax = 250, $withnodes = TRUE, $use_via_overlay = FALSE, $use_rel_overlay=FALSE)
{
wm_debug("Trace: DrawMap()\n");
metadump("# start",true);
$bgimage=NULL;
if($this->configfile != "")
{
$this->cachefile_version = crc32(file_get_contents($this->configfile));
}
else
{
$this->cachefile_version = crc32("........");
}
wm_debug("Running Post-Processing Plugins...\n");
foreach ($this->postprocessclasses as $post_class)
{
wm_debug("Running $post_class"."->run()\n");
//call_user_func_array(array($post_class, 'run'), array(&$this));
$this->plugins['post'][$post_class]->run($this);
}
wm_debug("Finished Post-Processing Plugins...\n");
wm_debug("=====================================\n");
wm_debug("Start of Map Drawing\n");
$this->datestamp = strftime($this->stamptext, time());
// do the basic prep work
if ($this->background != '')
{
if (is_readable($this->background))
{
$bgimage=imagecreatefromfile($this->background);
if (!$bgimage) { wm_warn
("Failed to open background image. One possible reason: Is your BACKGROUND really a PNG?\n");
}
else
{
$this->width=imagesx($bgimage);
$this->height=imagesy($bgimage);
}
}
else { wm_warn
("Your background image file could not be read. Check the filename, and permissions, for "
. $this->background . "\n"); }
}
$image=wimagecreatetruecolor($this->width, $this->height);
# $image = imagecreate($this->width, $this->height);
if (!$image) { wm_warn
("Couldn't create output image in memory (" . $this->width . "x" . $this->height . ")."); }
else
{
ImageAlphaBlending($image, true);
# imageantialias($image,true);
// by here, we should have a valid image handle
// save this away, now
$this->image=$image;
$this->white=myimagecolorallocate($image, 255, 255, 255);
$this->black=myimagecolorallocate($image, 0, 0, 0);
$this->grey=myimagecolorallocate($image, 192, 192, 192);
$this->selected=myimagecolorallocate($image, 255, 0, 0); // for selections in the editor
$this->AllocateScaleColours($image);
// fill with background colour anyway, in case the background image failed to load
wimagefilledrectangle($image, 0, 0, $this->width, $this->height, $this->colours['DEFAULT']['BG']['gdref1']);
if ($bgimage)
{
imagecopy($image, $bgimage, 0, 0, 0, 0, $this->width, $this->height);
imagedestroy ($bgimage);
}
// Now it's time to draw a map
// do the node rendering stuff first, regardless of where they are actually drawn.
// this is so we can get the size of the nodes, which links will need if they use offsets
foreach ($this->nodes as $node)
{
// don't try and draw template nodes
wm_debug("Pre-rendering ".$node->name." to get bounding boxes.\n");
if(!is_null($node->x)) $this->nodes[$node->name]->pre_render($image, $this);
}
$all_layers = array_keys($this->seen_zlayers);
sort($all_layers);
foreach ($all_layers as $z)
{
$z_items = $this->seen_zlayers[$z];
wm_debug("Drawing layer $z\n");
// all the map 'furniture' is fixed at z=1000
//.........这里部分代码省略.........
示例13: weathermap_run_maps
function weathermap_run_maps($mydir) {
global $config;
global $weathermap_debugging, $WEATHERMAP_VERSION;
global $weathermap_map;
global $weathermap_warncount;
global $weathermap_poller_start_time;
include_once($mydir.DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."HTML_ImageMap.class.php");
include_once($mydir.DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."Weathermap.class.php");
$total_warnings = 0;
$warning_notes = "";
$start_time = time();
if($weathermap_poller_start_time==0) $weathermap_poller_start_time = $start_time;
$outdir = $mydir.DIRECTORY_SEPARATOR.'output';
$confdir = $mydir.DIRECTORY_SEPARATOR.'configs';
$mapcount = 0;
// take our debugging cue from the poller - turn on Poller debugging to get weathermap debugging
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_DEBUG)
{
$weathermap_debugging = TRUE;
$mode_message = "DEBUG mode is on";
}
else
{
$mode_message = "Normal logging mode. Turn on DEBUG in Cacti for more information";
}
$quietlogging = read_config_option("weathermap_quiet_logging");
// moved this outside the module_checks, so there should always be something in the logs!
if($quietlogging==0) cacti_log("Weathermap $WEATHERMAP_VERSION starting - $mode_message\n",true,"WEATHERMAP");
if(wm_module_checks())
{
weathermap_memory_check("MEM Initial");
// move to the weathermap folder so all those relatives paths don't *have* to be absolute
$orig_cwd = getcwd();
chdir($mydir);
db_execute("replace into settings values('weathermap_last_start_time','".mysql_real_escape_string(time())."')");
// first, see if the output directory even exists
if(is_dir($outdir))
{
// next, make sure that we stand a chance of writing files
//// $testfile = realpath($outdir."weathermap.permissions.test");
$testfile = $outdir.DIRECTORY_SEPARATOR."weathermap.permissions.test";
$testfd = fopen($testfile, 'w');
if($testfd)
{
fclose($testfd);
unlink($testfile);
$queryrows = db_fetch_assoc("select m.*, g.name as groupname from weathermap_maps m,weathermap_groups g where m.group_id=g.id and active='on' order by sortorder,id");
if( is_array($queryrows) )
{
wm_debug("Iterating all maps.");
$imageformat = strtolower(read_config_option("weathermap_output_format"));
$rrdtool_path = read_config_option("path_rrdtool");
foreach ($queryrows as $map) {
// reset the warning counter
$weathermap_warncount=0;
// this is what will prefix log entries for this map
$weathermap_map = "[Map ".$map['id']."] ".$map['configfile'];
wm_debug("FIRST TOUCH\n");
if(weathermap_check_cron($weathermap_poller_start_time,$map['schedule']))
{
$mapfile = $confdir.DIRECTORY_SEPARATOR.$map['configfile'];
$htmlfile = $outdir.DIRECTORY_SEPARATOR.$map['filehash'].".html";
$imagefile = $outdir.DIRECTORY_SEPARATOR.$map['filehash'].".".$imageformat;
$thumbimagefile = $outdir.DIRECTORY_SEPARATOR.$map['filehash'].".thumb.".$imageformat;
if(file_exists($mapfile))
{
if($quietlogging==0) wm_warn("Map: $mapfile -> $htmlfile & $imagefile\n",TRUE);
db_execute("replace into settings values('weathermap_last_started_file','".mysql_real_escape_string($weathermap_map)."')");
$map_start = time();
weathermap_memory_check("MEM starting $mapcount");
$wmap = new Weathermap;
$wmap->context = "cacti";
// we can grab the rrdtool path from Cacti's config, in this case
$wmap->rrdtool = $rrdtool_path;
$wmap->ReadConfig($mapfile);
$wmap->add_hint("mapgroup",$map['groupname']);
$wmap->add_hint("mapgroupextra",($map['group_id'] ==1 ? "" : $map['groupname'] ));
# in the order of precedence - global extras, group extras, and finally map extras
$queries = array();
$queries[] = "select * from weathermap_settings where mapid=0 and groupid=0";
//.........这里部分代码省略.........
示例14: readData
public function readData(&$map, &$mapItem)
{
wm_debug("ReadData for {$mapItem} ({$this->pluginName} {$this->pluginRunnable})\n");
if (!$this->pluginRunnable) {
wm_debug("Plugin %s isn't runnable\n", $this->pluginName);
return;
}
if ($this->scaleFactor != 1) {
wm_debug("Will multiply result by %f\n", $this->scaleFactor);
}
list($in, $out, $dataTime) = $this->pluginObject->ReadData($this->finalTargetString, $map, $mapItem);
if ($in === null && $out === null) {
wm_warn(sprintf("ReadData: %s, target: %s had no valid data, according to %s [WMWARN70]\n", $mapItem, $this->finalTargetString, $this->pluginName));
return;
}
wm_debug("Collected data %f,%f\n", $in, $out);
$in *= $this->scaleFactor;
$out *= $this->scaleFactor;
$this->values[IN] = $in;
$this->values[OUT] = $out;
$this->timestamp = $dataTime;
$this->dataValid = true;
}
示例15: Draw
function Draw($im, &$map)
{
// Get the positions of the end-points
$x1 = $map->nodes[$this->a->name]->x;
$y1 = $map->nodes[$this->a->name]->y;
$x2 = $map->nodes[$this->b->name]->x;
$y2 = $map->nodes[$this->b->name]->y;
if (is_null($x1)) {
wm_warn("LINK " . $this->name . " uses a NODE with no POSITION! [WMWARN35]\n");
return;
}
if (is_null($y1)) {
wm_warn("LINK " . $this->name . " uses a NODE with no POSITION! [WMWARN35]\n");
return;
}
if (is_null($x2)) {
wm_warn("LINK " . $this->name . " uses a NODE with no POSITION! [WMWARN35]\n");
return;
}
if (is_null($y2)) {
wm_warn("LINK " . $this->name . " uses a NODE with no POSITION! [WMWARN35]\n");
return;
}
if ($this->linkstyle == 'twoway' && $this->labeloffset_in < $this->labeloffset_out && intval($map->get_hint("nowarn_bwlabelpos")) == 0) {
wm_warn("LINK " . $this->name . " probably has it's BWLABELPOSs the wrong way around [WMWARN50]\n");
}
list($dx, $dy) = calc_offset($this->a_offset, $map->nodes[$this->a->name]->width, $map->nodes[$this->a->name]->height);
$x1 += $dx;
$y1 += $dy;
list($dx, $dy) = calc_offset($this->b_offset, $map->nodes[$this->b->name]->width, $map->nodes[$this->b->name]->height);
$x2 += $dx;
$y2 += $dy;
if ($x1 == $x2 && $y1 == $y2 && sizeof($this->vialist) == 0) {
wm_warn("Zero-length link " . $this->name . " skipped. [WMWARN45]");
return;
}
$outlinecol = new Colour($this->outlinecolour);
$commentcol = new Colour($this->commentfontcolour);
$outline_colour = $outlinecol->gdallocate($im);
$xpoints = array();
$ypoints = array();
$xpoints[] = $x1;
$ypoints[] = $y1;
# warn("There are VIAs.\n");
foreach ($this->vialist as $via) {
# imagearc($im, $via[0],$via[1],20,20,0,360,$map->selected);
if (isset($via[2])) {
$xpoints[] = $map->nodes[$via[2]]->x + $via[0];
$ypoints[] = $map->nodes[$via[2]]->y + $via[1];
} else {
$xpoints[] = $via[0];
$ypoints[] = $via[1];
}
}
$xpoints[] = $x2;
$ypoints[] = $y2;
# list($link_in_colour,$link_in_scalekey, $link_in_scaletag) = $map->NewColourFromPercent($this->inpercent,$this->usescale,$this->name);
# list($link_out_colour,$link_out_scalekey, $link_out_scaletag) = $map->NewColourFromPercent($this->outpercent,$this->usescale,$this->name);
$link_in_colour = $this->colours[IN];
$link_out_colour = $this->colours[OUT];
$gd_in_colour = $link_in_colour->gdallocate($im);
$gd_out_colour = $link_out_colour->gdallocate($im);
// $map->links[$this->name]->inscalekey = $link_in_scalekey;
// $map->links[$this->name]->outscalekey = $link_out_scalekey;
$link_width = $this->width;
// these will replace the one above, ultimately.
$link_in_width = $this->width;
$link_out_width = $this->width;
// for bulging animations
if ($map->widthmod || $map->get_hint('link_bulge') == 1) {
// a few 0.1s and +1s to fix div-by-zero, and invisible links
$link_width = ($link_width * $this->inpercent * 1.5 + 0.1) / 100 + 1;
// these too
$link_in_width = ($link_in_width * $this->inpercent * 1.5 + 0.1) / 100 + 1;
$link_out_width = ($link_out_width * $this->outpercent * 1.5 + 0.1) / 100 + 1;
}
// If there are no vias, treat this as a 2-point angled link, not curved
if (sizeof($this->vialist) == 0 || $this->viastyle == 'angled') {
// Calculate the spine points - the actual not a curve really, but we
// need to create the array, and calculate the distance bits, otherwise
// things like bwlabels won't know where to go.
$this->curvepoints = calc_straight($xpoints, $ypoints);
// then draw the "curve" itself
draw_straight($im, $this->curvepoints, array($link_in_width, $link_out_width), $outline_colour, array($gd_in_colour, $gd_out_colour), $this->name, $map, $this->splitpos, $this->linkstyle == 'oneway' ? TRUE : FALSE);
} elseif ($this->viastyle == 'curved') {
// Calculate the spine points - the actual curve
$this->curvepoints = calc_curve($xpoints, $ypoints);
// then draw the curve itself
draw_curve($im, $this->curvepoints, array($link_in_width, $link_out_width), $outline_colour, array($gd_in_colour, $gd_out_colour), $this->name, $map, $this->splitpos, $this->linkstyle == 'oneway' ? TRUE : FALSE);
}
if (!$commentcol->is_none()) {
if ($commentcol->is_contrast()) {
$commentcol_in = $link_in_colour->contrast();
$commentcol_out = $link_out_colour->contrast();
} else {
$commentcol_in = $commentcol;
$commentcol_out = $commentcol;
}
$comment_colour_in = $commentcol_in->gdallocate($im);
$comment_colour_out = $commentcol_out->gdallocate($im);
//.........这里部分代码省略.........